Update of /cvsroot/epfl/tggame
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16052
Modified Files:
aicontroller.cc aicontroller.h
Log Message:
premier essai d'AI. pas une AI, c'est juste pour le debugage :)
Index: aicontroller.cc
===================================================================
RCS file: /cvsroot/epfl/tggame/aicontroller.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** aicontroller.cc 10 Oct 2004 21:25:32 -0000 1.1
--- aicontroller.cc 14 Oct 2004 13:21:06 -0000 1.2
***************
*** 2,16 ****
#include "game.h"
void AIController::Think (float eTime)
{
- iForward += 1;
! CollisionResult c = Game::pSelf->GetSceneManager()->Trace(pPawn->GetPosition(), pPawn->GetPosition()+Vector3::UNIT_X*100);
! // std::cout << std::setprecision(0) << "Endpoint : " << c.EndPoint << "\t\tNormal : " << c.Normal << std::endl;
}
void AIController::Collide (SceneNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal)
{
! //std::cout << "aicontroller" << std::endl;
}
--- 2,61 ----
#include "game.h"
+ #include <time.h>
+ #include <stdlib.h>
+ #include <math.h>
+
+ 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
!
! 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;
}
+ void AIController::Initialize()
+ {
+ std::cout << "\n\n---[AI]--- C'est parti pour l'IA" << std::endl;
+ initialised=true;
+ iForward=1;
+ // srand( (unsigned)time( NULL ) );
+ }
+
+ /*
+ =================================================================
+ NOTES : JE SAIS, JE POURAIS LES METTRE AILLEURS, MAIS LA-DESSOUS,
+ JE TROUVE QUE C'EST BIEN AUSSI..... :P
+ merci de les laisser :)
+ =================================================================
+
+
+ ## trouver l'altitude à une position donnee
+ CollisionResult c = Game::pSelf->GetSceneManager()->Trace(pPawn->GetPosition(), pPawn->GetPosition()+Vector3::UNIT_Y*100);
+
+ ## affichage direct des vecteurs3: ca peut toujours etre utile....
+ std::cout << std::setprecision(0) << "Endpoint : " << c.EndPoint << "\t\tNormal : " << c.Normal << std::endl;
+
+
+ */
+
Index: aicontroller.h
===================================================================
RCS file: /cvsroot/epfl/tggame/aicontroller.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** aicontroller.h 10 Oct 2004 21:25:32 -0000 1.1
--- aicontroller.h 14 Oct 2004 13:21:06 -0000 1.2
***************
*** 11,14 ****
--- 11,15 ----
void Think (float);
void Collide (SceneNode* other, const Vector3& vPoint, const Vector3& vCollisionNormal);
+ void Initialize ();
};
|