Graphics.NewbieCubeSpin - lordmundi/wikidoctest GitHub Wiki
Newbie Cube Spin
« Hello Cube Plugin | NewbieIndex | Respin Cube Using Tcl »
Goal
Spin the cube through a plugin.
| Skeleton C-File For Spinning Cube | || | #include "doug.h"
void SpinCube() {
// Code to spin cube
}
DSP_InitializePlugin( DSS_PLUGIN *plugin )
{
DSF_InstallPluginFunction(plugin->handle, SpinCube,
DSD_PLUGIN_UPDATE_SCENE);
return 1;
} |
| * * *
- Functionality for the spinning cube will be in the "SpinCube()" function
- SpinCube() is registered with DSF_InstallPluginFunction() |
| spincube.c | || | #include "doug.h"
extern DSS_SCENE *DSV_scene;
void SpinCube() {
DSS_NODE* cube_node ;
int cube_id;
DSF_BgnModifyScene( DSV_scene );
cube_id = DSF_GetNodeID("CUBE");
cube_node = DSV_scene->node_list + cube_id ;
cube_node->P += 1.0 ;
cube_node->Y += 1.0 ;
cube_node->R += 1.0 ;
DSF_ModifiedNode( cube_id, DSD_PYR_MODIFIED ) ;
DSF_EndModifyScene( DSV_scene );
DSF_ExecuteCore();
}
DSP_InitializePlugin( DSS_PLUGIN *plugin )
{
DSF_InstallPluginFunction(plugin->handle, SpinCube,
DSD_PLUGIN_UPDATE_SCENE);
return 1;
} |
| * * *
To Build:
% cd ${DOUG_HOME}/src.dist/plugins
% mkdir spinCube
% vi spinCube/spincube.c
<Add source above>
% cp example/Makefile spinCube/
<Follow helloPlugin Makefile guide>
% make
To Run:
% cd ${USERDATA}
% vi user.cfg
Similar to the hellocube plugin line, ([assuming this was done][1])
Add spincube under the plugin section as well.
% ./run_graphics ; # Cube should twirl, possibly at LUDICROUS SPEED. |
areeves July 20, 2009, at 05:28 PM:
Got an error using spincube.c code above . . .
Fixed by changing:
"cube_id = DSF_GetNodeID("NEWBIE_CUBE");"
to
"cube_id = DSF_GetNodeID("CUBE");".
Also, under To Run: …
% vi newbie.cfg
If just did Newbie Cube Hello Plugin Tutorial, you will type:
% vi user.cfg
*djordan April 5, 2011, at 10:04 PM *:
Fixed these issues. Thanks Angela!