|
From: julien r. <jul...@us...> - 2004-10-28 21:20:46
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1491 Modified Files: aicontroller.h config.cfg controller.cc controller.h game.cc pawn.h playercontroller.cc Log Message: quaternions Index: config.cfg =================================================================== RCS file: /cvsroot/epfl/tggame/config.cfg,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** config.cfg 25 Oct 2004 20:04:14 -0000 1.7 --- config.cfg 28 Oct 2004 21:20:33 -0000 1.8 *************** *** 5,7 **** -set lightpos.y 0 -set bump 0 - -clip --- 5,6 ---- Index: game.cc =================================================================== RCS file: /cvsroot/epfl/tggame/game.cc,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** game.cc 25 Oct 2004 20:04:14 -0000 1.20 --- game.cc 28 Oct 2004 21:20:33 -0000 1.21 *************** *** 124,128 **** pPhysicEngine->AddNode(pNode); pNode->SetPosition (Vector3(100,50,0)); - //pNode->SetYRot (45); //création d'un ennemi --- 124,127 ---- *************** *** 135,139 **** p->SetVelocity(Vector3(0,0,0)); p->SetPosition(Vector3(50,70,0)); ! p->SetRotationVelocity(Vector3(10,0,10)); //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(0,30,0)); //p->GetModel()->SetPhysicCallBack(c); --- 134,140 ---- p->SetVelocity(Vector3(0,0,0)); p->SetPosition(Vector3(50,70,0)); ! ! p->SetRotationVelocity(Quaternion(0.5,Vector3(0,1,1))); ! p->SetRotation(Quaternion(90,Vector3(0,1,0))); //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(0,30,0)); //p->GetModel()->SetPhysicCallBack(c); Index: pawn.h =================================================================== RCS file: /cvsroot/epfl/tggame/pawn.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pawn.h 25 Oct 2004 20:04:14 -0000 1.7 --- pawn.h 28 Oct 2004 21:20:33 -0000 1.8 *************** *** 39,47 **** inline Vector3 GetPosition () { return pPhysic->GetPosition(); } ! inline Vector3 GetRotation () { return pPhysic->GetRotation(); } ! inline void SetRotation (const Vector3& v) { pPhysic->SetRotation(v); } ! inline void SetRotationVelocity (const Vector3& q) { pPhysic->SetRotationVelocity(q); } inline float GetMoveSpeed () { return fMoveSpeed; } --- 39,47 ---- inline Vector3 GetPosition () { return pPhysic->GetPosition(); } ! inline Quaternion GetRotation () { return pPhysic->GetRotation(); } ! inline void SetRotation (const Quaternion& q) { pPhysic->SetRotation(q); } ! inline void SetRotationVelocity (const Quaternion& q) { pPhysic->SetRotationVelocity(q); } inline float GetMoveSpeed () { return fMoveSpeed; } Index: controller.h =================================================================== RCS file: /cvsroot/epfl/tggame/controller.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** controller.h 24 Oct 2004 14:53:58 -0000 1.6 --- controller.h 28 Oct 2004 21:20:33 -0000 1.7 *************** *** 17,20 **** --- 17,21 ---- public: Controller (Pawn*); + virtual ~Controller () {} virtual void Think (float) = 0; Index: aicontroller.h =================================================================== RCS file: /cvsroot/epfl/tggame/aicontroller.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** aicontroller.h 14 Oct 2004 13:21:06 -0000 1.2 --- aicontroller.h 28 Oct 2004 21:20:33 -0000 1.3 *************** *** 9,12 **** --- 9,14 ---- public: AIController (Pawn* p) : Controller(p) {} + virtual ~AIController() {} + void Think (float); void Collide (SceneNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal); Index: playercontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.cc,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** playercontroller.cc 25 Oct 2004 20:04:14 -0000 1.8 --- playercontroller.cc 28 Oct 2004 21:20:33 -0000 1.9 *************** *** 13,16 **** --- 13,19 ---- { float fSensivity = 0.02; + static float ry = 0; + static float rx = 0; + int mX, mY; int middleX, middleY; *************** *** 18,29 **** middleX = 320; middleY = 240; ! Vector3 mRot(0,0,0); ! mRot.y += ((float)mX-middleX)*6*fSensivity; ! mRot.x += ((float)mY-middleY)*6*fSensivity; Game::pSelf->GetEngine()->WarpMouse(middleX,middleY); ! pPawn->SetRotation(pPawn->GetRotation()+mRot); } --- 21,42 ---- middleX = 320; middleY = 240; + //si la souris reste au milieu, on a pas besoin de tourner + if ((mX == middleX) && (mY == middleY)) + return; ! //Vector3 mRot(0,0,0); ! //Quaternion roty (((float)mX-middleX)*6*fSensivity, 0,1,0); ! //Quaternion rotx (((float)mY-middleY)*6*fSensivity, 1,0,0); ! ry += ((float)mX-middleX)*6*fSensivity; ! rx += ((float)mY-middleY)*6*fSensivity; Game::pSelf->GetEngine()->WarpMouse(middleX,middleY); ! //pPawn->SetRotation(pPawn->GetRotation()+mRot); ! //pPawn->SetRotation(pPawn->GetRotation()*roty*rotx); ! Quaternion q; ! q.FromEuler(rx, ry, 0); ! q.Normalize(); ! pPawn->SetRotation(q); } Index: controller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/controller.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** controller.cc 24 Oct 2004 14:53:58 -0000 1.6 --- controller.cc 28 Oct 2004 21:20:33 -0000 1.7 *************** *** 20,28 **** //on garde la vitesse sur les y, elle est gérée par le moteur physique pPawn->SetVelocity(pPawn->GetVelocity()-vLastVel); ! Vector3 rot = pPawn->GetRotation(); ! vLastVel.Null(); ! if (bDir[0]) { vLastVel.x = vVelocity.x += sinf(rot.y*DEGTORAD)*fSpeed; vLastVel.z = vVelocity.z -= cosf(rot.y*DEGTORAD)*fSpeed; --- 20,28 ---- //on garde la vitesse sur les y, elle est gérée par le moteur physique pPawn->SetVelocity(pPawn->GetVelocity()-vLastVel); ! //Vector3 rot = pPawn->GetRotation(); ! Quaternion rot = pPawn->GetRotation(); vLastVel.Null(); ! /*if (bDir[0]) { vLastVel.x = vVelocity.x += sinf(rot.y*DEGTORAD)*fSpeed; vLastVel.z = vVelocity.z -= cosf(rot.y*DEGTORAD)*fSpeed; *************** *** 42,46 **** vLastVel.x = vVelocity.x += cosf(rot.y*DEGTORAD)*fSpeed; vLastVel.z = vVelocity.z += sinf(rot.y*DEGTORAD)*fSpeed; ! } pPawn->SetVelocity(pPawn->GetVelocity()+vVelocity); --- 42,60 ---- vLastVel.x = vVelocity.x += cosf(rot.y*DEGTORAD)*fSpeed; vLastVel.z = vVelocity.z += sinf(rot.y*DEGTORAD)*fSpeed; ! }*/ ! Vector3 x, z; ! //x = rot.Rotate(Vector3::UNIT_X); ! //z = rot.Rotate(Vector3::UNIT_Z); ! x = rot.GetXAxis(); ! z = rot.GetZAxis(); ! if (bDir[0]) ! vLastVel = vVelocity += x*fSpeed; ! if (bDir[1]) ! vLastVel = vVelocity -= x*fSpeed; ! if (bDir[2]) ! vLastVel = vVelocity += z*fSpeed; ! if (bDir[3]) ! vLastVel = vVelocity -= z*fSpeed; ! pPawn->SetVelocity(pPawn->GetVelocity()+vVelocity); |