Changeset 1913
- Timestamp:
- 05/12/00 17:15:53 (9 years ago)
- Files:
-
- trunk/juggler_1.0/samples/pf/pfNav/Makefile.in (modified) (2 diffs)
- trunk/juggler_1.0/samples/pf/pfNav/pfNav.cpp (modified) (11 diffs)
- trunk/juggler_1.0/samples/pfNav/Makefile.in (modified) (2 diffs)
- trunk/juggler_1.0/samples/pfNav/pfNav.cpp (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/juggler_1.0/samples/pf/pfNav/Makefile.in
r1891 r1913 12 12 COMPILE = @CXX@ @DEFS@ $(VJ_INCLUDES) @CPPFLAGS@ @CXXFLAGS@ @DBG_FLAGS@ 13 13 LINK = @CXX@ @CPPFLAGS@ @CXXFLAGS@ @EXTRA_LINK_FLAGS@ 14 VJ_INCLUDES = @INCLUDES@ -I$(VJ_BASE_DIR)/include -I$( srcdir) -I$(srcdir)/../nav14 VJ_INCLUDES = @INCLUDES@ -I$(VJ_BASE_DIR)/include -I$(VJ_BASE_DIR)/include/Math -I$(srcdir) -I$(srcdir)/../nav 15 15 VJ_LIBS = @TEST_VJ_LIBS_BASIC@ @TEST_VJ_LIBS_GL@ @TEST_VJ_LIBS_PF@ @TEST_LIBS_BASIC@ 16 16 VPATH = @srcdir@ … … 30 30 EXTRA_LIBS = @TEST_EXTRA_LIBS_BASIC@ @TEST_EXTRA_LIBS_PF@ @TEST_EXTRA_LIBS_GL@ 31 31 32 OBJECTS = pfNav.@OBJ_FILE_SUFFIX@ 32 OBJECTS = pfNav.@OBJ_FILE_SUFFIX@ ../nav/pfTerryCollide.@OBJ_FILE_SUFFIX@ ../nav/pfTerryPogoCollide.@OBJ_FILE_SUFFIX@ ../nav/pfTerryBoxCollide.@OBJ_FILE_SUFFIX@ 33 33 34 34 # ----------------------------------------------------------------------------- trunk/juggler_1.0/samples/pf/pfNav/pfNav.cpp
r1888 r1913 49 49 // --- VR Juggler Stuff --- // 50 50 #include <Kernel/vjKernel.h> 51 #include <Kernel/Pf/vjPfApp.h> 51 #include <Kernel/Pf/vjPfApp.h> // the performer application base type 52 52 #include <Kernel/vjDebug.h> 53 #include <Kernel/vjProjection.h> 54 55 #include <pfNaver.h> 56 #include <collidor.h> 57 #include <planeCollidor.h> 58 #include <pfCollidor.h> 53 #include <Kernel/vjProjection.h> // for setNearFar (for setting clipping planes) 54 #include <Input/InputManager/vjPosInterface.h> 55 #include <Input/InputManager/vjDigitalInterface.h> 56 57 58 // nav includes 59 #include <CaveNavigator.h> 60 #include <collider.h> 61 #include <planeCollider.h> 62 #include <pfPogoCollider.h> 63 #include <pfRayCollider.h> 64 #include <pfBoxCollider.h> 59 65 60 66 char* filename = NULL; … … 62 68 63 69 // Declare my application class 64 class myApp: public vjPfApp70 class pfNavJugglerApplication : public vjPfApp 65 71 { 66 72 public: 67 myApp(vjKernel* kern) : vjPfApp(kern) 68 { 69 //rotation = 0.0f; 70 //zPos = 0.0f; 73 pfNavJugglerApplication( vjKernel* kern ) : mFpsEmitCount(0), vjPfApp( kern ) 74 { 75 // get a valid time on the stopwatch... 76 stopWatch.stop(); 77 stopWatch.start(); 71 78 } 72 79 … … 75 82 vjDEBUG(vjDBG_ALL, 1) << "app::init\n" << vjDEBUG_FLUSH; 76 83 vjProjection::setNearFar(0.5, 1000); 84 85 mWand.init( "VJWand" ); 86 mHead.init( "VJHead" ); 87 mActionButton.init( "VJButton0" ); 88 mActionButton2.init( "VJButton1" ); 89 mModeChangeButton.init( "VJButton2" ); 77 90 } 78 91 … … 86 99 // Initialize type system 87 100 vjDEBUG(vjDBG_ALL,1) << "app::preForkInit: Initializing new types.\n" << vjDEBUG_FLUSH; 88 pfNaver::init();89 101 90 102 // Initialize loaders 91 } 92 103 pfdInitConverter("terrain.flt"); 104 } 105 106 inline void textures( bool state ) const 107 { 108 if (state == true) 109 { 110 pfEnable( PFEN_TEXTURE ); 111 pfOverride(PFSTATE_ENTEXTURE, PF_ON); 112 } 113 114 else 115 { 116 pfDisable( PFEN_TEXTURE ); 117 pfOverride(PFSTATE_ENTEXTURE, PF_OFF); 118 } 119 } 120 93 121 /// Initialize the scene graph 94 122 virtual void initScene() … … 103 131 rootNode = new pfGroup; 104 132 105 naver = new pfNaver();133 mNavigationDCS = new pfDCS(); 106 134 107 135 sun1 = new pfLightSource; … … 111 139 sun1->setColor(PFLT_SPECULAR, 1.0f, 1.0f, 1.0f); 112 140 sun1->on(); 113 naver->addChild(sun1);141 mNavigationDCS->addChild(sun1); 114 142 115 143 // Light the root node … … 128 156 //pfNode* obj = pfdLoadFile("/usr/share/Performer/data/klingon.flt"); 129 157 pfNode* obj = pfdLoadFile( filename ); 130 rootNode->addChild( naver);158 rootNode->addChild( mNavigationDCS ); 131 159 132 160 pfDCS* world_model = new pfDCS; // The node with the world under it 133 //rootNode->addChild(world_model);134 161 world_model->addChild(obj); 135 162 world_model->setScale(0.25f); 136 163 world_model->setTrans(0.0,5.0,-5.0); 137 138 vjMatrix initial_pos; 139 initial_pos.setTrans(0,0,0); 140 naver->getNavigator()->setCurPos(initial_pos); 141 naver->addChild(world_model); 142 //*/ 143 164 mNavigationDCS->addChild(world_model); 165 144 166 // Load the TOWN 145 146 167 //pfFilePath("/usr/share/Performer/data:/usr/share/Performer/data/town"); 147 168 //pfNode* obj = pfdLoadFile("/usr/share/Performer/data/town/town_ogl_pfi.pfb"); 148 169 //pfDCS* world_model = new pfDCS; // The node with the world under it 149 //rootNode->addChild(naver); 150 170 //rootNode->addChild(mNavigationDCS); 151 171 //world_model->addChild(obj); 152 172 //world_model->setScale(3.0f); 153 //vjMatrix initial_pos; 173 174 // Configure the Navigator DCS node: 175 // Set it's initial position: 176 vjMatrix initial_pos; 154 177 //initial_pos.setTrans(7500,50,-7500); 155 //naver->getNavigator()->setCurPos(initial_pos); 156 //naver->addChild(world_model); 157 158 //planeCollidor* collide = new planeCollidor; 159 pfVolumeCollidor* correction_collide = new pfVolumeCollidor(world_model); 160 pfRideCollidor* ride_collide = new pfRideCollidor(world_model); 161 162 naver->getNavigator()->setGravityCollidor(ride_collide); 163 naver->getNavigator()->setCorrectingCollidor(correction_collide); 164 165 166 //pfuTravPrintNodes(rootNode, "nodes.out"); 167 //pfdStoreFile(rootNode, "nodes.pfb"); 178 initial_pos.setTrans(0, 6, 0); 179 mNavigator.getNavigator()->setCurPos(initial_pos); 180 181 // Set its terrain follower 182 //planeCollider* collide = new planeCollider; 183 pfPogoCollider* ride_collide = new pfPogoCollider(world_model); 184 mNavigator.getNavigator()->addCollider(ride_collide); 185 186 // Set the navigator's collider. 187 pfBoxCollider* correction_collide = new pfBoxCollider( world_model ); 188 mNavigator.getNavigator()->addCollider( correction_collide ); 189 190 191 // load these files into perfly to see just what your scenegraph 192 // looked like. . . . .useful for debugging. 193 pfuTravPrintNodes( rootNode, "nodes.out" ); 194 pfdStoreFile( rootNode, "nodes.pfb" ); 168 195 } 169 196 … … 179 206 virtual void preDrawChan(pfChannel* chan, void* chandata) 180 207 { 181 pfDisable(PFEN_TEXTURE); 182 pfOverride(PFSTATE_TEXTURE,PF_ON); // Override texturing to turn it off; 208 this->textures( true ); // Override texturing to turn it on; 183 209 } 184 210 … … 193 219 virtual void preFrame() 194 220 { 195 //vjDEBUG(vjDBG_ALL, 1) << "app::preFrame\n" << vjDEBUG_FLUSH; 196 static float x=10; 197 static float y=-5; 198 static float z=3; 199 static float amb=0.0f; 200 201 x+=0.05; 202 y+=0.04; 203 z+=0.02; 204 amb += 0.025f; 205 206 if(x>20.0f) 207 x = -20.0f; 208 if(y>20.0f) 209 y = -20.0f; 210 if(z>20.0f) 211 z = -20.0f; 212 if(amb>1.0f) 213 amb = 0.0f; 214 215 //sun1->setPos(x,y,z, 1.0f); 216 //cerr << "set ambient: " << amb << endl; 217 //sun1->setColor(PFLT_AMBIENT, amb, amb, amb); 218 } 219 221 // Keep time, for FPS measurments... 222 stopWatch.stop(); 223 stopWatch.start(); 224 225 ///////////////////////////////////////////////////////// 226 //: Handle navigation 227 228 if (mActionButton2->getData() == vjDigital::TOGGLE_ON) 229 cout<<"Brake\n"<<flush; 230 if (mActionButton->getData() == vjDigital::TOGGLE_ON) 231 cout<<"Accelerate\n"<<flush; 232 233 // let the navigator collect some instructions from input devices... 234 mNavigator.accelerate( mActionButton->getData() == vjDigital::ON || 235 mActionButton->getData() == vjDigital::TOGGLE_ON ); 236 mNavigator.brake( mActionButton2->getData() == vjDigital::ON || 237 mActionButton2->getData() == vjDigital::TOGGLE_ON ); 238 mNavigator.rotate( mActionButton2->getData() != vjDigital::ON && 239 mActionButton2->getData() != vjDigital::TOGGLE_ON ); 240 vjMatrix* wandMatrix = mWand->getData(); 241 vjMatrix rotMatrix = *wandMatrix; 242 rotMatrix( 0, 3 ) = 0.0f; 243 rotMatrix( 1, 3 ) = 0.0f; 244 rotMatrix( 2, 3 ) = 0.0f; 245 mNavigator.setMatrix( rotMatrix ); 246 247 // tell the navigator to update itself with any new instructions just given to it. 248 mNavigator.update(); 249 250 // notify the navigator DCS of the mNavigator's new matrix 251 pfMatrix mNavigator_pf = vjGetPfMatrix( mNavigator ); 252 mNavigationDCS->setMat( mNavigator_pf ); 253 254 // output the FPS so the team artist can get metrics on their model 255 ++mFpsEmitCount; 256 if (mFpsEmitCount >= 15) 257 { 258 cout<<"FPS: "<<stopWatch.fpsAverage<<"\n"<<flush; 259 mFpsEmitCount = 0; 260 } 261 } 262 263 int mFpsEmitCount; 264 StopWatch stopWatch; 265 220 266 /// Function called after pfDraw 221 267 virtual void intraFrame() … … 225 271 226 272 public: 273 // the sun 227 274 pfLightSource* sun1; 228 275 229 pfNaver* naver; 230 //pfDCS* baseDCS; 276 // navigation objects. 277 CaveNavigator mNavigator; 278 pfDCS* mNavigationDCS; 279 280 // juggler device interface objects 281 vjPosInterface mWand; // the Wand 282 vjPosInterface mHead; // the Head 283 vjDigitalInterface mActionButton; 284 vjDigitalInterface mActionButton2; 285 vjDigitalInterface mModeChangeButton; 286 287 // scene's root (as far as we're concerned here) 231 288 pfGroup* rootNode; 232 289 }; … … 239 296 { 240 297 vjKernel* kernel = vjKernel::instance(); // Declare a new Kernel 241 myApp* application = new myApp(kernel); // Delcare an instance of my application298 pfNavJugglerApplication* application = new pfNavJugglerApplication(kernel); // Delcare an instance of my application 242 299 243 300 if (argc < 2) trunk/juggler_1.0/samples/pfNav/Makefile.in
r1891 r1913 12 12 COMPILE = @CXX@ @DEFS@ $(VJ_INCLUDES) @CPPFLAGS@ @CXXFLAGS@ @DBG_FLAGS@ 13 13 LINK = @CXX@ @CPPFLAGS@ @CXXFLAGS@ @EXTRA_LINK_FLAGS@ 14 VJ_INCLUDES = @INCLUDES@ -I$(VJ_BASE_DIR)/include -I$( srcdir) -I$(srcdir)/../nav14 VJ_INCLUDES = @INCLUDES@ -I$(VJ_BASE_DIR)/include -I$(VJ_BASE_DIR)/include/Math -I$(srcdir) -I$(srcdir)/../nav 15 15 VJ_LIBS = @TEST_VJ_LIBS_BASIC@ @TEST_VJ_LIBS_GL@ @TEST_VJ_LIBS_PF@ @TEST_LIBS_BASIC@ 16 16 VPATH = @srcdir@ … … 30 30 EXTRA_LIBS = @TEST_EXTRA_LIBS_BASIC@ @TEST_EXTRA_LIBS_PF@ @TEST_EXTRA_LIBS_GL@ 31 31 32 OBJECTS = pfNav.@OBJ_FILE_SUFFIX@ 32 OBJECTS = pfNav.@OBJ_FILE_SUFFIX@ ../nav/pfTerryCollide.@OBJ_FILE_SUFFIX@ ../nav/pfTerryPogoCollide.@OBJ_FILE_SUFFIX@ ../nav/pfTerryBoxCollide.@OBJ_FILE_SUFFIX@ 33 33 34 34 # ----------------------------------------------------------------------------- trunk/juggler_1.0/samples/pfNav/pfNav.cpp
r1888 r1913 49 49 // --- VR Juggler Stuff --- // 50 50 #include <Kernel/vjKernel.h> 51 #include <Kernel/Pf/vjPfApp.h> 51 #include <Kernel/Pf/vjPfApp.h> // the performer application base type 52 52 #include <Kernel/vjDebug.h> 53 #include <Kernel/vjProjection.h> 54 55 #include <pfNaver.h> 56 #include <collidor.h> 57 #include <planeCollidor.h> 58 #include <pfCollidor.h> 53 #include <Kernel/vjProjection.h> // for setNearFar (for setting clipping planes) 54 #include <Input/InputManager/vjPosInterface.h> 55 #include <Input/InputManager/vjDigitalInterface.h> 56 57 58 // nav includes 59 #include <CaveNavigator.h> 60 #include <collider.h> 61 #include <planeCollider.h> 62 #include <pfPogoCollider.h> 63 #include <pfRayCollider.h> 64 #include <pfBoxCollider.h> 59 65 60 66 char* filename = NULL; … … 62 68 63 69 // Declare my application class 64 class myApp: public vjPfApp70 class pfNavJugglerApplication : public vjPfApp 65 71 { 66 72 public: 67 myApp(vjKernel* kern) : vjPfApp(kern) 68 { 69 //rotation = 0.0f; 70 //zPos = 0.0f; 73 pfNavJugglerApplication( vjKernel* kern ) : mFpsEmitCount(0), vjPfApp( kern ) 74 { 75 // get a valid time on the stopwatch... 76 stopWatch.stop(); 77 stopWatch.start(); 71 78 } 72 79 … … 75 82 vjDEBUG(vjDBG_ALL, 1) << "app::init\n" << vjDEBUG_FLUSH; 76 83 vjProjection::setNearFar(0.5, 1000); 84 85 mWand.init( "VJWand" ); 86 mHead.init( "VJHead" ); 87 mActionButton.init( "VJButton0" ); 88 mActionButton2.init( "VJButton1" ); 89 mModeChangeButton.init( "VJButton2" ); 77 90 } 78 91 … … 86 99 // Initialize type system 87 100 vjDEBUG(vjDBG_ALL,1) << "app::preForkInit: Initializing new types.\n" << vjDEBUG_FLUSH; 88 pfNaver::init();89 101 90 102 // Initialize loaders 91 } 92 103 pfdInitConverter("terrain.flt"); 104 } 105 106 inline void textures( bool state ) const 107 { 108 if (state == true) 109 { 110 pfEnable( PFEN_TEXTURE ); 111 pfOverride(PFSTATE_ENTEXTURE, PF_ON); 112 } 113 114 else 115 { 116 pfDisable( PFEN_TEXTURE ); 117 pfOverride(PFSTATE_ENTEXTURE, PF_OFF); 118 } 119 } 120 93 121 /// Initialize the scene graph 94 122 virtual void initScene() … … 103 131 rootNode = new pfGroup; 104 132 105 naver = new pfNaver();133 mNavigationDCS = new pfDCS(); 106 134 107 135 sun1 = new pfLightSource; … … 111 139 sun1->setColor(PFLT_SPECULAR, 1.0f, 1.0f, 1.0f); 112 140 sun1->on(); 113 naver->addChild(sun1);141 mNavigationDCS->addChild(sun1); 114 142 115 143 // Light the root node … … 128 156 //pfNode* obj = pfdLoadFile("/usr/share/Performer/data/klingon.flt"); 129 157 pfNode* obj = pfdLoadFile( filename ); 130 rootNode->addChild( naver);158 rootNode->addChild( mNavigationDCS ); 131 159 132 160 pfDCS* world_model = new pfDCS; // The node with the world under it 133 //rootNode->addChild(world_model);134 161 world_model->addChild(obj); 135 162 world_model->setScale(0.25f); 136 163 world_model->setTrans(0.0,5.0,-5.0); 137 138 vjMatrix initial_pos; 139 initial_pos.setTrans(0,0,0); 140 naver->getNavigator()->setCurPos(initial_pos); 141 naver->addChild(world_model); 142 //*/ 143 164 mNavigationDCS->addChild(world_model); 165 144 166 // Load the TOWN 145 146 167 //pfFilePath("/usr/share/Performer/data:/usr/share/Performer/data/town"); 147 168 //pfNode* obj = pfdLoadFile("/usr/share/Performer/data/town/town_ogl_pfi.pfb"); 148 169 //pfDCS* world_model = new pfDCS; // The node with the world under it 149 //rootNode->addChild(naver); 150 170 //rootNode->addChild(mNavigationDCS); 151 171 //world_model->addChild(obj); 152 172 //world_model->setScale(3.0f); 153 //vjMatrix initial_pos; 173 174 // Configure the Navigator DCS node: 175 // Set it's initial position: 176 vjMatrix initial_pos; 154 177 //initial_pos.setTrans(7500,50,-7500); 155 //naver->getNavigator()->setCurPos(initial_pos); 156 //naver->addChild(world_model); 157 158 //planeCollidor* collide = new planeCollidor; 159 pfVolumeCollidor* correction_collide = new pfVolumeCollidor(world_model); 160 pfRideCollidor* ride_collide = new pfRideCollidor(world_model); 161 162 naver->getNavigator()->setGravityCollidor(ride_collide); 163 naver->getNavigator()->setCorrectingCollidor(correction_collide); 164 165 166 //pfuTravPrintNodes(rootNode, "nodes.out"); 167 //pfdStoreFile(rootNode, "nodes.pfb"); 178 initial_pos.setTrans(0, 6, 0); 179 mNavigator.getNavigator()->setCurPos(initial_pos); 180 181 // Set its terrain follower 182 //planeCollider* collide = new planeCollider; 183 pfPogoCollider* ride_collide = new pfPogoCollider(world_model); 184 mNavigator.getNavigator()->addCollider(ride_collide); 185 186 // Set the navigator's collider. 187 pfBoxCollider* correction_collide = new pfBoxCollider( world_model ); 188 mNavigator.getNavigator()->addCollider( correction_collide ); 189 190 191 // load these files into perfly to see just what your scenegraph 192 // looked like. . . . .useful for debugging. 193 pfuTravPrintNodes( rootNode, "nodes.out" ); 194 pfdStoreFile( rootNode, "nodes.pfb" ); 168 195 } 169 196 … … 179 206 virtual void preDrawChan(pfChannel* chan, void* chandata) 180 207 { 181 pfDisable(PFEN_TEXTURE); 182 pfOverride(PFSTATE_TEXTURE,PF_ON); // Override texturing to turn it off; 208 this->textures( true ); // Override texturing to turn it on; 183 209 } 184 210 … … 193 219 virtual void preFrame() 194 220 { 195 //vjDEBUG(vjDBG_ALL, 1) << "app::preFrame\n" << vjDEBUG_FLUSH; 196 static float x=10; 197 static float y=-5; 198 static float z=3; 199 static float amb=0.0f; 200 201 x+=0.05; 202 y+=0.04; 203 z+=0.02; 204 amb += 0.025f; 205 206 if(x>20.0f) 207 x = -20.0f; 208 if(y>20.0f) 209 y = -20.0f; 210 if(z>20.0f) 211 z = -20.0f; 212 if(amb>1.0f) 213 amb = 0.0f; 214 215 //sun1->setPos(x,y,z, 1.0f); 216 //cerr << "set ambient: " << amb << endl; 217 //sun1->setColor(PFLT_AMBIENT, amb, amb, amb); 218 } 219 221 // Keep time, for FPS measurments... 222 stopWatch.stop(); 223 stopWatch.start(); 224 225 ///////////////////////////////////////////////////////// 226 //: Handle navigation 227 228 if (mActionButton2->getData() == vjDigital::TOGGLE_ON) 229 cout<<"Brake\n"<<flush; 230 if (mActionButton->getData() == vjDigital::TOGGLE_ON) 231 cout<<"Accelerate\n"<<flush; 232 233 // let the navigator collect some instructions from input devices... 234 mNavigator.accelerate( mActionButton->getData() == vjDigital::ON || 235 mActionButton->getData() == vjDigital::TOGGLE_ON ); 236 mNavigator.brake( mActionButton2->getData() == vjDigital::ON || 237 mActionButton2->getData() == vjDigital::TOGGLE_ON ); 238 mNavigator.rotate( mActionButton2->getData() != vjDigital::ON && 239 mActionButton2->getData() != vjDigital::TOGGLE_ON ); 240 vjMatrix* wandMatrix = mWand->getData(); 241 vjMatrix rotMatrix = *wandMatrix; 242 rotMatrix( 0, 3 ) = 0.0f; 243 rotMatrix( 1, 3 ) = 0.0f; 244 rotMatrix( 2, 3 ) = 0.0f; 245 mNavigator.setMatrix( rotMatrix ); 246 247 // tell the navigator to update itself with any new instructions just given to it. 248 mNavigator.update(); 249 250 // notify the navigator DCS of the mNavigator's new matrix 251 pfMatrix mNavigator_pf = vjGetPfMatrix( mNavigator ); 252 mNavigationDCS->setMat( mNavigator_pf ); 253 254 // output the FPS so the team artist can get metrics on their model 255 ++mFpsEmitCount; 256 if (mFpsEmitCount >= 15) 257 { 258 cout<<"FPS: "<<stopWatch.fpsAverage<<"\n"<<flush; 259 mFpsEmitCount = 0; 260 } 261 } 262 263 int mFpsEmitCount; 264 StopWatch stopWatch; 265 220 266 /// Function called after pfDraw 221 267 virtual void intraFrame() … … 225 271 226 272 public: 273 // the sun 227 274 pfLightSource* sun1; 228 275 229 pfNaver* naver; 230 //pfDCS* baseDCS; 276 // navigation objects. 277 CaveNavigator mNavigator; 278 pfDCS* mNavigationDCS; 279 280 // juggler device interface objects 281 vjPosInterface mWand; // the Wand 282 vjPosInterface mHead; // the Head 283 vjDigitalInterface mActionButton; 284 vjDigitalInterface mActionButton2; 285 vjDigitalInterface mModeChangeButton; 286 287 // scene's root (as far as we're concerned here) 231 288 pfGroup* rootNode; 232 289 }; … … 239 296 { 240 297 vjKernel* kernel = vjKernel::instance(); // Declare a new Kernel 241 myApp* application = new myApp(kernel); // Delcare an instance of my application298 pfNavJugglerApplication* application = new pfNavJugglerApplication(kernel); // Delcare an instance of my application 242 299 243 300 if (argc < 2)
