Changeset 2491 for GTP/trunk/App/Demos/Illum/Ogre/src
- Timestamp:
- 07/02/07 20:24:25 (17 years ago)
- Location:
- GTP/trunk/App/Demos/Illum/Ogre/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/src/Moria/scripts/Moria.7.10.vcproj
r2473 r2491 35 35 <Tool 36 36 Name="VCLinkerTool" 37 AdditionalDependencies="OgreMain_d.lib GTGeometry_d.libIllumModule_Ogre.lib IllumModule.lib NxOgre_d.lib"37 AdditionalDependencies="OgreMain_d.lib IllumModule_Ogre.lib IllumModule.lib NxOgre_d.lib" 38 38 OutputFile="$(OutDir)/Moria.exe" 39 39 LinkIncremental="1" … … 102 102 <Tool 103 103 Name="VCLinkerTool" 104 AdditionalDependencies="OgreMain.lib GTGeometry.libIllumModule_Ogre.lib IllumModule.lib NxOgre.lib"104 AdditionalDependencies="OgreMain.lib IllumModule_Ogre.lib IllumModule.lib NxOgre.lib" 105 105 OutputFile="$(OutDir)/Moria.exe" 106 106 LinkIncremental="1" -
GTP/trunk/App/Demos/Illum/Ogre/src/SpaceStation/include/SpaceStation.h
r2472 r2491 52 52 Entity* LightButton; 53 53 Entity* SmokeButton; 54 55 AnimationState* scientistAnimState; 54 SceneNode* hlNode; 55 SceneNode* rlNode; 56 57 int targetCount = 6; 58 Vector3 targets[] = {Vector3(-8.5,-1.3, -9.8), 59 Vector3(-9.8,-1.3,-10.7), 60 Vector3(-6.5,-1.3,-11.5), 61 Vector3(-6.3,-1.3,-9.6), 62 Vector3(-7.7,-1.3,-10.6), 63 Vector3(-5.4,-1.3,-10.9)}; 64 65 class Scientist : FrameListener 66 { 67 public: 68 Scientist(String name, SceneManager* mSceneMgr) 69 { 70 scientist = mSceneMgr->createEntity(name, "scientist.mesh"); 71 mNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); 72 mNode->setPosition(-7.5,-1.3,-11); 73 mNode->setScale(0.02,0.02,0.02); 74 mNode->attachObject(scientist); 75 scientist->setCastShadows(true); 76 mNode->_updateBounds(); 77 animState = scientist->getAnimationState("idle"); 78 animState->setEnabled(true); 79 80 setPriority(20); 81 Root::getSingleton().addFrameListener(this); 82 83 waitTimer = new Timer(); 84 waitTimer->reset(); 85 86 wait_min = 2000; 87 wait_max = 5000; 88 waitTime = Math::RangeRandom(wait_min, wait_max); 89 90 targetReached = true; 91 movespeed = 0.2; 92 } 93 94 bool frameStarted(const FrameEvent& evt) 95 { 96 animState->addTime(evt.timeSinceLastFrame * 0.75); 97 98 //mNode->translate(movespeed * 0.001 * Vector3(0,0,1), Node::TS_LOCAL); 99 100 Vector3 pos = mNode->getWorldPosition(); 101 dir = target - pos; 102 if(!targetReached && dir.length() < 0.05) 103 { 104 waitTimer->reset(); 105 targetReached = true; 106 animState = scientist->getAnimationState("idle"); 107 animState->setEnabled(true); 108 animState->setLoop(true); 109 } 110 111 if(!targetReached) 112 { 113 //move forward to target 114 mNode->translate(movespeed * 0.1 * Vector3(0,0,1), Node::TS_LOCAL); 115 } 116 else 117 { 118 //look for new target 119 if(waitTimer->getMilliseconds() > waitTime) 120 { 121 int nextTarget = (int)(Math::UnitRandom() * targetCount); 122 target = targets[nextTarget]; 123 dir = target - mNode->getWorldPosition(); 124 dir.normalise(); 125 Vector3 right = -dir.crossProduct(Vector3::UNIT_Y); 126 Quaternion q; 127 q.FromAxes(right,Vector3::UNIT_Y, dir); 128 mNode->setOrientation(q); 129 130 targetReached = false; 131 animState = scientist->getAnimationState("walk"); 132 animState->setEnabled(true); 133 animState->setLoop(true); 134 } 135 } 136 137 return true; 138 } 139 140 Entity* scientist; 141 SceneNode* mNode; 142 Vector3 target; 143 Vector3 dir; 144 float movespeed; 145 bool targetReached; 146 Timer* waitTimer; 147 AnimationState* animState; 148 int wait_min; 149 int wait_max; 150 int waitTime; 151 152 }; 56 153 57 154 // Listener class for frame updates … … 86 183 bool frameStarted(const FrameEvent& evt) 87 184 { 88 scientistAnimState->addTime(evt.timeSinceLastFrame); 89 185 90 186 if(smokeOffTimer->getMilliseconds()>10) 91 187 { … … 100 196 static float rotate = 0; 101 197 rotate += dt * 100.0; 102 Vector3 dir(Math::Sin(Radian(Degree(rotate))), -1.4,Math::Cos(Radian(Degree(rotate)))); 198 hlNode->rotate(Vector3(0,1,0),Radian(-Degree(dt * 100.0))); 199 rlNode->rotate(Vector3(0,1,0),Radian(-Degree(dt * 100.0))); 200 Vector3 dir(Math::Cos(Radian(Degree(rotate))), -1.4,Math::Sin(Radian(Degree(rotate)))); 103 201 dir.normalise(); 104 202 if(light1) … … 122 220 smokeSystem->getEmitter(0)->setEmissionRate(0); 123 221 smokeOffTimer->reset(); 124 } 125 void smokebuttonpressed() 222 Ogre::Material* blueMat = (Ogre::Material*) MaterialManager::getSingleton().getByName("Station/bluebutton").getPointer(); 223 blueMat->getTechnique(0)->getPass(0)->setAmbient(0.01,0.01,0.01); 224 if(smokeON) 225 SmokeButton->getParentSceneNode()->translate(0,0.02,0,Node::TS_LOCAL); 226 } 227 void lightbuttonpressed() 126 228 { 127 229 hallLightON = !hallLightON; … … 129 231 if(!hallLightON) 130 232 { 233 turnSmokeOff(); 131 234 smokeON = false; 132 turnSmokeOff(); 235 236 LightButton->getParentSceneNode()->translate(0,0.02,0,Node::TS_LOCAL); 237 Ogre::Material* redMat = (Ogre::Material*) MaterialManager::getSingleton().getByName("Station/redbutton").getPointer(); 238 redMat->getTechnique(0)->getPass(0)->setAmbient(0.1,0.01,0.01); 239 Ogre::Material* lampMat = (Ogre::Material*) MaterialManager::getSingleton().getByName("Station_lamp").getPointer(); 240 lampMat->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("color",Vector4(0,0,0,0)); 241 133 242 } 134 } 135 void lightbuttonpressed() 243 else 244 { 245 LightButton->getParentSceneNode()->translate(0,-0.02,0,Node::TS_LOCAL); 246 Ogre::Material* redMat = (Ogre::Material*) MaterialManager::getSingleton().getByName("Station/redbutton").getPointer(); 247 redMat->getTechnique(0)->getPass(0)->setAmbient(1,0.1,0.1); 248 Ogre::Material* lampMat = (Ogre::Material*) MaterialManager::getSingleton().getByName("Station_lamp").getPointer(); 249 lampMat->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("color",Vector4(20,20,20,20)); 250 } 251 252 253 254 } 255 void smokebuttonpressed() 136 256 { 137 257 if(hallLightON) … … 143 263 smokeSystem->setVisible(true); 144 264 smokeVisible = true; 265 266 SmokeButton->getParentSceneNode()->translate(0,-0.02,0,Node::TS_LOCAL); 267 Ogre::Material* blueMat = (Ogre::Material*) MaterialManager::getSingleton().getByName("Station/bluebutton").getPointer(); 268 blueMat->getTechnique(0)->getPass(0)->setAmbient(0.1,0.1,1); 145 269 } 146 270 else 147 271 { 148 272 turnSmokeOff(); 273 SmokeButton->getParentSceneNode()->translate(0,0.02,0,Node::TS_LOCAL); 149 274 } 150 275 … … 279 404 if( dist < 1 && FPSPlayer::thePlayer->getDirection().dotProduct(Vector3(0,0,-1))>0) 280 405 { 281 if(PlayerPos.x > -1.5375)//lightbutton 406 if(PlayerPos.x > -1.5375) 407 { 408 smokebuttonpressed(); 409 } 410 else 282 411 { 283 412 lightbuttonpressed(); 284 }285 else//smokebutton286 {287 smokebuttonpressed();288 413 } 289 414 } … … 466 591 lbNode->rotate(Vector3(1,0,0), Degree(30.0)); 467 592 lbNode->attachObject(LightButton); 593 lbNode->translate(0,-0.02,0,Node::TS_LOCAL); 468 594 LightButton->setMaterialName("Station/redbutton"); 469 595 … … 474 600 sbNode->rotate(Vector3(1,0,0), Degree(30.0)); 475 601 sbNode->attachObject(SmokeButton); 476 SmokeButton->setMaterialName("Station/bluebutton"); 477 478 Entity* scientist = mSceneMgr->createEntity("scientist", "scientist.mesh"); 479 //scientist->setMaterialName("GTP/Diffuse/Disc2Point"); 480 SceneNode* aNode = rootNode->createChildSceneNode(); 481 aNode->setPosition(-7.5,-1.3,-11); 482 aNode->setScale(0.02,0.02,0.02); 483 aNode->attachObject(scientist); 484 scientist->setCastShadows(true); 485 aNode->_updateBounds(); 486 AxisAlignedBox bb4 = scientist->getWorldBoundingBox(); 487 AxisAlignedBox bb3 = scientist->getBoundingBox(); 488 Ogre::Sphere bs2 = scientist->getWorldBoundingSphere(); 489 scientistAnimState = scientist->getAnimationState("idle"); 490 scientistAnimState->setEnabled(true); 491 492 PlayerCharacter::frameListenerPriority = 20; 493 494 gFPSPlayer = new FPSPlayer(NXScene, mSceneMgr, Vector3(0.4, 1.0, 0.35),/* Vector3(-0.6,-0.5,-24)*/Vector3(0, -0.5, 11.5), 1.15, mCamera, false); 602 sbNode->translate(0,-0.02,0,Node::TS_LOCAL); 603 SmokeButton->setMaterialName("Station/bluebutton"); 604 605 Entity* hallLampHolder = mSceneMgr->createEntity("hallLampHolder", "hallLampHolder.mesh"); 606 SceneNode* hlhNode = rootNode->createChildSceneNode(); 607 hlhNode->setPosition(-1.547, 4.308, -24.242); 608 hlhNode->attachObject(hallLampHolder); 609 610 Entity* hallLamp = mSceneMgr->createEntity("hallLamp", "hallLamp.mesh"); 611 hlNode = rootNode->createChildSceneNode(); 612 hlNode->setPosition(-1.547, 2.899, -24.242); 613 hlNode->attachObject(hallLamp); 614 hallLamp->setCastShadows(false); 615 616 Entity* roomLamp = mSceneMgr->createEntity("roomLamp", "roomLamp.mesh"); 617 rlNode = rootNode->createChildSceneNode(); 618 rlNode->setPosition(-7.579, 1.000, -10.831); 619 rlNode->attachObject(roomLamp); 620 rlNode->rotate(Vector3(0,1,0),Radian(Degree(180))); 621 roomLamp->setCastShadows(false); 622 623 new Scientist("scientist", mSceneMgr); 624 PlayerCharacter::frameListenerPriority = 30; 625 626 gFPSPlayer = new FPSPlayer(NXScene, mSceneMgr, Vector3(0.4, 1.0, 0.35),/*Vector3(-7.5,0.0,-11)*/Vector3(0, 0.0, 11.5), 1.15, mCamera, false); 495 627 /*gFPSPlayer->addPlayerMesh("FPSarm.mesh", 0.02, false); 496 628 gFPSPlayer->addWeaponModel("sword.mesh", "joint28");
Note: See TracChangeset
for help on using the changeset viewer.