Question about rotations

Hi all i have a car model and now im trying to rotate the wheels like in flagrush tutorial 9

However in the bike model the wheels are a seperate node and therefor can be rotated around its own axis



the bike model from the tutorials

Transform: (0.0, 0.0, 0.0)[0.0, 0.0, 0.0]{0.0025}
Children: Node/2  Node/body  Node/axleback01  Node/Object11  Node/backwheel  Node/glass  Node/temp  Node/frontwheel  AxisRods/ 




my car model

Children: JointMesh/rlwheel  JointMesh/frwheel  JointMesh/rrwheel  JointMesh/body  JointMesh/flwheel 



if i try to rotate the wheels now they will in fact rotate around the entire car because the pivot point is in the center of the car and not the center of each wheel

How can i change the pivot point to the center of each wheel ?  right now im using this to rotate them

   rotQuat.fromAngleAxis(angle, wheelAxis);
         flwheel.getLocalRotation().multLocal(rotQuat);
         frwheel.setLocalRotation(flwheel.getLocalRotation());
         rlwheel.setLocalRotation(flwheel.getLocalRotation());
         rrwheel.setLocalRotation(flwheel.getLocalRotation());



Thanks

If you are making the model in the modeling tool, you generally make sure that the transform origin for each part is centered at the mesh data. In Blender3D, it's the button "Center New" under object editing options.

If you cannot open the model in a modeling tool, you may have to write special code which will translate the verticles of the model by the negative translation of the model bound in object space. This in most cases should give you the same functionality that you would get by doing it in a modeling tool.

Momoko_Fan said:

you may have to write special code which will translate the verticles of the model by the negative translation of the model bound in object space.


Im not sure i understand what you mean by that, i looked at the localtranslation and the worldtranslation but both are 0.

Right now im trying to open it in blender and see what i can do there but i have never worked with blender yet so that might take a while  :-o

I did open the file in a different modeling tool and i made it look like the bike.3ds by turning off grouping, this gave it a translation inside the tool but in jme it was still 0  :|

If you build a quad on the z plane (simple example) in a modeling tool and set the coordinates at (10, 10), (10, 20), (20,20) and (20,10)… jME will read that in and give it a local translation of 0,0, but visually, it will LOOK centered at 15,15.  By having your modeling tool center it before exporting (in this case, the coords would be -5,-5  -5,5  5,5 and 5,-5) you make the local translation and the "visual" translation the same.

The local/world translation does not really represent the actual model position if it's not centered… That's why you're using the bounding volume position and not the spatial translation.

Example code:


Spatial model = ...
BoundingVolume b = model.getWorldBound();
Vector3f center = b.getCenter();
// go through each trimesh under 'model', translate the verticles by -center..