Page 1 of 1

Rotation doesnt affect origin

Posted: Fri Jul 25, 2008 3:05 am
by MasterM
Hey all, i have a 3d car that can move,rotate,etc but when i rotate the 3d car
and move it forward it doesn't move forward in the direction the rotation is and resulting in a very strange car.
So i ask how do i rotate the car and the origin of it at the same time?
Thanks in advance.

Posted: Fri Jul 25, 2008 3:07 am
by Ion Dune
This has been answered a ridiculous number of times. Please use the search function at the top of your screen.

Posted: Fri Jul 25, 2008 3:45 am
by MasterM
I searched but i did not get anything that helped me, if you know a good link pleas give it to me.
Thanks in advance.

Posted: Fri Jul 25, 2008 4:32 am
by Ion Dune

Posted: Fri Jul 25, 2008 8:18 am
by rogerborg
You lied to me! I feel... violated.

I need to go and lie down now, and deal with the shock. It'll be difficult to trust you after this, but... I'll try counselling if you will.

Posted: Fri Jul 25, 2008 12:15 pm
by cdrwolfe
rogerborg wrote:You lied to me! I feel... violated.

I need to go and lie down now, and deal with the shock. It'll be difficult to trust you after this, but... I'll try counselling if you will.
Your a Scot aren't you, you should be used to it by now :)

Regards Wolfe

Posted: Fri Jul 25, 2008 12:29 pm
by rogerborg
We never learn though.

Scotchmen: Right, Frenchies, are you up for getting stuck into the English?
Frenchies: Oui.
Scotchmen: For real this time? We'll invade from the North, you come from the South?
Frenchies: Oui.
Scotchmen: OK, we're about to go. Are you definitely going to join in this time?
Frenchies: Oui.
Scotchmen: Promise?
Frenchies: Oui.
Scotchmen: FREEEEEEEEEDOM! CHAAAAR- wait... are you invading or not?
Frenchies: (shrug) Non.
Scotchmen: (charge into a swamp and get bayoneted - again)

How many times?

Posted: Fri Jul 25, 2008 3:10 pm
by MasterM
I did not lie to you...
The car is moving fine but the orgin doesnt change...
I swear i did not lie to you.

Posted: Fri Jul 25, 2008 8:23 pm
by Ion Dune
rogerborg wrote:Brilliant! Have you got framerate independent motion, and movement in the correct direction working OK?
MasterM wrote:Yup, its working in the correct direction
Also, I found another answer for you in that very same thread.
rogerborg wrote: Then, as the model rotates, the forwards (and backwards) direction changes, and you'll want to calculate that direction and then add it to - or subtract it from - the model's position when it moves forwards and backwards.

To get the forwards direction, you can either use trig, matrix methods, or if you've got the latest SVN code (as I recommend because of the getTime() issue on Windows) then you can use the new vector3df::rotationToDirection() utility method to create a forwards vector directly from the node's rotation.
Deja vu, eh? :lol:

I think the fundamental problem here is that the origin is only a point, not a rotation. When you rotate a node, it will rotate around it's origin, but there is no "rotation" of the origin to be changed. You yourself have to manually calculate which direction to move the node to achieve movement in the correct manner; refer to either what rogerborg said in the last topic (as I have conveniently quoted above) or the link to the topic I posted earlier.

Posted: Mon Jul 28, 2008 3:13 am
by MasterM
I still dont see why i lied, really i dont :S

Posted: Mon Jul 28, 2008 4:30 am
by rooly
To get what you want, you'll need a minorly-complex mathematical calculation to have your car travelling "forward" in relation to it's rotation.

irrlicht can most correctly be called a 3d rendering engine, as opposed to a game engine. for this matter, irrlicht does not store the "forward" orientation itself. this is up to you.

the way i like to do it, is to use a class that acts as a container for a group of nodes:

ISceneNode* parent, mesh, transform;

set the mesh and transform's parent as "parent".
when moving, set the parent's position to the transform's absolute position. then reset the transform's position to (0,0,0)

when rotating, set the parent's rotation to the transform's absolute rotation, then reset the transform's rotation to (0,0,0)

parent and transform should both be init'ed with addEmptySceneNode()


Now. i've just given you so much free information, i would be shot by the intellectual property cops. don't bug me unless you get on IRC

Posted: Mon Jul 28, 2008 3:04 pm
by Dark_Kilauea
psst...

I would just use a physics library, since it seems you are going for a car racing game