Changeset 2411 for GTP/trunk/App/Demos/Illum/Ogre/src
- Timestamp:
- 06/05/07 14:27:14 (17 years ago)
- Location:
- GTP/trunk/App/Demos/Illum/Ogre/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/src/Common/include/FPSPlayer.h
r2405 r2411 30 30 bool frameStarted(const FrameEvent& evt); 31 31 virtual void addWeaponModel(String meshname, String attachBoneName); 32 void doAction( );32 void doAction(float dt); 33 33 34 34 static unsigned int frameListenerPriority; … … 85 85 virtual void processMouseInputs(InputReader* inputDevice); 86 86 void addWeaponModel(String meshname, String attachBoneName); 87 Vector3 getPosition(){return mPlayerCharacter->getGlobalPosition();} 87 Vector3 getPosition(){return mPlayerNode->getWorldPosition(); 88 return mPlayerCharacter->getGlobalPosition();} 88 89 // Vector3 getOrienation(){return mPlayerCharacter->getGlobalOrientation();} 89 90 -
GTP/trunk/App/Demos/Illum/Ogre/src/Common/src/FPSPlayer.cpp
r2405 r2411 21 21 { 22 22 public: 23 MyCharMoveController(float speed = 1.5){movespeed = speed; mWeaponBound = 0;}23 MyCharMoveController(float speed = 1.5){movespeed = speed;} 24 24 float movespeed; 25 Actor* mWeaponBound;26 Vector3 mWeaponPosition;27 SceneNode* mWeaponDebugNode;28 25 void move(NxVec3 &out, NxVec3 &moveVector, NxQuat &direction, NxVec3 &g, float t, Character*) 29 26 { 30 27 NxVec3 dir = direction.rot(moveVector); 31 out = ((dir * movespeed) + g) * t; 32 33 if(mWeaponBound) 34 { 35 Vector3 addDir(0,0,0); 36 //if(moveVector.z < 0) 37 addDir = Vector3(dir.x,0,dir.z) * t * movespeed * 1.2; 38 39 Vector3 newPos = mWeaponPosition/* + addDir*/; 40 mWeaponBound->setGlobalPosition(newPos); 41 mWeaponBound->simulate(t); 42 //if(mWeaponDebugNode) 43 //mWeaponDebugNode->setPosition(newPos); 44 //mWeaponBound->moveGlobalPosition(mWeaponPosition); 45 //mWeaponDebugNode->setPosition(mWeaponPosition); 46 } 28 out = ((dir * movespeed) + g) * t; 47 29 } 48 30 }; … … 63 45 mPlayerNode = mPlayerCharacter->getNode(); 64 46 47 mCharacterController = 0; 65 48 mCharacterController = new MyCharMoveController(2.0); 66 49 mPlayerCharacter->setMovementVectorController(mCharacterController); … … 73 56 } 74 57 75 //mCharacterMesh_AnimState = 0;58 mCharacterMesh_AnimState = 0; 76 59 mForceAnimChange = false; 77 60 mWeapon = 0; 78 61 mWeaponBound = 0; 79 62 mWeaponBoundDebugNode = 0; 80 81 // this->setPriority(frameListenerPriority++); 82 // Root::getSingleton().addFrameListener(this); 63 mCharacterMeshEntity = 0; 64 mWeaponEntity = 0; 65 mWeaponAttachBone = 0; 66 mWeaponNode = 0; 67 mWeaponBoundNode = 0; 68 mWeaponBoundDebugNode = 0; 69 mPlayerBoundDebugNode = 0; 70 mWeaponBound = 0; 71 mWeaponNode2 = 0; 72 73 this->setPriority(frameListenerPriority++); 74 Root::getSingleton().addFrameListener(this); 83 75 84 76 //mPlayerCharacter->setCharacterCollisionGroup(NX_CHARACTER_COL_GROUP_CHARACTER); … … 91 83 mCameraHeight = cameraHeight - dimensions.y / 2.0; 92 84 mCamera = cam; 93 mCamera->setPosition(Vector3(0, mCameraHeight, 0));94 85 mPlayerNode->attachObject(cam); 95 86 96 87 thePlayer = this; 97 88 } … … 116 107 if(rotateModel) 117 108 meshNode->rotate(Vector3::UNIT_Y, Degree(180.0)); 109 meshNode->_updateBounds(); 118 110 } 119 111 … … 171 163 mWeaponBound = new MyTrigger(mName + "_WeaponTrigger", mScene, new CubeShape(dimX, dimY, dimZ, "trigger: yes"), Vector3(0,0,0), "mass: 0, density: 0"); 172 164 mScene->addTrigger((Trigger*)mWeaponBound); 173 174 mCharacterController->mWeaponBound = mWeaponBound; 175 165 176 166 if(mDebug) 177 167 { … … 179 169 mWeaponBoundDebugNode->setScale(dim); 180 170 mWeaponBoundDebugNode->attachObject(mSceneManager->createEntity(mName+"_WeaponBoundDebug", "cube.mesh")); 181 mCharacterController->mWeaponDebugNode = mWeaponBoundDebugNode;182 171 } 183 172 … … 224 213 mScene->addTrigger((Trigger*)mWeaponBound); 225 214 226 mCharacterController->mWeaponBound = mWeaponBound;227 228 215 if(mDebug) 229 216 { … … 231 218 mWeaponBoundDebugNode->setScale(dim); 232 219 mWeaponBoundDebugNode->attachObject(mSceneManager->createEntity(mName+"_WeaponBoundDebug", "cube.mesh")); 233 mCharacterController->mWeaponDebugNode = mWeaponBoundDebugNode;234 220 } 235 221 … … 237 223 } 238 224 239 void PlayerCharacter::doAction( )225 void PlayerCharacter::doAction(float dt) 240 226 { 241 227 FPSPlayer* thePlayer = FPSPlayer::getPlayer(); … … 244 230 { 245 231 Vector3 playerPos = thePlayer->getPosition(); 246 Vector3 myPos = mPlayer Character->getGlobalPosition();232 Vector3 myPos = mPlayerNode->getWorldPosition(); 247 233 Vector3 dir = playerPos - myPos; 248 234 dir.y = 0; 249 if( dir.length() > 1.0)250 {235 //if( dir.length() > 1.0) 236 //{ 251 237 dir.normalise(); 252 Vector3 right = dir.crossProduct(Vector3::UNIT_Y); 253 Quaternion q; 254 Matrix3 rot; 255 rot.SetColumn(0, right); 256 rot.SetColumn(1, Vector3::UNIT_Y); 257 rot.SetColumn(2, dir); 258 //rot = rot.Transpose(); 259 260 q.FromRotationMatrix(rot); 238 Vector3 right = -dir.crossProduct(Vector3::UNIT_Y); 239 Quaternion q; 240 q.FromAxes(right,Vector3::UNIT_Y,dir); 261 241 mPlayerCharacter->setDirection(q); 262 ((MyCharMoveController*)mCharacterController)->movespeed = 0.2; 263 // mPlayerCharacter->addMovement(Character::DR_Forward); 264 } 242 if(mCharacterController ) 243 ((MyCharMoveController*)mCharacterController)->movespeed = 1.5; 244 mPlayerCharacter->addMovement(Character::DR_StepRight); 245 //} 265 246 266 247 } … … 272 253 { 273 254 // LogManager::getSingleton().logMessage("CHARACTERPLAYER_FRAMESTARTED"); 274 doAction( );255 doAction(evt.timeSinceLastFrame); 275 256 276 257 float dt = evt.timeSinceLastFrame; … … 325 306 if (inputDevice->isKeyDown(KC_LSHIFT)) 326 307 { 308 if(mCharacterController) 327 309 ((MyCharMoveController*)mCharacterController)->movespeed = 4.0; 328 310 mRunning = true; … … 330 312 else 331 313 { 314 if(mCharacterController) 332 315 ((MyCharMoveController*)mCharacterController)->movespeed = 2.0; 333 316 mRunning = false; … … 389 372 } 390 373 374 if(mCharacterMeshEntity) 391 375 this->mCharacterMeshEntity->_updateAnimation(); 392 376 … … 401 385 Vector3 translation = mWeaponBoundNode->getWorldPosition(); 402 386 Quaternion orientation = mWeaponBoundNode->getWorldOrientation(); 403 404 mCharacterController->mWeaponPosition = translation;405 387 406 388 mWeaponBound->setGlobalOrientation(orientation); 407 //mWeaponBound->moveGlobalPosition(translation);389 mWeaponBound->setGlobalPosition(translation); 408 390 409 391 //mWeaponBound->setGlobalPosition(translation); … … 469 451 void FPSPlayer::setAnimState(PlayerAnimState as) 470 452 { 453 if(!mCharacterMeshEntity) 454 return; 455 471 456 switch(as) 472 457 { -
GTP/trunk/App/Demos/Illum/Ogre/src/Moria/include/Moria.h
r2405 r2411 80 80 { 81 81 gFPSPlayer->processKeyInputs(mInputDevice); 82 82 /* 83 83 static float lastTime = 0; 84 84 static Timer* t = Root::getSingleton().getTimer(); … … 103 103 throwSphere->addForce(mCamera->getDirection()*200); 104 104 105 } 106 107 108 //return ExampleFrameListener::processUnbufferedKeyInput(evt);105 }*/ 106 107 108 // return ExampleFrameListener::processUnbufferedKeyInput(evt); 109 109 110 110 if( mInputDevice->isKeyDown( KC_ESCAPE) ) … … 133 133 { 134 134 gFPSPlayer->processMouseInputs(mInputDevice); 135 // return ExampleFrameListener::processUnbufferedMouseInput(evt); 135 136 return true; 136 137 } … … 214 215 215 216 Root::getSingleton()._setCurrentSceneManager(mSceneMgr); 216 mCamera->setPosition(-20,3,0);217 //mCamera->setPosition(-20,3,0); 217 218 //mCamera->setPosition(0,100,0); 218 219 //mCamera->lookAt(0,-1,0); 219 mCamera->setFOVy(Radian(Degree( 80)));220 mCamera->setNearClipDistance(0.0 1);220 mCamera->setFOVy(Radian(Degree(90))); 221 mCamera->setNearClipDistance(0.001); 221 222 mCamera->setFarClipDistance(150); 222 223 // Set ambient light … … 307 308 mAnimState->setEnabled(true);*/ 308 309 309 //PlayerCharacter::frameListenerPriority = 20;310 PlayerCharacter::frameListenerPriority = 20; 310 311 gFPSPlayer = new FPSPlayer(NXScene, mSceneMgr, Vector3(0.5, 1.8, 0.3), Vector3(5, 10, 15), 1.6, mCamera, false); 311 312 //gFPSPlayer->addPlayerMesh("FPSarm.mesh", 0.02, true); 312 313 //gFPSPlayer->addWeaponModel("sword.mesh", "joint28"); 313 /* 314 314 315 PlayerCharacter* troll = new PlayerCharacter("troll1", NXScene, mSceneMgr, Vector3(1.5, 3.0, 1.2), Vector3(5, 10, 5), false); 315 troll->addPlayerMesh("troll.mesh", 0.05, false);*/ 316 troll->addPlayerMesh("troll.mesh", 0.05, false); 317 316 318 for(float i = 0; i< 7; i++) 317 319 { -
GTP/trunk/App/Demos/Illum/Ogre/src/PRMDemo/include/PRMDemo.h
r2405 r2411 60 60 t += dt; 61 61 62 //blueLight->setDirection(sin(t),sin(t),cos(t)); 63 blueLight->getParentSceneNode()->setPosition(30 * sin(t), 1, 30 * cos(t)); 62 Vector3 pos(30 * sin(t), 1, 30 * cos(t)); 63 blueLight->getParentSceneNode()->setPosition(pos); 64 Vector3 dir = pos; 65 dir.normalise(); 66 blueLight->setDirection(dir); 67 64 68 65 69 return result; … … 278 282 */ 279 283 blueLight = mSceneMgr->createLight("BlueLight"); 280 blueLight->setType(Light::LT_ POINT);284 blueLight->setType(Light::LT_SPOTLIGHT); 281 285 blueLight->setCastShadows(true); 282 286 blueLight->setDiffuseColour(ColourValue(1,1,1,1)); … … 288 292 blueLight->setPowerScale(200); 289 293 // blueLight->setDirection(1, 0, 0); 290 // blueLight->setSpotlightOuterAngle(Radian(Degree(90))); 291 blueLight->setAttenuation(200, 0, 0, 1); 294 blueLight->setSpotlightOuterAngle(Radian(Degree(90))); 295 blueLight->setSpotlightFalloff(1); 296 blueLight->setAttenuation(2000, 0, 0, 1); 292 297 blueLightNode->attachObject(blueLight); 293 298
Note: See TracChangeset
for help on using the changeset viewer.