Page 2 of 2

Posted: Sat Jan 03, 2004 2:14 am
by qwe
that's exactly what I was trying to say but didn't have the time to type. :D

Moving a Node based on rotation

Posted: Sun Jan 25, 2004 11:25 am
by Eric the half a bee
If I want to use the code included earlier in this thread, I need to define PI somewhere. Is this another library I need to include in my Visual Studio project, or have I missed an earlier definition in my code...I am guessing that the same problem will then arise with cos, sin, and tan.

Your assistance is appreciated.

Eric

Posted: Sun Jan 25, 2004 11:37 am
by deps
#define PI 3.1415926535

And to get sin and cos you should just include math.h
#include <math.h>

(PI is probably in there somewhere to)

Posted: Sun Jan 25, 2004 12:54 pm
by JoeMill
Irrlicht has a #define for PI, use irr::core::PI ;)

Posted: Sun Jan 25, 2004 4:59 pm
by DarkWhoppy
Irrlicht has a define for sin() and cos() too. I don't have to include any other files... just <irrlicht.h>

Posted: Mon Jan 26, 2004 4:35 pm
by NecromanX
I used the sydney model to test this piece of code and there is still a little problem. she strafes instead of walking forward :p
so for those who have this problem too simply change this line to

Code: Select all

vector3df forward( sin( node->getRotation().Y*PI/180.0f ), 0, cos( node->getRotation().Y*PI/180.0f ) ); 

Code: Select all

vector3df forward( sin( (node->getRotation().Y+90)*PI/180.0f ), 0, cos( (node->getRotation().Y+90)*PI/180.0f ) );

Posted: Mon Jan 26, 2004 5:11 pm
by moni
strafing instead of going forward is because the md2 models are facing towards the positive x-axis by default!
so, be carefull if you change the forward vector definition, actually for md2 models forward should rather be defined like this:

Code: Select all

irr::core::matrix4 mat;
vector3df fw(1,0,0); // md2 default forward
mat.setRotationDegrees(node->getRotation());
mat.transformVect(fw);
this way you'll not run into problems if you're using other models than MD2s.

cheers
moni

Posted: Tue Jan 27, 2004 11:11 am
by NecromanX
thanks dude