|
From: Yohann C. <pl...@us...> - 2004-10-31 11:03:23
|
Update of /cvsroot/epfl/tggame In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14697 Modified Files: aicontroller.cc game.cc Log Message: pinky tourne en rond.... piloté par l'AI.... Index: game.cc =================================================================== RCS file: /cvsroot/epfl/tggame/game.cc,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** game.cc 28 Oct 2004 21:20:33 -0000 1.21 --- game.cc 31 Oct 2004 11:03:06 -0000 1.22 *************** *** 135,140 **** p->SetPosition(Vector3(50,70,0)); ! p->SetRotationVelocity(Quaternion(0.5,Vector3(0,1,1))); ! p->SetRotation(Quaternion(90,Vector3(0,1,0))); //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(0,30,0)); //p->GetModel()->SetPhysicCallBack(c); --- 135,140 ---- p->SetPosition(Vector3(50,70,0)); ! p->SetRotationVelocity(Quaternion(10,Vector3(0,1,1))); ! //p->SetRotation(Quaternion(90,Vector3(0,1,0))); //p->SetPosition(pWorld->GetRandomStartPosition()+Vector3(0,30,0)); //p->GetModel()->SetPhysicCallBack(c); Index: aicontroller.cc =================================================================== RCS file: /cvsroot/epfl/tggame/aicontroller.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** aicontroller.cc 21 Oct 2004 21:29:14 -0000 1.4 --- aicontroller.cc 31 Oct 2004 11:03:06 -0000 1.5 *************** *** 1,2 **** --- 1,4 ---- + #define AI_DEBUG 0 + #include "aicontroller.h" #include "game.h" *************** *** 7,18 **** bool initialised = false; ! void AIController::Think (float eTime) { ! if (!initialised) // A mettre ailleurs... mais je ne vais pas hacker tggame.. je laisse ca aux experts ;) AIController::Initialize(); ! // Vector3 pos = pPawn->GetPosition(); // position du perso AI Vector3 vPos = Game::pSelf->GetSceneManager()->GetCamera()->GetPosition(); // position de la camera --- 9,20 ---- bool initialised = false; ! int rot=0; void AIController::Think (float eTime) { ! /* if (!initialised) // A mettre ailleurs... mais je ne vais pas hacker tggame.. je laisse ca aux experts ;) AIController::Initialize(); ! */ // Vector3 pos = pPawn->GetPosition(); // position du perso AI Vector3 vPos = Game::pSelf->GetSceneManager()->GetCamera()->GetPosition(); // position de la camera *************** *** 20,34 **** Vector3 vCentre = Game::pSelf->GetSceneManager()->Trace(vPos, vPos + ( Vector3::UNIT_Z*(-1000000) ) ).EndPoint; float fVarX = vCentre.x - vPos.x; float fVarZ = vCentre.z - vPos.z; float fDist = sqrt(fVarX*fVarX + fVarZ*fVarZ); ! /* std::cout << "EndPoint Z: " << vCentre.z ! << " Position : " << vPos ! << " Distance : " << abs(fVarZ) << std::endl;*/ } void AIController::Collide (SceneNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal) { - // std::cout << "aicontroller" << std::endl; // fYaw=rand()%360; // std::cout << vPoint << std::endl; --- 22,43 ---- Vector3 vCentre = Game::pSelf->GetSceneManager()->Trace(vPos, vPos + ( Vector3::UNIT_Z*(-1000000) ) ).EndPoint; + float fVarX = vCentre.x - vPos.x; float fVarZ = vCentre.z - vPos.z; float fDist = sqrt(fVarX*fVarX + fVarZ*fVarZ); ! ! #if AI_DEBUG >= 5 ! std::cout << "[AI] EndPoint Z: " << vCentre.z ! << " Position : " << vPos ! << " Distance : " << abs(fVarZ) << std::endl; ! #endif ! ! pPawn->SetRotation(Quaternion(rot++, Vector3::UNIT_Y)); ! rot=rot%360; ! bDir[0]=1; } void AIController::Collide (SceneNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal) { // fYaw=rand()%360; // std::cout << vPoint << std::endl; *************** *** 37,43 **** void AIController::Initialize() { ! std::cout << "\n\n---[AI]--- C'est parti pour l'IA" << std::endl; initialised=true; ! // srand( (unsigned)time( NULL ) ); } --- 46,54 ---- void AIController::Initialize() { ! #if AI_DEBUG >= 1 ! std::cout << "[AI] C'est parti pour l'IA" << std::endl; ! #endif initialised=true; ! srand( (unsigned)time( NULL ) ); } |