|
From: julien r. <jul...@us...> - 2004-10-24 14:54:08
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23304 Modified Files: controller.cc controller.h game.cc game.h pawn.cc pawn.h playercontroller.cc Log Message: pas mal de suppression de bugs concernant les mouvements Index: game.cc =================================================================== RCS file: /cvsroot/epfl/tggame/game.cc,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** game.cc 22 Oct 2004 20:30:22 -0000 1.18 --- game.cc 24 Oct 2004 14:53:58 -0000 1.19 *************** *** 122,127 **** pPhysicEngine->AddNode(pNode); pNode->SetPosition (Vector3(100,50,0)); ! //pNode->SetYRot (45); ! //création d'un ennemi --- 122,126 ---- pPhysicEngine->AddNode(pNode); pNode->SetPosition (Vector3(100,50,0)); ! //pNode->SetYRot (45); //création d'un ennemi *************** *** 133,138 **** p->SetMoveSpeed(CAM_SPEED); p->SetVelocity(Vector3(0,0,0)); ! p->SetPosition(Vector3(0,10,0)); ! p->SetRotVelocity(Vector3(0,20,0)); //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(0,30,0)); //p->GetModel()->SetPhysicCallBack(c); --- 132,137 ---- p->SetMoveSpeed(CAM_SPEED); p->SetVelocity(Vector3(0,0,0)); ! p->SetPosition(Vector3(50,70,0)); ! p->SetRotationVelocity(Vector3(10,10,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.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pawn.h 21 Oct 2004 21:29:15 -0000 1.5 --- pawn.h 24 Oct 2004 14:53:58 -0000 1.6 *************** *** 39,43 **** inline Vector3 GetPosition () { return pPhysic->GetPosition(); } ! inline void SetRotVelocity (const Vector3& v) { pPhysic->SetRotVelocity(v); } inline float GetMoveSpeed () { return fMoveSpeed; } --- 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; } Index: pawn.cc =================================================================== RCS file: /cvsroot/epfl/tggame/pawn.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pawn.cc 21 Oct 2004 21:29:15 -0000 1.4 --- pawn.cc 24 Oct 2004 14:53:58 -0000 1.5 *************** *** 9,13 **** pModel = Engine::pMeshManager->Load("data/models/pinky/pinky.md5mesh"); pPhysic = new PhysicNode(pModel); ! pPhysic->SetClip(false); fMoveSpeed = 0.0f; } --- 9,13 ---- pModel = Engine::pMeshManager->Load("data/models/pinky/pinky.md5mesh"); pPhysic = new PhysicNode(pModel); ! pPhysic->SetClip(true); fMoveSpeed = 0.0f; } Index: controller.h =================================================================== RCS file: /cvsroot/epfl/tggame/controller.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** controller.h 21 Oct 2004 21:29:15 -0000 1.5 --- controller.h 24 Oct 2004 14:53:58 -0000 1.6 *************** *** 28,32 **** Pawn* pPawn; bool bDir[4]; ! bool bLastDir[4]; //pour les mouvements //int iForward; --- 28,33 ---- Pawn* pPawn; bool bDir[4]; ! ! Vector3 vLastVel; //pour les mouvements //int iForward; Index: playercontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.cc,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** playercontroller.cc 21 Oct 2004 21:29:15 -0000 1.6 --- playercontroller.cc 24 Oct 2004 14:53:58 -0000 1.7 *************** *** 12,16 **** --- 12,29 ---- void PlayerController::Think (float eTime) { + float fSensivity = 0.02; + int mX, mY; + int middleX, middleY; + Game::pSelf->GetEngine()->GetMouseState(&mX,&mY); + 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); } Index: game.h =================================================================== RCS file: /cvsroot/epfl/tggame/game.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** game.h 10 Oct 2004 21:18:41 -0000 1.6 --- game.h 24 Oct 2004 14:53:58 -0000 1.7 *************** *** 55,58 **** --- 55,59 ---- inline SceneManager* GetSceneManager () { return pSceneManager; } inline World* GetWorld () { return pWorld; } + inline Engine* GetEngine () { return pEngine; } /** Index: controller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/controller.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** controller.cc 21 Oct 2004 21:29:15 -0000 1.5 --- controller.cc 24 Oct 2004 14:53:58 -0000 1.6 *************** *** 8,12 **** for (int i=0; i<4; i++) { bDir[i] = false; - bLastDir[i] = false; } } --- 8,11 ---- *************** *** 20,57 **** float factor = 1.0f; //on garde la vitesse sur les y, elle est gérée par le moteur physique ! ! /*if (iForward >= 1) ! vVelocity.x += fSpeed; ! else if (iForward <= -1) ! vVelocity.x -= fSpeed; ! if (iStrafe >= 1) ! vVelocity.z += fSpeed; ! else if (iStrafe <= 1) ! vVelocity.z -= fSpeed;*/ ! ! if (bDir[0] && !bLastDir[0]) ! vVelocity.z -= fSpeed; ! else if (!bDir[0] && bLastDir[0]) ! vVelocity.z += fSpeed; ! if (bDir[1] && !bLastDir[1]) ! vVelocity.z += fSpeed; ! else if (!bDir[1] && bLastDir[1]) ! vVelocity.z -= fSpeed; ! if (bDir[2] && !bLastDir[2]) ! vVelocity.x -= fSpeed; ! else if (!bDir[2] && bLastDir[2]) ! vVelocity.x += fSpeed; ! if (bDir[3] && !bLastDir[3]) ! vVelocity.x += fSpeed; ! else if (!bDir[3] && bLastDir[3]) ! vVelocity.x -= fSpeed; ! for (int i=0; i<4; i++) ! bLastDir[i] = bDir[i]; ! ! //pPawn->GetModel()->SetAcceleration(vAccel); pPawn->SetVelocity(pPawn->GetVelocity()+vVelocity); --- 19,46 ---- float factor = 1.0f; //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; ! } ! if (bDir[1]) { ! vLastVel.x = vVelocity.x -= sinf(rot.y*DEGTORAD)*fSpeed; ! vLastVel.z = vVelocity.z += cosf(rot.y*DEGTORAD)*fSpeed; ! } ! if (bDir[2]) { ! vLastVel.x = vVelocity.x -= cosf(rot.y*DEGTORAD)*fSpeed; ! vLastVel.z = vVelocity.z -= sinf(rot.y*DEGTORAD)*fSpeed; ! } ! ! if (bDir[3]) { ! vLastVel.x = vVelocity.x += cosf(rot.y*DEGTORAD)*fSpeed; ! vLastVel.z = vVelocity.z += sinf(rot.y*DEGTORAD)*fSpeed; ! } pPawn->SetVelocity(pPawn->GetVelocity()+vVelocity); |