walking forward?

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.
qwe
Posts: 112
Joined: Sun Dec 28, 2003 12:54 am
Location: Oregon, USA

Post by qwe »

that's exactly what I was trying to say but didn't have the time to type. :D
Eric the half a bee
Posts: 3
Joined: Sat Jan 24, 2004 1:00 pm
Location: Wimbledon, England

Moving a Node based on rotation

Post 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
We like the moon
deps
Posts: 115
Joined: Sat Jan 10, 2004 5:22 pm
Location: Tranås, Sweden

Post 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)
JoeMill
Posts: 3
Joined: Wed Jan 14, 2004 12:29 pm
Location: Dresden, Germany

Post by JoeMill »

Irrlicht has a #define for PI, use irr::core::PI ;)
DarkWhoppy
Posts: 386
Joined: Thu Sep 25, 2003 12:43 pm
Contact:

Post by DarkWhoppy »

Irrlicht has a define for sin() and cos() too. I don't have to include any other files... just <irrlicht.h>
Programmer of the Irrlicht Scene Editor:
Homepage - Forum Thread
Version 2 on its way!!
NecromanX
Posts: 16
Joined: Sat Jan 24, 2004 6:01 pm

Post 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 ) );
moni

Post 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
NecromanX
Posts: 16
Joined: Sat Jan 24, 2004 6:01 pm

Post by NecromanX »

thanks dude
Post Reply