Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5695 Modified Files: aicontroller.cc config.cfg controller.cc controller.h game.cc model.cc model.h pawn.cc pawn.h playercontroller.cc world.h Log Message: Index: config.cfg =================================================================== RCS file: /cvsroot/epfl/tggame/config.cfg,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** config.cfg 13 Oct 2004 23:46:13 -0000 1.5 --- config.cfg 21 Oct 2004 21:29:15 -0000 1.6 *************** *** 5,7 **** -set lightpos.y 0 -set bump 0 - -set sound 1 --- 5,6 ---- Index: world.h =================================================================== RCS file: /cvsroot/epfl/tggame/world.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** world.h 10 Oct 2004 21:18:41 -0000 1.3 --- world.h 21 Oct 2004 21:29:15 -0000 1.4 *************** *** 57,60 **** --- 57,62 ---- */ int GetNumPointLights (); + + Q3Bsp* GetMap() { return pMap; } protected: void _Load(char*); Index: model.h =================================================================== RCS file: /cvsroot/epfl/tggame/model.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** model.h 15 Oct 2004 14:01:01 -0000 1.6 --- model.h 21 Oct 2004 21:29:15 -0000 1.7 *************** *** 1,2 **** --- 1,3 ---- + #if 0 #ifndef _TGMODEL_H #define _TGMODEL_H *************** *** 57,60 **** --- 58,64 ---- inline void SetAcceleration (const Vector3& v) { pMD5->SetAccel(v); } inline Vector3 GetAcceleration () { return pMD5->GetAccel(); } + inline Vector3 GetVelocity () { return pMD5->GetVelocity(); } + inline void SetVelocity (const Vector3& v) { pMD5->SetVelocity(v); } + protected: bool _ParseMDLFile (char*); *************** *** 62,68 **** MD5Instance* pMD5; - MD5Mesh10* pMD5Mesh; }; #endif --- 66,72 ---- MD5Instance* pMD5; }; #endif + #endif Index: model.cc =================================================================== RCS file: /cvsroot/epfl/tggame/model.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** model.cc 15 Oct 2004 14:17:25 -0000 1.4 --- model.cc 21 Oct 2004 21:29:15 -0000 1.5 *************** *** 1,2 **** --- 1,3 ---- + #if 0 #include "model.h" *************** *** 39,45 **** meshname += buffer; ! pMD5Mesh = new MD5Mesh10 (); ! pMD5Mesh->LoadMesh ((char*)meshname.data()); ! pMD5 = new MD5Instance(pMD5Mesh); NEXT("numAnimations") pFD >> numAnims; --- 40,44 ---- meshname += buffer; ! pMD5 = Engine::pMeshManager->Load((char*)meshname.data()); NEXT("numAnimations") pFD >> numAnims; *************** *** 56,60 **** NEXT("anim") pFD >> buffer; ! pMD5Mesh->LoadAnim ((char*)(animname+buffer).data()); } if (numAnims > 0) --- 55,59 ---- NEXT("anim") pFD >> buffer; ! //pMD5Mesh->LoadAnim ((char*)(animname+buffer).data()); } if (numAnims > 0) *************** *** 72,74 **** --- 71,74 ---- p->AddNode (pMD5); } + #endif Index: game.cc =================================================================== RCS file: /cvsroot/epfl/tggame/game.cc,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** game.cc 16 Oct 2004 14:36:57 -0000 1.15 --- game.cc 21 Oct 2004 21:29:15 -0000 1.16 *************** *** 77,85 **** { if (scene) ! p->GetModel()->Add(pSceneManager); if (physic && scene) ! p->GetModel()->Add(pPhysicEngine); ! if (p->GetCamera() && physic) ! pPhysicEngine->AddNode(p->GetCamera()); } --- 77,83 ---- { if (scene) ! p->Add(pSceneManager); if (physic && scene) ! p->Add(pPhysicEngine); } *************** *** 89,111 **** //on ajoute _pas_ le pawn au scenemanager #ifndef TGWIN32 ! #define CAM_SPEED 15000 #else ! #define CAM_SPEED 150000 #endif Camera* cam = new Camera (0.025f,CAM_SPEED, Vector3 (0, 100,0)); //TODO: on devrait plutot se base sur la bounding box du model ! cam->pBBox->vMin = Vector3(-10, -70, -10); ! cam->pBBox->vMax = Vector3(10, 10, 10); ! Pawn* p = new Pawn(cam); pSceneManager->SetCamera(cam); vPawns.push_back(p); ! this->AddPawn(p, true, false); pLocalController = new PlayerController(p); vControllers.push_back(pLocalController); ! p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(20,70,20)); ! p->GetCamera()->SetPhysicCallBack(pLocalController); ! //création d'un ennemi p = new Pawn(); --- 87,122 ---- //on ajoute _pas_ le pawn au scenemanager #ifndef TGWIN32 ! #define CAM_SPEED 450 #else ! #define CAM_SPEED 4500 #endif Camera* cam = new Camera (0.025f,CAM_SPEED, Vector3 (0, 100,0)); //TODO: on devrait plutot se base sur la bounding box du model ! //cam->pBBox->vMin = Vector3(-10, -70, -10); ! //cam->pBBox->vMax = Vector3(10, 10, 10); ! Pawn* p = new Pawn(); pSceneManager->SetCamera(cam); vPawns.push_back(p); ! this->AddPawn(p); pLocalController = new PlayerController(p); vControllers.push_back(pLocalController); ! p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(20,80,20)); ! p->Attach (cam); ! p->SetPosition (Vector3(100,80,100)); ! p->GetBBox()->vMin = Vector3(-10, -70, -10); ! p->GetBBox()->vMax = Vector3(10,10,10); ! p->SetMoveSpeed (CAM_SPEED); ! //p->GetCamera()->SetPhysicCallBack(pLocalController); + MD5Instance* pMD5 = Engine::pMeshManager->Load("data/models/cube/cube.md5mesh"); + pSceneManager->AddWorldObject (pMD5); + pMD5->SetPosition(Vector3(0,50,0)); + PhysicNode* pNode = new PhysicNode(pMD5); + pPhysicEngine->AddNode(pNode); + pNode->SetPosition (Vector3(100,50,0)); + //pNode->SetYRot (45); + + //création d'un ennemi p = new Pawn(); *************** *** 114,120 **** Controller* c = new AIController(p); vControllers.push_back(c); ! p->SetMoveSpeed(15000); ! p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(0,30,0)); ! p->GetModel()->SetPhysicCallBack(c); } --- 125,134 ---- Controller* c = new AIController(p); vControllers.push_back(c); ! 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); } *************** *** 184,186 **** } - --- 198,199 ---- Index: controller.h =================================================================== RCS file: /cvsroot/epfl/tggame/controller.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** controller.h 10 Oct 2004 21:18:41 -0000 1.4 --- controller.h 21 Oct 2004 21:29:15 -0000 1.5 *************** *** 27,37 **** protected: Pawn* pPawn; //pour les mouvements ! int iForward; ! int iStrafe; ! //pour l'orientation de la vue ! float fYaw; ! float fPitch; ! float fRoll; }; --- 27,35 ---- protected: Pawn* pPawn; + bool bDir[4]; + bool bLastDir[4]; //pour les mouvements ! //int iForward; ! //int iStrafe; }; Index: aicontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/aicontroller.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** aicontroller.cc 15 Oct 2004 14:00:53 -0000 1.3 --- aicontroller.cc 21 Oct 2004 21:29:14 -0000 1.4 *************** *** 39,43 **** std::cout << "\n\n---[AI]--- C'est parti pour l'IA" << std::endl; initialised=true; - iForward=1; // srand( (unsigned)time( NULL ) ); } --- 39,42 ---- Index: pawn.h =================================================================== RCS file: /cvsroot/epfl/tggame/pawn.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pawn.h 10 Oct 2004 20:54:47 -0000 1.4 --- pawn.h 21 Oct 2004 21:29:15 -0000 1.5 *************** *** 4,9 **** #include <vector3.h> #include <camera.h> ! #include "model.h" #include "actor.h" --- 4,13 ---- #include <vector3.h> #include <camera.h> + #include <md5instance.h> + #include <physicnode.h> + #include <physicengine.h> + #include <scenemanager.h> ! //#include "model.h" #include "actor.h" *************** *** 20,24 **** * @param Camera* un pointeur sur l'éventuelle caméra attachée à ce pawn */ ! Pawn (Camera* c=NULL); /** * Think : méthode appelée à toute les frames (avant le rendu) --- 24,28 ---- * @param Camera* un pointeur sur l'éventuelle caméra attachée à ce pawn */ ! Pawn (); /** * Think : méthode appelée à toute les frames (avant le rendu) *************** *** 26,50 **** */ void Think (float eTime) {} - - inline void SetPosition (const Vector3& v) { pModel->SetPosition(v); if (pCamera) pCamera->SetPosition(v);} ! inline Vector3 GetPosition () ! { ! if (pModel) return pModel->GetPosition(); ! else if (pCamera) return pCamera->GetPosition(); ! return Vector3::ZERO; ! } ! inline Camera* GetCamera () { return pCamera; } inline float GetMoveSpeed () { return fMoveSpeed; } inline void SetMoveSpeed (float s) { fMoveSpeed = s; } ! Model* GetModel () { return pModel; } protected: float fMoveSpeed; ! Model* pModel; ! Camera* pCamera; }; --- 30,61 ---- */ void Think (float eTime) {} ! inline BoundingBox* GetBBox () { return pPhysic->GetBBox(); } ! inline void SetPosition (const Vector3& v) { pPhysic->SetPosition(v); } ! inline void SetVelocity (const Vector3& v) { pPhysic->SetVelocity(v); } ! inline Vector3 GetVelocity () { return pPhysic->GetVelocity(); } ! ! inline Vector3 GetPosition () { return pPhysic->GetPosition(); } + inline void SetRotVelocity (const Vector3& v) { pPhysic->SetRotVelocity(v); } + inline float GetMoveSpeed () { return fMoveSpeed; } inline void SetMoveSpeed (float s) { fMoveSpeed = s; } + + inline void Attach (SceneNode* s) { pPhysic->AttachNode(s); } + + void Add(PhysicEngine* p) {p->AddNode(pPhysic); } + void Add(SceneManager* s) {s->AddWorldObject(pModel); } ! //Model* GetModel () { return pModel; } protected: float fMoveSpeed; ! //Model* pModel; ! MD5Instance* pModel; ! PhysicNode* pPhysic; ! ! //Camera* pCamera; }; Index: playercontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** playercontroller.cc 13 Oct 2004 18:59:55 -0000 1.5 --- playercontroller.cc 21 Oct 2004 21:29:15 -0000 1.6 *************** *** 1,4 **** --- 1,5 ---- #include "playercontroller.h" #include <soundmanager.h> + #include "game.h" using namespace tg; *************** *** 26,42 **** { case TGKEY_w: ! iForward += 1; SoundManager::pSoundManager->PlaySound("step"); break; case TGKEY_s: ! iForward -= 1; SoundManager::pSoundManager->PlaySound("step"); break; case TGKEY_a: ! iStrafe -= 1; SoundManager::pSoundManager->PlaySound("step"); break; case TGKEY_d: ! iStrafe += 1; SoundManager::pSoundManager->PlaySound("step"); break; --- 27,47 ---- { case TGKEY_w: ! //iForward += 1; ! bDir[0] = true; SoundManager::pSoundManager->PlaySound("step"); break; case TGKEY_s: ! //iForward -= 1; ! bDir[1] = true; SoundManager::pSoundManager->PlaySound("step"); break; case TGKEY_a: ! //iStrafe -= 1; ! bDir[2] = true; SoundManager::pSoundManager->PlaySound("step"); break; case TGKEY_d: ! //iStrafe += 1; ! bDir[3] = true; SoundManager::pSoundManager->PlaySound("step"); break; *************** *** 44,47 **** --- 49,55 ---- SoundManager::pSoundManager->PlaySound("gun"); break; + + case TGKEY_RIGHT: + pPawn->SetPosition(Game::pSelf->GetWorld()->GetRandomStartPosition()+Vector3(20,80,20)); default: break; *************** *** 53,63 **** { case TGKEY_w: case TGKEY_s: ! iForward = 0; SoundManager::pSoundManager->StopSound("step"); break; case TGKEY_a: case TGKEY_d: ! iStrafe = 0; SoundManager::pSoundManager->StopSound("step"); break; --- 61,80 ---- { case TGKEY_w: + bDir[0] = false; + SoundManager::pSoundManager->StopSound("step"); + break; case TGKEY_s: ! //iForward = 0; ! bDir[1] = false; SoundManager::pSoundManager->StopSound("step"); break; + case TGKEY_a: + bDir[2] = false; + SoundManager::pSoundManager->StopSound("step"); + break; case TGKEY_d: ! //iStrafe = 0; ! bDir[3] = false; SoundManager::pSoundManager->StopSound("step"); break; *************** *** 68,70 **** } - --- 85,86 ---- Index: controller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/controller.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** controller.cc 11 Oct 2004 12:25:39 -0000 1.4 --- controller.cc 21 Oct 2004 21:29:15 -0000 1.5 *************** *** 5,55 **** { pPawn = p; ! iForward = iStrafe = 0; ! fYaw = fPitch = fRoll = 0; } void Controller::MovePawn () { ! Camera* c; ! //si une caméra est attachée au pawn, on prend les données de la caméra (qui est controlée par la souris) ! if ((c=pPawn->GetCamera())) ! { ! fYaw = c->fYaw; ! fPitch = c->fPitch; ! fRoll = c->fRoll; ! ! c->iForward = iForward; ! c->iStrafe = iStrafe; ! } ! Vector3 vAccel = pPawn->GetModel()->GetAcceleration(); ! vAccel.x = 0; ! vAccel.z = 0; float fSpeed = pPawn->GetMoveSpeed (); float factor = 1.0f; ! //on garde l'accélération sur les y, elle est gérée par le moteur physique ! ! if (iForward >= 1) ! { ! vAccel.x += sinf(fYaw*DEGTORAD)*fSpeed*factor; ! vAccel.z -= cosf(fYaw*DEGTORAD)*fSpeed*factor; ! } else if (iForward <= -1) ! { ! vAccel.x -= sinf(fYaw*DEGTORAD)*fSpeed*factor; ! vAccel.z += cosf(fYaw*DEGTORAD)*fSpeed*factor; ! } if (iStrafe >= 1) ! { ! vAccel.x += cosf(fYaw*DEGTORAD)*fSpeed*factor; ! vAccel.z += sinf(fYaw*DEGTORAD)*fSpeed*factor; ! } ! else if (iStrafe <= -1) ! { ! vAccel.x -= cosf(fYaw*DEGTORAD)*fSpeed*factor; ! vAccel.z -= sinf(fYaw*DEGTORAD)*fSpeed*factor; ! } ! pPawn->GetModel()->SetAcceleration(vAccel); } --- 5,59 ---- { pPawn = p; ! //iForward = iStrafe = 0; ! for (int i=0; i<4; i++) { ! bDir[i] = false; ! bLastDir[i] = false; ! } } void Controller::MovePawn () { ! Vector3 vVelocity(0,0,0); ! //vVelocity.x = 0; ! //vVelocity.z = 0; float fSpeed = pPawn->GetMoveSpeed (); 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); } + Index: pawn.cc =================================================================== RCS file: /cvsroot/epfl/tggame/pawn.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pawn.cc 10 Oct 2004 20:54:47 -0000 1.3 --- pawn.cc 21 Oct 2004 21:29:15 -0000 1.4 *************** *** 3,10 **** using namespace tg; ! Pawn::Pawn(Camera* c) : Actor () { ! pModel = new Model ("data/models/pinky/pinky.mdl", MDL_PLAYER); ! pCamera = c; fMoveSpeed = 0.0f; } --- 3,13 ---- using namespace tg; ! Pawn::Pawn() : Actor () { ! //pModel = new Model ("data/models/pinky/pinky.mdl", MDL_PLAYER); ! //pCamera = c; ! pModel = Engine::pMeshManager->Load("data/models/pinky/pinky.md5mesh"); ! pPhysic = new PhysicNode(pModel); ! pPhysic->SetClip(false); fMoveSpeed = 0.0f; } |