how to rotate the cylinder
-
lizhigang34
- Posts: 49
- Joined: Sun Dec 21, 2008 4:11 pm
how to rotate the cylinder
I want the cylinder to rotate automatically..
How should I do? Please give me some code.
the cylinder is IAnimatedMeshSceneNode.
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
in your irrlicht loop:
(if you want to rotate it on it's y axis)
Code: Select all
cylinderNode->setRotation(cylinderNode->getRotation() + irr::core::vector3df(0, .1f, 0));
Last edited by frostysnowman on Wed Feb 04, 2009 5:35 am, edited 1 time in total.
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
.
-
lizhigang34
- Posts: 49
- Joined: Sun Dec 21, 2008 4:11 pm
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??frostysnowman wrote:in your irrlicht loop:
(if you want to rotate it on it's y axis)Code: Select all
cylinderNode->setRotation(cylinderNode->getRotation() + irr::core::vector3df(0, .1f, 0));
-
rogerborg
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
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
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
-
rogerborg
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
No, sorry. How about you post your code?lizhigang34 wrote:Can you get my thinking?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
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
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.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?
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...
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
As I understand it, you have a cylinder. See below...
Code: Select all
Y axis
|
_|_
/ | \
|\___/|
| . |
| . | Z axis
| . | /
| . | /
| . |/
| . |
| . |
| . |_______ X axis
\___/
|
|
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