#include #include #include #include #include #include #include #include #include #include "simpleNavigator.h" #include "grabberDCS.h" static void createScene(pfChannel *chan,int argc,char **argv); static void loadObjects(int argc,char **argv,pfGroup *parent); static int grabTest(pfTraverser *trav,void *); static int buttonChange=0; /* main() - this is identical to the skeleton main of outline.c++, except for the call to simplNavigator::init(). All subclasses of Performer classes must be initialized like this after pfInit(). */ int main(int argc,char **argv) { pfInit(); simpleNavigator::init(); grabberDCS::init(); pfCAVEConfig(&argc,argv,NULL); pfConfig(); pfCAVEInitChannels(); if (CAVEConfig->Simulator) pfCAVEMasterChan()->getFStats()->setClass( PFSTATS_ALL^PFSTATSHW_ENGFXPIPE_FILL, PFSTATS_ON); else pfCAVEMasterChan()->getFStats()->setClass(PFSTATS_ALL, PFSTATS_OFF); createScene(pfCAVEMasterChan(),argc,argv); while (!CAVEgetbutton(CAVE_ESCKEY)) { buttonChange = CAVEButtonChange(2); pfSync(); pfCAVEPreFrame(); pfFrame(); pfCAVEPostFrame(); } pfCAVEHalt(); pfExit(); return 0; } /* createScene() - creates the scene. This is the same as in navobj.c++, except that a simpleNavigator node is used in place of the DCS for navigation. */ static void createScene(pfChannel *chan,int argc,char **argv) { pfScene *scene; pfGeoState *gstate; simpleNavigator *nav; scene = new pfScene; gstate = new pfGeoState; gstate->setMode(PFSTATE_ENLIGHTING, PF_ON); gstate->setMode(PFSTATE_CULLFACE, PFCF_OFF); scene->setGState(gstate); scene->addChild(new pfLightSource); nav = new simpleNavigator; /* Create the navigator & add it to the scene */ scene->addChild(nav); loadObjects(argc,argv,nav); chan->setScene(scene); } static void loadObjects(int argc,char **argv,pfGroup *parent) { int i; pfNode *obj; for (i=1; isetTrans(drand48()*10.0f-5.0f, drand48()*10.0f-5.0f, 3.0f); g->setTravFuncs(PFTRAV_APP, grabTest, NULL); g->addChild(obj); parent->addChild(g); } else pfExit(); } } static int grabTest(pfTraverser *trav,void *) { if (buttonChange == 1) { grabberDCS *g = (grabberDCS *) trav->getNode(); if (g->isGrabbed()) g->release(); else { pfSphere boundSphere; pfVec3 wandPos; g->getBound(&boundSphere); CAVEGetPosition(CAVE_WAND_NAV, wandPos.vec); if (boundSphere.contains(wandPos)) g->grab(); } } return PFTRAV_CONT; }