Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6108 Modified Files: aicontroller.cc game.cc pawn.cc pawn.h playercontroller.cc projectile.cc projectile.h rocket.cc rocket.h rocketlauncher.cc Log Message: rockets Index: projectile.cc =================================================================== RCS file: /cvsroot/epfl/tggame/projectile.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** projectile.cc 17 Nov 2004 23:12:56 -0000 1.2 --- projectile.cc 19 Nov 2004 12:05:14 -0000 1.3 *************** *** 1,7 **** #include "projectile.h" ! Projectile::Projectile() : Pawn () { - } --- 1,7 ---- #include "projectile.h" + #include "controller.h" ! Projectile::Projectile() : Pawn ("rocket") { } Index: game.cc =================================================================== RCS file: /cvsroot/epfl/tggame/game.cc,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** game.cc 17 Nov 2004 23:12:56 -0000 1.34 --- game.cc 19 Nov 2004 12:05:14 -0000 1.35 *************** *** 83,86 **** --- 83,87 ---- void Game::AddPawn (Pawn* p, bool physic = true, bool scene = true) { + vPawns.push_back(p); if (scene) p->Add(pSceneManager); *************** *** 93,96 **** --- 94,98 ---- p->Remove(pSceneManager); p->Remove(pPhysicEngine); + //TODO: il faut enlever le pawn de vPawns; } *************** *** 117,134 **** pEngine->pMeshManager->LoadAnim("pinky", "data/models/player/death.md5anim"); ! pEngine->pMeshManager->Load("rocket", "data/models/player/hazmat.md5mesh"); ! ! //creation de l'arme ! /*MD5Instance* pModel = Engine::pMeshManager->LoadInstance("machinegun"); ! pModel->SetAnimation("idle"); ! pModel->bCamera = true; ! pModel->SetRotation(Quaternion(90, Vector3(0,0,1))); ! pModel->SetPosition(Vector3(5,0,-5)); ! pSceneManager->AddWorldObject(pModel);*/ //creation du joueur Pawn* p = new Pawn(); pSceneManager->SetCamera(cam); - vPawns.push_back(p); this->AddPawn(p); pLocalController = new PlayerController(p); --- 119,133 ---- pEngine->pMeshManager->LoadAnim("pinky", "data/models/player/death.md5anim"); ! pEngine->pMeshManager->Load("rocket", "data/models/rocket/rocket.md5mesh"); + ParticleEmitter* pEmit = new ParticleEmitter (100, Vector3(0,0,0), pEngine->pTextureManager->LoadTexture("data/particle.jpg", TG_TEXTURE_2D), 10.0f); + pEmit->SetParticlesSpeed (Vector3(90,0,0)); + pEmit->SetLife(30.0f); + pEmit->Initialize (); + pSceneManager->AddParticlesEmitter(pEmit); + //creation du joueur Pawn* p = new Pawn(); pSceneManager->SetCamera(cam); this->AddPawn(p); pLocalController = new PlayerController(p); *************** *** 136,139 **** --- 135,139 ---- cam->SetViewOffset(Vector3(0,70,0)); pLocalController->SetViewOffset(Vector3(0,60,0)); + p->SetBB(Vector3(-15, 0, -15), Vector3(15, 80, 15)); //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(20,80,20)); *************** *** 147,152 **** //for (int i=0; i<pWorld->GetNumStartPositions(); i++) //{ ! p = new Pawn(); ! vPawns.push_back(p); this->AddPawn(p); Controller* c = new AIController(p); --- 147,152 ---- //for (int i=0; i<pWorld->GetNumStartPositions(); i++) //{ ! p = new Pawn("pinky"); ! p->SetAnimation("stand"); this->AddPawn(p); Controller* c = new AIController(p); *************** *** 156,159 **** --- 156,160 ---- //p->SetRotation(Quaternion(-90, Vector3(1,0,0))); p->SetPosition(pWorld->GetStartPosition(0)); + p->SetBB(Vector3(-15, 0, -15), Vector3(15, 80, 15)); c->SetViewOffset(Vector3(0,70,0)); //} Index: rocketlauncher.cc =================================================================== RCS file: /cvsroot/epfl/tggame/rocketlauncher.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rocketlauncher.cc 17 Nov 2004 23:12:56 -0000 1.2 --- rocketlauncher.cc 19 Nov 2004 12:05:14 -0000 1.3 *************** *** 20,34 **** fCoolDown = fFireRate; - Rocket* pRocket = new Rocket (); - pRocket->Add(Game::pSelf->GetSceneManager()); - pRocket->Add(Game::pSelf->GetPhysicEngine()); - 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"); --- 20,33 ---- fCoolDown = fFireRate; Vector3 target = vPosition - vTarget*10000; + + Rocket* pRocket = new Rocket (vPosition, target); + Game::pSelf->AddPawn(pRocket, true, true); ! /*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"); Index: rocket.h =================================================================== RCS file: /cvsroot/epfl/tggame/rocket.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rocket.h 17 Nov 2004 23:12:56 -0000 1.2 --- rocket.h 19 Nov 2004 12:05:14 -0000 1.3 *************** *** 7,12 **** { public: ! Rocket (); protected: }; --- 7,15 ---- { public: ! Rocket (const Vector3& vPosition, const Vector3& vTarget); ! ~Rocket (); ! void Collide (PhysicNode* other,const Vector3& vPoint, const Vector3& vCollisionNormal); protected: + static const float fSpeed; }; Index: projectile.h =================================================================== RCS file: /cvsroot/epfl/tggame/projectile.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** projectile.h 17 Nov 2004 23:12:56 -0000 1.2 --- projectile.h 19 Nov 2004 12:05:14 -0000 1.3 *************** *** 6,18 **** #include <md5instance.h> #include <physicnode.h> using namespace tg; ! class Projectile : public Pawn { public: ! Projectile (); ! virtual ~Projectile (); ! protected: }; --- 6,19 ---- #include <md5instance.h> #include <physicnode.h> + #include <physiccallback.h> using namespace tg; ! class Projectile : public Pawn, public PhysicCallBack { public: ! Projectile (); ! virtual ~Projectile (); ! virtual void Collide (PhysicNode* other,const Vector3& vPoint, const Vector3& vCollisionNormal) = 0; protected: }; Index: rocket.cc =================================================================== RCS file: /cvsroot/epfl/tggame/rocket.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rocket.cc 17 Nov 2004 23:12:56 -0000 1.2 --- rocket.cc 19 Nov 2004 12:05:14 -0000 1.3 *************** *** 1,9 **** #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);*/ ! } \ No newline at end of file --- 1,37 ---- #include "rocket.h" + #include "game.h" + #include <vector3.h> ! const float Rocket::fSpeed = 900.0f; ! ! Rocket::Rocket (const Vector3& vPosition, const Vector3& vTarget) : Projectile () { ! pPhysic->SetGravityFactor(0.0f); ! pPhysic->SetPosition(vPosition); ! Vector3 vVeloc = (vTarget-vPosition).Normalize(); ! vVeloc *= fSpeed; ! //std::cout << "[TGGAME] " << vVeloc << std::endl; ! pPhysic->SetVelocity(vVeloc); ! pPhysic->SetPhysicCallBack(this); ! //pPhysic->SetSpeed ! } ! ! Rocket::~Rocket () ! { ! ! } ! ! void Rocket::Collide (PhysicNode* other,const Vector3& vPoint, const Vector3& vCollisionNormal) ! { ! Game::pSelf->RemovePawn(this); ! if (other == NULL) //on a touche la map ! { ! //FIXME: Ugly hack pour que le decal soit fixé contre le mur. Le vPoint est en fait la position du node au moment de la collision. Hors, le node a une bounding box, ce qui fait que le vPoint est éloigné du mur. ! Vector3 cP = vPoint - vCollisionNormal*15; ! Game::pSelf->GetSceneManager()->GetDecalManager()->AddDecal(cP, vCollisionNormal, 50.0f, 50.0f, Engine::pTextureManager->LoadTexture("data/textures/decals/rocket.jpg", TG_TEXTURE_2D), 10.0f); ! } ! ! if (other != NULL && other->GetPhysicCallBack() != NULL) //on a touche un objet ! other->GetPhysicCallBack()->Collide(NULL, vPoint, vCollisionNormal); ! delete this; ! } Index: pawn.cc =================================================================== RCS file: /cvsroot/epfl/tggame/pawn.cc,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** pawn.cc 17 Nov 2004 23:12:56 -0000 1.13 --- pawn.cc 19 Nov 2004 12:05:14 -0000 1.14 *************** *** 3,13 **** using namespace tg; ! Pawn::Pawn() : Actor () { ! pModel = Engine::pMeshManager->LoadInstance("pinky"); ! 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; --- 3,11 ---- using namespace tg; ! Pawn::Pawn(const std::string& mesh) : Actor () { ! pModel = Engine::pMeshManager->LoadInstance(mesh); ! //pModel->SetAnimation("stand"); pPhysic = new PhysicNode(pModel); //pPhysic->SetClip(false); fMoveSpeed = 0.0f; Index: pawn.h =================================================================== RCS file: /cvsroot/epfl/tggame/pawn.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** pawn.h 17 Nov 2004 23:12:56 -0000 1.13 --- pawn.h 19 Nov 2004 12:05:14 -0000 1.14 *************** *** 23,27 **** * Constructeur */ ! Pawn (); virtual ~Pawn (); /** --- 23,27 ---- * Constructeur */ ! Pawn (const std::string& mesh="pinky"); virtual ~Pawn (); /** Index: playercontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/playercontroller.cc,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** playercontroller.cc 17 Nov 2004 23:12:56 -0000 1.20 --- playercontroller.cc 19 Nov 2004 12:05:14 -0000 1.21 *************** *** 29,33 **** { vTarget = pPawn->GetRotation().GetZAxis(); ! vPosition = pPawn->GetPosition()+vViewOffset; pWeapon->Fire (vPosition, vTarget, pPawn); } --- 29,33 ---- { vTarget = pPawn->GetRotation().GetZAxis(); ! vPosition = pPawn->GetPosition()+vViewOffset-vTarget*50; pWeapon->Fire (vPosition, vTarget, pPawn); } Index: aicontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/aicontroller.cc,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** aicontroller.cc 17 Nov 2004 23:12:56 -0000 1.12 --- aicontroller.cc 19 Nov 2004 12:05:14 -0000 1.13 *************** *** 67,70 **** --- 67,71 ---- { iLife -= 5; + std::cout << "OUCH" << std::endl; if (!bAlive) { |