Changeset 130
- Timestamp:
- Oct 31, 2007, 12:28:24 AM (17 years ago)
- Location:
- code/branches/main_reto
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/main_reto/include/OrxonoxShip.h
r128 r130 9 9 { 10 10 public: 11 Vector3 speed; 12 float thrust, sideThrust, baseThrust; 13 11 14 OrxonoxShip(SceneManager*, SceneNode*); 12 15 virtual ~OrxonoxShip(); … … 20 23 void setRoll(const Radian); 21 24 25 Real getThrust(); 26 22 27 bool tick(unsigned long, float); 23 28 … … 27 32 Entity *mShip; 28 33 29 Vector3 speed;30 float thrust, sideThrust, baseThrust;31 34 }; 32 35 -
code/branches/main_reto/include/RunManager.h
r127 r130 41 41 OrxonoxShip *mShip; 42 42 43 Vector3 mTranslateVector;44 43 bool mStatsOn; 45 44 … … 47 46 48 47 unsigned int mNumScreenShots; 49 float mMoveScale;50 Degree mRotScale;51 48 // just to stop toggles flipping too fast 52 49 Real mTimeUntilNextToggle ; 53 Radian mRotX, mRotY;54 50 TextureFilterOptions mFiltering; 55 51 int mAniso; 56 52 57 53 int mSceneDetailIndex ; 58 Real mMoveSpeed;59 Degree mRotateSpeed;60 54 Overlay* mDebugOverlay; 61 55 … … 93 87 virtual void updateStats(void); 94 88 95 virtual void moveCamera();96 97 89 virtual void showDebugOverlay(bool); 98 90 -
code/branches/main_reto/src/OrxonoxShip.cpp
r128 r130 3 3 4 4 OrxonoxShip::OrxonoxShip(SceneManager *mSceneMgr, SceneNode *mNode) 5 : mSceneMgr(mSceneMgr), mRootNode(mNode), speed(Vector3(0, 0, 0)), baseThrust(100) 5 : mSceneMgr(mSceneMgr), mRootNode(mNode), speed(Vector3(0, 0, 0)), baseThrust(100), thrust(0), sideThrust(0) 6 6 { 7 7 } … … 36 36 void OrxonoxShip::setSideThrust(const Real value) 37 37 { 38 sideThrust = value ;38 sideThrust = value * baseThrust; 39 39 } 40 40 … … 54 54 } 55 55 56 Real OrxonoxShip::getThrust() 57 { 58 return thrust; 59 } 60 56 61 57 62 bool OrxonoxShip::tick(unsigned long time, float deltaTime) 58 63 { 59 speed += (mRootNode->getLocalAxes() * Vector3(0, 0, 1)).normalisedCopy() * thrust * deltaTime; 64 speed += (mRootNode->getLocalAxes() * Vector3(0, 0, -1)).normalisedCopy() * thrust * deltaTime; 65 speed += (mRootNode->getLocalAxes() * Vector3(1, 0, 0)).normalisedCopy() * sideThrust * deltaTime; 60 66 61 67 mRootNode->translate(speed * deltaTime); -
code/branches/main_reto/src/RunManager.cpp
r128 r130 6 6 bool bufferedJoy ) : 7 7 mOgre(mOgre), mWindow(mOgre->getRenderWindow()), 8 m TranslateVector(Vector3::ZERO), mStatsOn(true), mNumScreenShots(0),9 m MoveScale(0.0f), mRotScale(0.0f), mTimeUntilNextToggle(0), mFiltering(TFO_BILINEAR),10 mAniso(1), mSceneDetailIndex(0), m MoveSpeed(300), mRotateSpeed(36), mDebugOverlay(0),8 mStatsOn(true), mNumScreenShots(0), 9 mTimeUntilNextToggle(0), mFiltering(TFO_BILINEAR), 10 mAniso(1), mSceneDetailIndex(0), mDebugOverlay(0), 11 11 mInputManager(0), mMouse(0), mKeyboard(0), mJoy(0) 12 12 { … … 90 90 91 91 mScene->tick(time, deltaTime); 92 mShip->tick(time, deltaTime); 92 93 93 94 using namespace OIS; … … 108 109 if (mTimeUntilNextToggle >= 0) 109 110 mTimeUntilNextToggle -= deltaTime; 110 111 // If this is the first frame, pick a speed112 if (deltaTime == 0)113 {114 mMoveScale = 1;115 mRotScale = 0.1;116 }117 // Otherwise scale movement units by time passed since last frame118 else119 {120 // Move about 100 units per second,121 mMoveScale = mMoveSpeed * deltaTime;122 // Take about 10 seconds for full rotation123 mRotScale = mRotateSpeed * deltaTime;124 }125 mRotX = 0;126 mRotY = 0;127 mTranslateVector = Ogre::Vector3::ZERO;128 111 } 129 112 … … 136 119 return false; 137 120 138 if( !mMouse->buffered() || !mKeyboard->buffered() || !buffJ )139 moveCamera();140 141 121 return true; 142 122 } … … 179 159 using namespace OIS; 180 160 181 if(mKeyboard->isKeyDown(KC_A)) 182 mTranslateVector.x = -mMoveScale; // Move camera left 183 184 if(mKeyboard->isKeyDown(KC_D)) 185 mTranslateVector.x = mMoveScale; // Move camera RIGHT 161 if(mKeyboard->isKeyDown(KC_A) || mKeyboard->isKeyDown(KC_LEFT)) 162 mShip->setSideThrust(1); 163 else if(mKeyboard->isKeyDown(KC_D) || mKeyboard->isKeyDown(KC_RIGHT)) 164 mShip->setSideThrust(-1); 165 else 166 mShip->setSideThrust(0); 186 167 187 168 if(mKeyboard->isKeyDown(KC_UP) || mKeyboard->isKeyDown(KC_W) ) 188 mTranslateVector.z = -mMoveScale; // Move camera forward 189 190 if(mKeyboard->isKeyDown(KC_DOWN) || mKeyboard->isKeyDown(KC_S) ) 191 mTranslateVector.z = mMoveScale; // Move camera backward 192 193 if(mKeyboard->isKeyDown(KC_PGUP)) 194 mTranslateVector.y = mMoveScale; // Move camera up 195 196 if(mKeyboard->isKeyDown(KC_PGDOWN)) 197 mTranslateVector.y = -mMoveScale; // Move camera down 198 199 if(mKeyboard->isKeyDown(KC_RIGHT)) 200 mCamera->yaw(-mRotScale); 201 202 if(mKeyboard->isKeyDown(KC_LEFT)) 203 mCamera->yaw(mRotScale); 169 mShip->setThrust(1); 170 else if(mKeyboard->isKeyDown(KC_DOWN) || mKeyboard->isKeyDown(KC_S) ) 171 mShip->setThrust(-1); 172 else 173 mShip->setThrust(0); 204 174 205 175 if( mKeyboard->isKeyDown(KC_ESCAPE) || mKeyboard->isKeyDown(KC_Q) ) … … 269 239 // Print camera details 270 240 if(displayCameraDetails) 271 mDebugText = "P: " + StringConverter::toString(mCamera->getDerivedPosition()) + 272 " " + "O: " + StringConverter::toString(mCamera->getDerivedOrientation()); 241 mDebugText = StringConverter::toString(mShip->getThrust()) 242 + " | Speed = " + StringConverter::toString(mShip->speed); 243 // mDebugText = "P: " + StringConverter::toString(mCamera->getDerivedPosition()) + 244 // " " + "O: " + StringConverter::toString(mCamera->getDerivedOrientation()); 273 245 274 246 // Return true to continue rendering … … 284 256 // 2nd mouse button - slide, otherwise rotate 285 257 const MouseState &ms = mMouse->getMouseState(); 286 mRotX = Degree(-ms.X.rel * 0.13); 287 mRotY = Degree(-ms.Y.rel * 0.13); 288 289 mShip->setYaw(mRotX); 290 mShip->setPitch(mRotY); 258 259 mShip->setYaw(Degree(-ms.X.rel * 0.13)); 260 mShip->setPitch(Degree(-ms.Y.rel * 0.13)); 291 261 292 262 return true; 293 }294 295 296 void RunManager::moveCamera()297 {298 // Make all the changes to the camera299 // Note that YAW direction is around a fixed axis (freelook style) rather than a natural YAW300 //(e.g. airplane)301 //mCamera->yaw(mRotX);302 //mCamera->pitch(mRotY);303 //mCamera->moveRelative(mTranslateVector);304 305 mShipNode->translate(mShipNode->getLocalAxes() * mTranslateVector);306 263 } 307 264
Note: See TracChangeset
for help on using the changeset viewer.