- Timestamp:
- Jun 22, 2006, 4:28:18 PM (18 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/math/quaternion.cc
r8724 r8731 216 216 217 217 /** 218 * @returns the heading218 * @returns the Heading 219 219 */ 220 220 float Quaternion::getHeading() const … … 230 230 231 231 /** 232 * @returns the Heading-Quaternion 233 */ 234 Quaternion Quaternion::getHeadingQuat() const 235 { 236 return Quaternion(this->getHeading(), Vector(0,1,0)); 237 } 238 239 /** 232 240 * @returns the Attitude 233 241 */ … … 236 244 return asin(2.0 * (v.x*v.y + v.z*w)); 237 245 } 246 247 /** 248 * @returns the Attitude-Quaternion 249 */ 250 Quaternion Quaternion::getAttitudeQuat() const 251 { 252 return Quaternion(this->getAttitude(), Vector(0,0,1)); 253 } 254 238 255 239 256 /** … … 247 264 return 0.0f; 248 265 } 266 267 /** 268 * @returns the Bank-Quaternion 269 */ 270 Quaternion Quaternion::getBankQuat() const 271 { 272 return Quaternion(this->getBank(), Vector(1,0,0)); 273 } 274 249 275 250 276 -
trunk/src/lib/math/quaternion.h
r8724 r8731 98 98 99 99 float getHeading() const; 100 Quaternion getHeadingQuat() const; 100 101 float getAttitude() const; 102 Quaternion getAttitudeQuat() const; 101 103 float getBank() const; 104 Quaternion getBankQuat() const; 102 105 /** @returns the rotational axis of this Quaternion */ 103 106 inline Vector getSpacialAxis() const { return this->v / sin(acos(w));/*sqrt(v.x*v.x + v.y*v.y + v.z+v.z);*/ }; -
trunk/src/world_entities/creatures/fps_player.cc
r8724 r8731 18 18 19 19 #include "interactive_model.h" 20 #include " md2/md2Model.h"20 #include "state.h" 21 21 22 22 #include "src/lib/util/loading/factory.h" … … 28 28 29 29 30 30 31 CREATE_FACTORY(FPSPlayer, CL_FPS_PLAYER); 31 32 33 using namespace std;34 32 35 33 … … 72 70 this->bBackward = false; 73 71 this->bJump = false; 72 74 73 this->xMouse = 0.0f; 75 74 this->yMouse = 0.0f; … … 78 77 this->setHealth(80); 79 78 80 this->mouseDir = this->getAbsDir(); 79 80 this->cameraNode.setParent(this); 81 82 this->attitude = this->getAbsDir().getAttitude(); 83 this->heading = this->getAbsDir().getHeading(); 81 84 82 85 //add events to the eventlist … … 91 94 this->getWeaponManager().setSlotCount(0); 92 95 93 this->getWeaponManager().getFixedTarget()->setParent(this);94 this->getWeaponManager().getFixedTarget()->setRelCoor(100000,0,0);95 96 96 97 dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false); … … 101 102 registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) ); 102 103 registerVar( new SynchronizeableBool( &bBackward, &bBackward, "bBackward", PERMISSION_OWNER ) ); 103 registerVar( new SynchronizeableQuaternion( &mouseDir, &mouseDir, "mouseDir", PERMISSION_OWNER ) );104 // registerVar( new SynchronizeableQuaternion( &mouseDir, &mouseDir, "mouseDir", PERMISSION_OWNER ) ); 104 105 105 106 // collision reaction registration … … 119 120 void FPSPlayer::setPlayDirection(const Quaternion& quat, float speed) 120 121 { 121 this->mouseDir = quat; 122 this->angleY = quat.getHeading(); 123 this->angleX = quat.getAttitude(); 122 this->attitude = this->getAbsDir().getAttitude(); 123 this->heading = this->getAbsDir().getHeading(); 124 124 } 125 125 … … 140 140 void FPSPlayer::enter() 141 141 { 142 dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false ); 143 this->attachCamera(); 142 dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( true ); 143 144 State::getCameraNode()->setParentSoft(&this->cameraNode); 145 State::getCameraTargetNode()->setParentSoft(&this->cameraNode); 146 147 this->getWeaponManager().getFixedTarget()->setParent(State::getCameraTargetNode()); 148 this->getWeaponManager().getFixedTarget()->setRelCoor(0,0,0); 149 150 151 State::getCameraNode()->setRelCoor(0,0,0); 152 State::getCameraTargetNode()->setRelCoor(10,0,0); 144 153 } 145 154 … … 165 174 yMouse *= time ; 166 175 167 angleX -= xMouse; 168 angleY -= yMouse; 169 170 if ( angleY > 2.05 ) 171 angleY = 2.05; 172 173 if ( angleY < -1.15 ) 174 angleY = -1.15; 175 176 this->mouseDir = Quaternion( angleX, Vector( 0, 1, 0 ) ) * Quaternion( angleY, Vector( 0, 0, 1 ) ); 176 heading -= xMouse; 177 attitude-= yMouse; 178 179 if ( attitude > 2.05 ) 180 attitude = 2.05; 181 182 else if ( attitude < -1.15 ) 183 attitude = -1.15; 184 185 this->setAbsDir(Quaternion(heading, Vector(0,1,0))); 186 this->cameraNode.setRelDir(Quaternion( attitude, Vector( 0, 0, 1 ) )); 177 187 178 188 xMouse = yMouse = 0; 179 189 } 180 190 181 this->setAbsDir( this->mouseDir );191 // this->setAbsDir( this->mouseDir ); 182 192 183 193 Vector velocity; -
trunk/src/world_entities/creatures/fps_player.h
r8724 r8731 45 45 float xMouse; //!< mouse moved in x-Direction 46 46 float yMouse; //!< mouse moved in y-Direction 47 Quaternion mouseDir; //!< the direction where the player wants to fly48 47 49 float angleX;50 float angleY;51 48 49 float heading; 50 float attitude; 51 52 PNode cameraNode; 52 53 }; 53 54
Note: See TracChangeset
for help on using the changeset viewer.