Rotation and MoveEntity
Blitz3D Forums/Blitz3D Beginners Area/Rotation and MoveEntity
| ||
I have a soccer ball mesh that I want to rotate so that it appears to roll. If I use RotateEntity the following MoveEntity command sends it in the wrong direction because it's orientation has changed. How can I make the ball appear to roll without changing it's orientation? |
| ||
Basicly you should work with a pivot ball_piv=createpivot() ball=loadmesh("ball.3ds",ball_piv) now you can rotate the ball locally and move the pivot globally. I think there's already some smart rolling ball code in the archives. |
| ||
Ah, pivots. I've managed to avoid them thus far so I have no idea how they work. Are there any good tutorials that will help me understand them? |
| ||
There isn't much to understand. They are like a mesh with zero triangles. They are mostly useful when used in parenting systems, like in my example. So it's more about understanding parent-child relations and hierarchies, as well as the optional "parent" and "global" parameter of many Blitz commands. |
| ||
You can use TranslateEntity to move the ball around, regardless of it's orientation. |
| ||
You use TranslateEntity or MoveEntity on the pivot. Since you parented the ball to the pivot, the ball moves, but does not rotate. Then you use TurnEntity (I prefer it to RotateEntity) to make the ball "roll." |
| ||
Justin case you wanted to know... theres some superb roll a ball across the floor in any direction code in the archives somewhere. IPete2. |
| ||
Yes i found that and was very impressed. I'm currently in the process of re-writing my program. :) |
| ||
Using a pivot gives your mesh a frame of reference around which to rotate. That is to say, motions of a mesh that is a child of the pivot-parent, are moved/turned in relation to where the pivot is. To move the mesh through the 3d world, you simply move the pivot, and all child meshes go with the parent (ie the pivot in this example). |