how to rotate the cylinder

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
lizhigang34
Posts: 49
Joined: Sun Dec 21, 2008 4:11 pm

how to rotate the cylinder

Post by lizhigang34 »

I want the cylinder to rotate automatically..
How should I do? Please give me some code.
the cylinder is IAnimatedMeshSceneNode.
frostysnowman
Posts: 83
Joined: Fri Apr 11, 2008 3:06 am
Location: Beaverton, Oregon, US

Post by frostysnowman »

in your irrlicht loop:

Code: Select all

cylinderNode->setRotation(cylinderNode->getRotation() + irr::core::vector3df(0, .1f, 0));
(if you want to rotate it on it's y axis)
Last edited by frostysnowman on Wed Feb 04, 2009 5:35 am, edited 1 time in total.
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Post by Ion Dune »

Please refer to the tutorials (numbers 3, 11, and 13 all do what you ask) and the docs before asking questions - it will save both your and our time :D .
lizhigang34
Posts: 49
Joined: Sun Dec 21, 2008 4:11 pm

Post by lizhigang34 »

frostysnowman wrote:in your irrlicht loop:

Code: Select all

cylinderNode->setRotation(cylinderNode->getRotation() + irr::core::vector3df(0, .1f, 0));
(if you want to rotate it on it's y axis)
I want to rotate it on it's middle axis,and it's middle aixs will change,the middle axis is not parallel the X or Y axis,it's a rand vector,how should I do??
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

The code shown above will rotate the cylinder around its own Y axis, rather than the world Y axis. It should do what you want.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
lizhigang34
Posts: 49
Joined: Sun Dec 21, 2008 4:11 pm

Post by lizhigang34 »

In my program,the cylinder has a position,the position will change.But,no matter the cylinder how to change position,it will be cross vector (0,0,0).
Now,I want to the cylinder rotate around vector (postion - vector(0,0,0)).
Can you get my thinking?My English is poor. :cry:
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

I don't understand at all. The result of position - vector3df(0, 0, 0) is position. Do you want to rotate the cylinder around the vector that represents the direction from the origin of the coordinate system?
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

lizhigang34 wrote:Can you get my thinking?
No, sorry. How about you post your code?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
lizhigang34
Posts: 49
Joined: Sun Dec 21, 2008 4:11 pm

Post by lizhigang34 »

vitek wrote:I don't understand at all. The result of position - vector3df(0, 0, 0) is position. Do you want to rotate the cylinder around the vector that represents the direction from the origin of the coordinate system?
No,I just want rotate the cylinder around it's middle axis.this axis is vector(vector3df(position) - vector3df(0,0,0)),because the cylinder cross the point(0,0,0) all the time.the cylinder is IAnimatedMeshSceneNode which I load from a file.
lizhigang34
Posts: 49
Joined: Sun Dec 21, 2008 4:11 pm

Post by lizhigang34 »

Did I express myself unclearly??
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Yes. Repeating yourself doesn't help either. Describing what you mean in a slightly better way (perhaps with graphics or ascii art) would be more useful.

As I understand it, you have a cylinder. See below...

Code: Select all


     Y axis
     |
    _|_
   / | \
  |\___/|
  |  .  |
  |  .  |   Z axis
  |  .  |  /
  |  .  | /
  |  .  |/
  |  .  |
  |  .  |
  |  .  |_______ X axis
   \___/
     |
     |
You want to rotate the cylinder along the dotted line. In other words, you want to rotate the cylinder on the axis that runs the length of the cylinder, which, in this case is the Y axis. This is as simple as the code posted previously.

If you want the cylinder to turn in other directions, all while it is spinning, you would handle those other rotations using a parent scene node. At least that is the simplest way to do it.

Travis
Post Reply