How would I rotate scene node around local axis (not world ones like rotateYZBy does)?
So, for example, that if I want to rotate around target up and down no matter at what side of target I am I always rotate around X axis.
Of course I would always have to turn to face the target so that my Y axis points towards the target.
Rotate scene node around local axis
-
- Posts: 53
- Joined: Sun Aug 31, 2008 3:16 pm
- Location: Split, Croatia
Rotate scene node around local axis
What now??? =_=''
You have to use matrices or quaternions.
You can find some useful bits here:
Free Flight (space flight) functions
and here:
Turn to target in 3D
You can find some useful bits here:
Free Flight (space flight) functions
and here:
Turn to target in 3D
-
- Posts: 53
- Joined: Sun Aug 31, 2008 3:16 pm
- Location: Split, Croatia
I successfully circle around with my scene node (cube object) but it always circle around (0, 0, 0).
What do I have to do to make it circle around some specified point like (100, 100, 100)?
My current code
What do I have to do to make it circle around some specified point like (100, 100, 100)?
My current code
Code: Select all
core::vector3df my_rotation4 = my_cube4->getPosition();
core::matrix4 n;
if(receiver.IsKeyDown(irr::KEY_KEY_W))
n.setRotationDegrees(core::vector3df(0.1, 0, 0));
else if(receiver.IsKeyDown(irr::KEY_KEY_S))
n.setRotationDegrees(core::vector3df(-0.1, 0, 0));
if(receiver.IsKeyDown(irr::KEY_KEY_A))
n.setRotationDegrees(core::vector3df(0, -0.2, 0));
else if(receiver.IsKeyDown(irr::KEY_KEY_D))
n.setRotationDegrees(core::vector3df(0, 0.2, 0));
n.rotateVect(my_rotation4);
my_cube4->setPosition(my_rotation4);
What now??? =_=''
You confuse position and rotation. Lineshould tell you that something is just not right.
And there is also distance to origin which you need to take in to account somehow.
I made tutorial which shows two methods to turn node around origin: Turn around origin in 3D
I hope its what you are looking for.
Code: Select all
my_rotation4 = my_cube4->getPosition();
You use no origin in your calculation, that is why its circling around 0,0,0.but it always circle around (0, 0, 0)
And there is also distance to origin which you need to take in to account somehow.
I made tutorial which shows two methods to turn node around origin: Turn around origin in 3D
I hope its what you are looking for.
-
- Posts: 53
- Joined: Sun Aug 31, 2008 3:16 pm
- Location: Split, Croatia
You are my savior. Method rotateAround1 is exactly what I need.arras wrote:You use no origin in your calculation, that is why its circling around 0,0,0.but it always circle around (0, 0, 0)
And there is also distance to origin which you need to take in to account somehow.
I made tutorial which shows two methods to turn node around origin: Turn around origin in 3D
I hope its what you are looking for.
Thank you once more and please comment the code more extensively and make that thread into a tutorial about rotation because it rules and I found a lot of questions on that topic.
What now??? =_=''