IrrNewt - strange rotation

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.
Donner
Posts: 87
Joined: Fri May 18, 2007 11:27 am

IrrNewt - strange rotation

Post by Donner »

Hi,

I use IrrNewt with my project and now I have a problem:

Maybe some of you knows the IrrNewt example with the car.

But how can I get the Y-Rotation if the car? I tried it with "chassis_node->getRotation().Y" but then I get a value between 270 and 90 degrees, so if the rotation is 90, it counts backwards, the same procedure if I reach 270 degrees.

The value is never between 90 and 270, so for example its impossible to reach 180 degrees.

Anaway, the car moves and rotates correctly, only the "getRotation()"-Value is wrong.

How can this be?
I need the real Y-rotation, because I want to create a third person cam.


Donner
AlaaBR9
Posts: 16
Joined: Sun Oct 21, 2007 8:47 pm
Location: syria/lattakia

Hello ..

Post by AlaaBR9 »

Hello ..
I donot have a solve for you, but i need help.
I try to download IRRNEWT 0.4 ,but i canot .
do you can send the package irrnewt 0.4 or older into my e-mail
Alaabr9@yahoo.com
thank you overall...
________
MARIJUANA TRICHOMES
Last edited by AlaaBR9 on Fri Feb 25, 2011 2:41 am, edited 1 time in total.
Donner
Posts: 87
Joined: Fri May 18, 2007 11:27 am

Post by Donner »

Hi,

i sent irrlicht to you as email attachment.


Well, back to topic:
I found out that, when the Y Rotation should change from 89.9... to 90 or heigher (it goes back to 89.9..., 89.8 ), the X- and Z Rotation change from (ca.) 0 degrees to ca. 180 degrees, but the Mesh doesnt change.


Hmm... my english isnt very good so its not esay to explain the problem... Well, I made a little drawing:
http://imageupload.com/out.php/i46836_i ... roblem.png

Here you can see the Y Rotation of the car. The black numbers stand for the Y Rotation, which is returned by "playermesh->getRotation().Y". The red numbers stand for the "real" rotation, but, as I said above, I get the wrong (black) values.

And if the 90° or the 270° are reached, the X-Rotation changes from 0 degrees to 180 degrees, exactly as the Z-Rotation.

How can it be?? What could IrrNewt/Newton do? I think its a question which regards Irrlicht and not only IrrNewt, so I hope I get an answer...


Donner
xray
Posts: 231
Joined: Fri Feb 02, 2007 1:06 pm
Location: Germany, Munich
Contact:

Post by xray »

Well I still have the same problem. And I asked the community some months ago without any answer. You can read my post here http://irrlicht.sourceforge.net/phpBB2/ ... highlight=
either the problem is in my/our rotation function or in irrlicht. It would be really nice if someone could check this and give us feedback!

@Donner: how does your rotation function look like?

best regards!
xray
Posts: 231
Joined: Fri Feb 02, 2007 1:06 pm
Location: Germany, Munich
Contact:

Post by xray »

Come on, whats up with all the professionals!!! :(
Vsk
Posts: 343
Joined: Thu Sep 27, 2007 4:43 pm

Post by Vsk »

Upps, sorry I didn' response earlier.
This is not a irrnewt problem, if I remember well is the way irrlicht manage rotation wit euler angles. (Look for euler angles, I learned this a little time ago too).

Well I think you can rotate your bodies doing:

matrix4 mat;
mat.serRotationDegrres(278) //an example ;-))

bodyPhysic.setRotation(mat.getRotation);

I don't know if this works.

if not, try:

matrix4 mat;
mat.serRotationRadians(angleInRandias)

bodyPhysic.setRotation(mat.getRotation);

I repeat, this is not a irrnewt problem, this is basic from irrlicht (that I don't know how to solve :lol: ).

I hope it help you. Tell me if you find the solution.
xray
Posts: 231
Joined: Fri Feb 02, 2007 1:06 pm
Location: Germany, Munich
Contact:

Post by xray »

Ok but I think that is what I made with my matrixRotation function, to change the excisting rotation of a node with a new one:

Code: Select all

// set the rotation between to euler angel vectors
core::vector3df matrixRotation(core::vector3df rotation, core::vector3df newrot)
{
   f32 pitch=newrot.X;
   f32 yaw=newrot.Y;
   f32 roll=newrot.Z;
   core::matrix4 m,t;
   
   m.setRotationDegrees(rotation);

   t.setRotationDegrees(core::vector3df(pitch,0,0));
   m*=t;

   t.setRotationDegrees(core::vector3df(0,0,roll));
   m*=t;

   t.setRotationDegrees(core::vector3df(0,yaw,0));
   t=m*t;

   return t.getRotationDegrees();
} 
...or how does your function look like ?
Vsk
Posts: 343
Joined: Thu Sep 27, 2007 4:43 pm

Post by Vsk »

Sorry about the my code kinda sucks.

Believe or not I have not use rotations yet :P. I am for example rotating my tank turret with angular velocity, same for cannon, etc.
But do you try this ?

matrix4 mat;
mat.setRotationDegrees(vector3df(0,rotationY,0));
body->setRotation(mat.getRotationDegrees());

I just tried it and it works in irrlicht 360 without problem.
In irrnewt becasue you have friction you have to deal with what happend if you try to rotate a body with other forces, like gravitiy, friction, etc.

So in irrnewt I try to do the same and didn¡'t work (it rotates but slides becase other forces).
So if you wanto to rotate a body you shold freeze it and then unfreeze.
Or other kind of solution that don't affect the body with forces (at least friction) while rotating it. This will work.

I hope it help you.
By the way, good skeletal animation, but I am having problem with instaliling acky extansion so I have couldn't put it in my proyect.
xray
Posts: 231
Joined: Fri Feb 02, 2007 1:06 pm
Location: Germany, Munich
Contact:

Post by xray »

Thank you, now I understand the whole rotation thing.

Towards the skeleton animation system. I updated it for use with Irrlicht 1.4 so you dont need Acki's IrrExtension.

regards
Donner
Posts: 87
Joined: Fri May 18, 2007 11:27 am

Post by Donner »

Well, I didn't understand it really...

My problem is, that I dont rotate the body, i just call the irrnewt-function "CarBody->turnRight()" - should I change the IrrNewt code or should I change my code?

Thanks a lot

D.
Vsk
Posts: 343
Joined: Thu Sep 27, 2007 4:43 pm

Post by Vsk »

The turnRight function only moves the steer angle for the front wheels.
Take a look at the implementation of this function on the car file.
But I don't undertand why have you problem with this if this not use any kind of angle, it only turns the wheel and icrement angle (transparent to you) and because the MAX-STEERANGLE don't let the wheel turn more than 90 degrees (if I remember correctly).
What do you in fact want to do?

Turn the car?, turn the wheel?, or something else?
Donner
Posts: 87
Joined: Fri May 18, 2007 11:27 am

Post by Donner »

I want to create a third person cam following the car - therefor I need the Car-Rotation. So I cant use the values I get from "CarBody->getRotation()", because the problem i described in the first post of this thread...
Vsk
Posts: 343
Joined: Thu Sep 27, 2007 4:43 pm

Post by Vsk »

Oh, did you try made de camera son of the car?.
That follows you car without a problem.
Donner
Posts: 87
Joined: Fri May 18, 2007 11:27 am

Post by Donner »

Yes, i tried it, but then it's very stiff and the cam turns also with the car's x- and z-axis.

Is there a possibility to convert the Rotation I get from "CarBody->getRotation()" to a value I can use?

Thanks a lot!
D.
Vsk
Posts: 343
Joined: Thu Sep 27, 2007 4:43 pm

Post by Vsk »

Try this or something like this.
matrix4 mat;
mat.setRotationDegrees(car->getRotationBody());
body->setRotation(mat.getRotationDegrees());
(But I think it will do the same that if camera will be a child of car).

What is exactly what you want to do?

Do you want to change the target of the camera????
This MUST BE DONE with camera-SetTarget(target).

You can create the targe vector in this way:

vector3df target = vector3df(0,0,1) //THIS ASSUME that you begin with the face of your car facing z axis +.

Then if you want to move the camera target for 45 degrees left of car
you will do something like this:

matrix4 mat;
mat.setRotationDegrees(car->getRotationBody()+vector3df(0,-45 ,0);

mat.rotateVect(target);
camera->setTarget(target);

Please correctme someone if this doesn't work, in particular de part in wich I set the rotationDegrees to the matrix (this one I have doubts):
Post Reply