path finding

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Guest

path finding

Post by Guest »

Hi,

I need to perform some basic AI for models.
The models runs in the scene, following some targets, like quake.

how to perform the orientation and translation of the models to the targets?.

I have tried to put one camera child of model, and setTarget() of the camera to the next target, but the model don't get the rotation of the camera.

for example:

person->addChild(camera);
camera->setTarget(flag);
person->setRotation(camera->getRotation());


but, dont work.... :o(

any help, niko?
Guest

Re: path finding

Post by Guest »

... and i have tried other metod:

// --------------- function Dot and Magnitude
float Dot(vector3df vVector1, vector3df vVector2) {
// (V1.x * V2.x + V1.y * V2.y + V1.z * V2.z)
return ( (vVector1.X * vVector2.X) + (vVector1.Y * vVector2.Y) + (vVector1.Z * vVector2.Z) );
}

float Magnitude(vector3df vNormal){
return (float)sqrt( (vNormal.X * vNormal.X) + (vNormal.Y * vNormal.Y) + (vNormal.Z * vNormal.Z) );
}


//----------------------

float dotP = Dot(vigiapos, navepos);
float vmagnitude = Magnitude(vigiapos) * Magnitude(navepos);
double angle = acos(dotP / vmagnitude);
printf("angle = %d\n", angle);

vigia->setRotation(vector3df(nave->getRotation().X, angle, nave->getRotation().Z));

... but it dont work, either.

i get desesperated.... sure.
:lol:
jrnovoa
Posts: 12
Joined: Tue Sep 16, 2003 12:29 pm
Contact:

Re: path finding

Post by jrnovoa »

OK... i have been get the solution myself...

I send soon the source and the executable about basic path finding.

It is the example of code:


// --------------- function Dot, Magnitude and Angle
float Dot(vector3df vVector1, vector3df vVector2) {
// (V1.x * V2.x + V1.y * V2.y + V1.z * V2.z)
return ( (vVector1.X * vVector2.X) + (vVector1.Y * vVector2.Y) + (vVector1.Z * vVector2.Z) );
}

float Magnitude(vector3df vNormal){
return (float)sqrt( (vNormal.X * vNormal.X) + (vNormal.Y * vNormal.Y) + (vNormal.Z * vNormal.Z) );
}

double AngleBetweenVectors(vector3df Vector1, vector3df Vector2){

float dotProduct = Dot(Vector1, Vector2);
float vectorsMagnitude = Magnitude(Vector1) * Magnitude(Vector2) ;
double angle = acos( dotProduct / vectorsMagnitude );
return( angle);

}

//---------------------- and lather....

float vangle = AngleBetweenVectors(vigiapos, navepos);
vangle /= (PI / 180);

vector3df vrot = vigia->getRotation();
vrot.Y = vangle;
vigia->setRotation(vrot);

OKIS, OKIS.... HOUSTON


:D :D
Guest

Post by Guest »

hello,

i'm trying to do the same thing, and have tried your code, but i can't get it to work..here's what i'm doing:

Code: Select all

vangle = AngleBetweenVectors(botPos, lookToPos); 
vangle /= (core::PI / 180); 
vrot = botNode->getRotation(); 
vrot.Y = vangle; 
botNode->setRotation(vrot);
any ideas??
Guest

Post by Guest »

*bump* :)

any help here? this has got me stuck.
Guest

Post by Guest »

one last bump - i'm desperate! :)
Post Reply