walking forward?
-
- Posts: 3
- Joined: Sat Jan 24, 2004 1:00 pm
- Location: Wimbledon, England
Moving a Node based on rotation
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
Your assistance is appreciated.
Eric
We like the moon
-
- Posts: 386
- Joined: Thu Sep 25, 2003 12:43 pm
- Contact:
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
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 ) );
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:
this way you'll not run into problems if you're using other models than MD2s.
cheers
moni
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);
cheers
moni