|
From: Yohann C. <pl...@us...> - 2004-12-02 22:02:46
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16812 Modified Files: aicontroller.cc aicontroller.h Log Message: pour le debug... le perso fait rien de plus pour le moment. (enfin, il serait sensé, mais non....) Index: aicontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/aicontroller.cc,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** aicontroller.cc 2 Dec 2004 00:18:54 -0000 1.18 --- aicontroller.cc 2 Dec 2004 22:02:37 -0000 1.19 *************** *** 8,11 **** --- 8,13 ---- #include <math.h> + #define cout std::cout<<"[AI] " + bool initialised = false; int rot=0; *************** *** 40,46 **** } ! static float rotY = 0.0f; static float test = 0.5f; ! /* float test = Util::Random(); if (test < 0.5f) test *= -1; --- 42,48 ---- } ! /* static float rotY = 0.0f; static float test = 0.5f; ! float test = Util::Random(); if (test < 0.5f) test *= -1; *************** *** 50,65 **** // pPawn->SetRotation(Quaternion(rotY, Vector3::UNIT_Y)); ! //bDir[FORWARD] = 1; ! } - void AIController::HitWall(const Vector3& vPoint, const Vector3& vNormal, PhysicNode* who) { //if (other == NULL) //si on a une collision avec la map, on ne prend pas de degats // return; ! //iLife -= 5; pPawn->SetRotation(Quaternion(Util::Random()*360, Vector3::UNIT_Y)); /*std::cout << "OUCH" << std::endl; --- 52,69 ---- // pPawn->SetRotation(Quaternion(rotY, Vector3::UNIT_Y)); ! AIController::LookForward(); ! // pPawn->SetVelocity(Vector3(0,1,0)); } void AIController::HitWall(const Vector3& vPoint, const Vector3& vNormal, PhysicNode* who) { //if (other == NULL) //si on a une collision avec la map, on ne prend pas de degats // return; ! //iLife -= 5; pPawn->SetRotation(Quaternion(Util::Random()*360, Vector3::UNIT_Y)); + #if AI_DEBUG >=4 + cout << "OUCH" << std::endl; + #endif /*std::cout << "OUCH" << std::endl; *************** *** 77,84 **** } void AIController::Initialize() { #if AI_DEBUG >= 1 ! std::cout << "[AI] C'est parti pour l'IA" << std::endl; #endif initialised=true; --- 81,89 ---- } + // n'est jamais appelee. c'est a peu pres normal pour le moment.... void AIController::Initialize() { #if AI_DEBUG >= 1 ! cout << "C'est parti pour l'IA" << std::endl; #endif initialised=true; *************** *** 87,90 **** --- 92,131 ---- } + Vector3 AIController::LookForward() + { + Vector3 vVelocity = pPawn->GetVelocity(); + float fMoveSpeed = pPawn->GetMoveSpeed(); + + // trace dans la direction du deplacement + CollisionResult c = Game::pSelf->GetSceneManager()->Trace(pPawn->GetPosition(), vVelocity*2); + + // cherche (mais ne marche pas) a savoir si le lancer de rayon a touché un objet (map ou joueur) + if(c.EndPoint != 2*vVelocity+pPawn->GetPosition()) { + // dans ce cas, on ralentit... + pPawn->SetMoveSpeed(fMoveSpeed-0.5); + // puis on tourne... (a revoir... a priori SetVelocity n'est pas ce que je cherche...) + pPawn->SetVelocity(vVelocity + 4*c.Normal); + #if AI_DEBUG >= 4 + cout << "Changement de direction..." << std::endl; + #endif + } else { + // sinon, on va augmenter la vitesse (pas de vitesse limite dans le moteur pour le moment + // a priori, donc je limite moi-meme.... + if(fMoveSpeed < 449.5) { + #if AI_DEBUG >= 4 + cout << "augmentation de la vitesse" << std::endl; + #endif + pPawn->SetMoveSpeed(fMoveSpeed+0.5); + } + } + + #if AI_DEBUG >= 5 + cout << c.EndPoint << " / " << (2*vVelocity+pPawn->GetPosition())<< std::endl; + #endif + + // ca, ca sert a rien pour le moment, mais c'est sensé servir plus tard + // (biensur, je retournerai autre chose..) + return Vector3::UNIT_Y; + } /* ================================================================= Index: aicontroller.h =================================================================== RCS file: /cvsroot/epfl/tggame/aicontroller.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** aicontroller.h 2 Dec 2004 00:18:54 -0000 1.12 --- aicontroller.h 2 Dec 2004 22:02:37 -0000 1.13 *************** *** 22,25 **** --- 22,28 ---- void HitWall (const Vector3& vPoint, const Vector3& vCollisionNormal, PhysicNode* who); void Initialize (); + protected: + Vector3 LookForward(); + }; |