|
From: julien r. <jul...@us...> - 2004-11-17 22:56:41
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17590 Modified Files: aicontroller.cc aicontroller.h config.cfg controller.cc controller.h game.cc game.h pawn.cc pawn.h playercontroller.cc playercontroller.h weapon.cc weapon.h Added Files: projectile.cc projectile.h rocket.cc rocket.h rocketlauncher.cc rocketlauncher.h Log Message: cf changelog tgengine Index: config.cfg =================================================================== RCS file: /cvsroot/epfl/tggame/config.cfg,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** config.cfg 12 Nov 2004 12:13:17 -0000 1.9 --- config.cfg 17 Nov 2004 22:56:27 -0000 1.10 *************** *** 5,7 **** -set lightpos.y 0 -set bump 0 ! -set gravity 1000 --- 5,7 ---- -set lightpos.y 0 -set bump 0 ! -set gravity 700 --- NEW FILE: projectile.cc --- #include "projectile.h" Projectile::Projectile() : Actor () { } Projectile::~ Projectile() { } Index: game.cc =================================================================== RCS file: /cvsroot/epfl/tggame/game.cc,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** game.cc 15 Nov 2004 21:41:52 -0000 1.32 --- game.cc 17 Nov 2004 22:56:27 -0000 1.33 *************** *** 89,92 **** --- 89,98 ---- } + void Game::RemovePawn (Pawn* p) + { + p->Remove(pSceneManager); + p->Remove(pPhysicEngine); + } + void Game::_CreatePlayers () { *************** *** 159,163 **** CollisionResult Game::Trace(const Vector3& vBegin, const Vector3& vEnd, Pawn* edict) { ! return pPhysicEngine->Trace(vBegin, vEnd, edict->GetPhysic()); } --- 165,169 ---- CollisionResult Game::Trace(const Vector3& vBegin, const Vector3& vEnd, Pawn* edict) { ! return pPhysicEngine->Trace(vBegin, vEnd, Vector3(0,0,0), Vector3(0,0,0), edict->GetPhysic()); } --- NEW FILE: rocketlauncher.cc --- #include "rocketlauncher.h" #include "game.h" RocketLauncher::RocketLauncher() : Weapon () { fFireRate = 0.1f; fCoolDown = fFireRate; } RocketLauncher::~RocketLauncher () { } void RocketLauncher::Fire (const Vector3& vPosition, const Vector3& vTarget, Pawn* p) { if (fCoolDown > 0.0f) return; fCoolDown = fFireRate; Vector3 target = vPosition - vTarget*10000; CollisionResult cR = Game::pSelf->Trace(vPosition, target, p); if (cR.pNode == NULL) //on a touche la map Game::pSelf->GetSceneManager()->GetDecalManager()->AddDecal(cR.EndPoint, cR.Normal, 1.0f, 1.0f, Engine::pTextureManager->LoadTexture("data/textures/decals/mgun.bmp", TG_TEXTURE_2D), 10.0f); if (cR.pNode != NULL && cR.pNode->GetPhysicCallBack() != NULL) //on a touche un objet cR.pNode->GetPhysicCallBack()->Collide(NULL, cR.EndPoint, cR.Normal); SoundManager::pSoundManager->PlaySound("gun"); } --- NEW FILE: rocket.h --- #ifndef _TGROCKET_H #define _TGROCKET_H #include "projectile.h" class Rocket : public Projectile { public: Rocket (); protected: }; #endif Index: game.h =================================================================== RCS file: /cvsroot/epfl/tggame/game.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** game.h 13 Nov 2004 23:38:08 -0000 1.11 --- game.h 17 Nov 2004 22:56:27 -0000 1.12 *************** *** 32,35 **** --- 32,37 ---- void AddPawn (Pawn*, bool, bool); + void RemovePawn (Pawn*); + /** * StaticEventHandler : appelera le 'vrai' event handler, utilisé pour ne pas s'embeter avec des pointeurs d'instance Index: controller.h =================================================================== RCS file: /cvsroot/epfl/tggame/controller.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** controller.h 12 Nov 2004 12:13:17 -0000 1.9 --- controller.h 17 Nov 2004 22:56:27 -0000 1.10 *************** *** 23,27 **** virtual void MovePawn(); ! virtual void Collide(SceneNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal) = 0; inline Pawn* GetPawn () { return pPawn; } --- 23,27 ---- virtual void MovePawn(); ! virtual void Collide(PhysicNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal) = 0; inline Pawn* GetPawn () { return pPawn; } *************** *** 32,35 **** --- 32,38 ---- bool bDir[4]; + int iLife; + bool bAlive; + Vector3 vViewOffset; Vector3 vLastVel; --- NEW FILE: projectile.h --- #ifndef _TGPROJECTILE_H #define _TGPROJECTILE_H #include "game.h" #include "actor.h" #include <md5instance.h> #include <physicnode.h> using namespace tg; class Projectile : public Actor { public: Projectile (); virtual ~Projectile (); protected: MD5Instance* pModel; PhysicNode* pPhysic; }; #endif Index: controller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/controller.cc,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** controller.cc 12 Nov 2004 12:13:17 -0000 1.10 --- controller.cc 17 Nov 2004 22:56:27 -0000 1.11 *************** *** 5,8 **** --- 5,10 ---- { pPawn = p; + iLife = 100; + bAlive = true; p->GetPhysic()->SetPhysicCallBack(this); vViewOffset.Null(); --- NEW FILE: rocket.cc --- #include "rocket.h" Rocket::Rocket () : Projectile () { pModel = Engine::pMeshManager->LoadInstance("rocket"); pPhysic = new PhysicNode(pModel); pModel->GetBBox()->vMin.Set(-5,-5,-5); pModel->GetBBox()->vMax.Set(5,5,5); } --- NEW FILE: rocketlauncher.h --- #ifndef _TGROCKETLAUNCHER_H #define _TGROCKETLAUNCHER_H #include "weapon.h" class RocketLauncher : public Weapon { public: RocketLauncher (); ~RocketLauncher (); void Fire (const Vector3& vPosition, const Vector3& vTarget, Pawn* p); protected: }; #endif Index: pawn.cc =================================================================== RCS file: /cvsroot/epfl/tggame/pawn.cc,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** pawn.cc 12 Nov 2004 12:13:17 -0000 1.11 --- pawn.cc 17 Nov 2004 22:56:27 -0000 1.12 *************** *** 8,14 **** pModel->SetAnimation("stand"); pPhysic = new PhysicNode(pModel); ! pModel->GetBBox()->vMin.Set(-10,0,-10); ! pModel->GetBBox()->vMax.Set(10,80,10); //pPhysic->SetClip(false); fMoveSpeed = 0.0f; } --- 8,21 ---- pModel->SetAnimation("stand"); pPhysic = new PhysicNode(pModel); ! pModel->GetBBox()->vMin.Set(-15,0,-15); ! pModel->GetBBox()->vMax.Set(15,80,15); //pPhysic->SetClip(false); fMoveSpeed = 0.0f; } + + Pawn::~Pawn () + { + delete pModel; + delete pPhysic; + } + Index: pawn.h =================================================================== RCS file: /cvsroot/epfl/tggame/pawn.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** pawn.h 12 Nov 2004 12:13:17 -0000 1.11 --- pawn.h 17 Nov 2004 22:56:27 -0000 1.12 *************** *** 24,27 **** --- 24,28 ---- */ Pawn (); + virtual ~Pawn (); /** * Think : méthode appelée à toute les frames (avant le rendu) *************** *** 53,56 **** --- 54,60 ---- void Add(SceneManager* s) {s->AddWorldObject(pModel); } + void Remove(PhysicEngine* p) {p->RemoveNode(pPhysic); } + void Remove(SceneManager* s) {s->RemoveWorldObject(pModel); } + inline void SetClip(bool b) { pPhysic->SetClip(b); } inline bool GetClip () { return pPhysic->Clip(); } *************** *** 59,62 **** --- 63,68 ---- inline PhysicNode* GetPhysic() { return pPhysic; } + + inline void SetBB (Vector3 vMin, Vector3 vMax) { pModel->GetBBox()->vMin = vMin; pModel->GetBBox()->vMax = vMax; } //Model* GetModel () { return pModel; } Index: playercontroller.h =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** playercontroller.h 15 Nov 2004 21:41:52 -0000 1.9 --- playercontroller.h 17 Nov 2004 22:56:27 -0000 1.10 *************** *** 5,9 **** #include "controller.h" ! #include "weapon.h" using namespace tg; --- 5,9 ---- #include "controller.h" ! #include "rocketlauncher.h" using namespace tg; *************** *** 20,23 **** --- 20,24 ---- static int STRAFERIGHT; + RocketLauncher* pRocketLauncher; Weapon* pWeapon; bool bFire; *************** *** 27,31 **** void Think (float); void EventHandler (tgEvent& e); ! void Collide(SceneNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal); void Exec (const std::string& s, int arg) { --- 28,32 ---- void Think (float); void EventHandler (tgEvent& e); ! void Collide(PhysicNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal); void Exec (const std::string& s, int arg) { Index: playercontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.cc,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** playercontroller.cc 15 Nov 2004 21:41:52 -0000 1.18 --- playercontroller.cc 17 Nov 2004 22:56:27 -0000 1.19 *************** *** 15,19 **** pSphere = new DebugSphere (); Game::pSelf->GetSceneManager()->AddDebugSphere(pSphere); ! pWeapon = new Weapon (); bFire = false; } --- 15,20 ---- pSphere = new DebugSphere (); Game::pSelf->GetSceneManager()->AddDebugSphere(pSphere); ! pRocketLauncher = new RocketLauncher(); ! pWeapon = pRocketLauncher; bFire = false; } *************** *** 23,33 **** pWeapon->Think(eTime); //Test des tirs if (bFire) { ! Vector3 vTarget = pPawn->GetRotation().GetZAxis(); ! Vector3 vPosition = pPawn->GetPosition()+vViewOffset; pWeapon->Fire (vPosition, vTarget, pPawn); ! ! vTarget = vPosition - vTarget*1000000; CollisionResult cR = Game::pSelf->Trace(vPosition, vTarget, pPawn); --- 24,37 ---- pWeapon->Think(eTime); //Test des tirs + Vector3 vTarget; + Vector3 vPosition; if (bFire) { ! vTarget = pPawn->GetRotation().GetZAxis(); ! vPosition = pPawn->GetPosition()+vViewOffset; pWeapon->Fire (vPosition, vTarget, pPawn); ! } ! vPosition = pPawn->GetPosition()+vViewOffset; ! vTarget = vPosition - pPawn->GetRotation().GetZAxis()*1000000; CollisionResult cR = Game::pSelf->Trace(vPosition, vTarget, pPawn); *************** *** 39,44 **** if (cR.pNode != NULL && cR.pNode->GetPhysicCallBack() != NULL) cR.pNode->GetPhysicCallBack()->Collide(NULL, cR.EndPoint, cR.Normal);*/ ! } ! //Mouvement de la souris { --- 43,47 ---- if (cR.pNode != NULL && cR.pNode->GetPhysicCallBack() != NULL) cR.pNode->GetPhysicCallBack()->Collide(NULL, cR.EndPoint, cR.Normal);*/ ! //Mouvement de la souris { *************** *** 77,81 **** } ! void PlayerController::Collide (SceneNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal) { //std::cerr << "playercontroller" << std::endl; --- 80,84 ---- } ! void PlayerController::Collide (PhysicNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal) { //std::cerr << "playercontroller" << std::endl; Index: aicontroller.h =================================================================== RCS file: /cvsroot/epfl/tggame/aicontroller.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** aicontroller.h 12 Nov 2004 12:13:17 -0000 1.6 --- aicontroller.h 17 Nov 2004 22:56:27 -0000 1.7 *************** *** 18,22 **** void Think (float); ! void Collide (SceneNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal); void Initialize (); }; --- 18,22 ---- void Think (float); ! void Collide (PhysicNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal); void Initialize (); }; Index: weapon.cc =================================================================== RCS file: /cvsroot/epfl/tggame/weapon.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** weapon.cc 14 Nov 2004 13:34:44 -0000 1.3 --- weapon.cc 17 Nov 2004 22:56:27 -0000 1.4 *************** *** 11,17 **** pModel->SetPosition(Vector3(5,0,-5)); Game::pSelf->GetSceneManager()->AddWorldObject(pModel); - - fFireRate = 0.1f; - fCoolDown = fFireRate; } --- 11,14 ---- *************** *** 30,50 **** } - void Weapon::Fire (const Vector3& vPosition, const Vector3& vTarget, Pawn* p) - { - if (fCoolDown > 0.0f) - return; - - fCoolDown = fFireRate; - - Vector3 target = vPosition - vTarget*10000; - - CollisionResult cR = Game::pSelf->Trace(vPosition, target, p); - if (cR.pNode == NULL) //on a touche la map - Game::pSelf->GetSceneManager()->GetDecalManager()->AddDecal(cR.EndPoint, cR.Normal, 1.0f, 1.0f, Engine::pTextureManager->LoadTexture("data/textures/decals/mgun.bmp", TG_TEXTURE_2D), 10.0f); - if (cR.pNode != NULL && cR.pNode->GetPhysicCallBack() != NULL) //on a touche un objet - cR.pNode->GetPhysicCallBack()->Collide(NULL, cR.EndPoint, cR.Normal); - - SoundManager::pSoundManager->PlaySound("gun"); - } void Weapon::Animation(string name) --- 27,30 ---- Index: weapon.h =================================================================== RCS file: /cvsroot/epfl/tggame/weapon.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** weapon.h 14 Nov 2004 13:34:44 -0000 1.2 --- weapon.h 17 Nov 2004 22:56:27 -0000 1.3 *************** *** 12,20 **** { public: ! Weapon (); ! ~Weapon (); ! void Fire (const Vector3& vPosition, const Vector3& vTarget, Pawn* p); ! void Think (float eTime); void Animation(std::string name); --- 12,20 ---- { public: ! Weapon (); ! virtual ~Weapon (); ! virtual void Fire (const Vector3& vPosition, const Vector3& vTarget, Pawn* p) = 0; ! void Think (float eTime); void Animation(std::string name); Index: aicontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/aicontroller.cc,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** aicontroller.cc 12 Nov 2004 12:13:17 -0000 1.10 --- aicontroller.cc 17 Nov 2004 22:56:27 -0000 1.11 *************** *** 64,70 **** } ! void AIController::Collide (SceneNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal) { ! pPawn->SetAnimation("death"); } --- 64,80 ---- } ! void AIController::Collide (PhysicNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal) { ! iLife -= 5; ! if (!bAlive) ! { ! Game::pSelf->RemovePawn(pPawn); ! } ! if (iLife <= 0 && bAlive) ! { ! pPawn->SetAnimation("death"); ! pPawn->SetBB (Vector3(-15,0,-10), Vector3(60, 30, 15)); ! bAlive = false; ! } } |