Rotating a model in 3D space

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
NewImage
Posts: 8
Joined: Wed Feb 11, 2009 3:07 am

Rotating a model in 3D space

Post by NewImage »

Hi
I'm trying to put together a dog fight space game. The spaceship is a IMeshSceneNode But I'm having some problems with rotating in 3D space relative to the object it self.

I was trying to use the code in this topic
http://irrlicht.sourceforge.net/phpBB2/ ... t=rotation


But unlike the camera, mesh nodes don't have a getTarget() and GetUpVector() . I don't know how to create a relative XYZ space that I can rotate around and keep it locked to the ship as it moves and spins.

Any help would be great thank you.

----

after looking on some forums would this work?

Code: Select all

  core::vector3df forward(0, 0, 1);

  core::matrix4 m;
  m.setRotationDegrees( node->getRotationDegrees() );

  // rotate the forward vector into parent coords
  m.rotateVect(forward);

  // get the old position
  core::vector3df position(node->getPosition());

  // get the distance moved this time slice
  f32 distance = velocity * time;

  // augment the node position
  position += (forward * distance);
  node->setPosition(position); 
and just do this again with a left right vector?
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Free Flight (space flight) functions

You can also modify that code to use AbsoluteTransformation but in principle it is the same:

Code: Select all

irr::core::matrix4 m = node->getAbsoluteTransformation();
NewImage
Posts: 8
Joined: Wed Feb 11, 2009 3:07 am

Post by NewImage »

Thank you for your reply, ill give that a shot. I have another question, what does absolute mean, I see it in the getrotation and getposition functions, and now in this?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Absolute coordinates are the relative ones, transformed to the world coordinate system (i.e. taking into account all parent transformations). For scene nodes without parents the both are the same.
Post Reply