Update of /cvsroot/epfl/tggame
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8127
Modified Files:
aicontroller.cc aicontroller.h
Log Message:
Voilà, le bot évite les murs... pas top encore, mais disons qu'il tourne avant de se le prendre en pleine poire (sauf pour les petis objets: poubelles, escaliers.....)
Index: aicontroller.cc
===================================================================
RCS file: /cvsroot/epfl/tggame/aicontroller.cc,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** aicontroller.cc 2 Dec 2004 22:02:37 -0000 1.19
--- aicontroller.cc 3 Dec 2004 19:49:55 -0000 1.20
***************
*** 23,27 ****
{
pSphere = new DebugSphere ();
! Game::pSelf->GetSceneManager()->AddDebugSphere(pSphere);
}
--- 23,30 ----
{
pSphere = new DebugSphere ();
! // Game::pSelf->GetSceneManager()->AddDebugSphere(pSphere);
!
! pSphere2 = new DebugSphere ();
! Game::pSelf->GetSceneManager()->AddDebugSphere(pSphere2);
}
***************
*** 31,35 ****
{
Vector3 vTarget = pPawn->GetRotation().GetXAxis();
! Vector3 vPosition = pPawn->GetPosition()+vViewOffset;
vTarget = vPosition + vTarget*1000;
--- 34,38 ----
{
Vector3 vTarget = pPawn->GetRotation().GetXAxis();
! Vector3 vPosition = pPawn->GetPosition()+vViewOffset/2;
vTarget = vPosition + vTarget*1000;
***************
*** 63,67 ****
//iLife -= 5;
pPawn->SetRotation(Quaternion(Util::Random()*360, Vector3::UNIT_Y));
! #if AI_DEBUG >=4
cout << "OUCH" << std::endl;
#endif
--- 66,70 ----
//iLife -= 5;
pPawn->SetRotation(Quaternion(Util::Random()*360, Vector3::UNIT_Y));
! #if AI_DEBUG >=3
cout << "OUCH" << std::endl;
#endif
***************
*** 94,111 ****
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 {
--- 97,119 ----
Vector3 AIController::LookForward()
{
! Vector3 vTarget = pPawn->GetRotation().GetXAxis();;
! Vector3 vPosition = pPawn->GetPosition()+Vector3(0, 0, 4);
float fMoveSpeed = pPawn->GetMoveSpeed();
// trace dans la direction du deplacement
! CollisionResult c = Game::pSelf->Trace(vPosition , vPosition + vTarget*500, pPawn);
! pSphere2->vPosition = c.EndPoint;
// cherche (mais ne marche pas) a savoir si le lancer de rayon a touché un objet (map ou joueur)
! if(c.Fraction < 1) {
// dans ce cas, on ralentit...
! if (fMoveSpeed>10) {
! pPawn->SetMoveSpeed(fMoveSpeed-0.5);
! }
// puis on tourne... (a revoir... a priori SetVelocity n'est pas ce que je cherche...)
! pPawn->SetRotation(Quaternion(rot+=5, Vector3::UNIT_Y));
! // pPawn->SetVelocity(vVelocity + 4*c.Normal);
#if AI_DEBUG >= 4
! cout << "Changement de direction... "<< c.Fraction << std::endl;
#endif
} else {
***************
*** 119,123 ****
}
}
!
#if AI_DEBUG >= 5
cout << c.EndPoint << " / " << (2*vVelocity+pPawn->GetPosition())<< std::endl;
--- 127,131 ----
}
}
!
#if AI_DEBUG >= 5
cout << c.EndPoint << " / " << (2*vVelocity+pPawn->GetPosition())<< std::endl;
***************
*** 135,146 ****
=================================================================
-
## 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;
-
-
*/
--- 143,149 ----
Index: aicontroller.h
===================================================================
RCS file: /cvsroot/epfl/tggame/aicontroller.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** aicontroller.h 2 Dec 2004 22:02:37 -0000 1.13
--- aicontroller.h 3 Dec 2004 19:49:55 -0000 1.14
***************
*** 15,18 ****
--- 15,19 ----
DebugSphere* pSphere;
+ DebugSphere* pSphere2; // pour l'IA
public:
AIController (Pawn* p);
|