Rotation matrix from Geometry is not matching Rotation matrix from Body

20 views
Skip to first unread message

jfelrod1960

unread,
Jul 5, 2011, 8:57:35 AM7/5/11
to jinngine
I'm using the following code ...

// Create the hovercraft racer's main body.
final Quaternion rotation = Quaternion.rotation(Math.PI * 0.5,
Vector3.j());
final Geometry hovercraftGeometry = new Box("hovercraft", xMax - xMin,
yMax - yMin, zMax - zMin);
final Body hovercraftBody = new Body(hovercraftGeometry.getName());
hovercraftBody.addGeometry(rotation.toRotationMatrix3(new Matrix3()),
initialPosition, hovercraftGeometry);
addGeometry(hovercraftGeometry);
addBody(hovercraftBody);

To determine the parameters for the Box geometry, I'm reading a list
of vertices to find the bounds of the hovercraft model. Then I create
the hovercraft body with just the name of the geometry and afterwards
add the geometry.

The two last methods are used for a superclass called PhysicsObject.
It contains a list of geometries, constraints and bodies.

Once the PhysicsObject is constructed, the method
PhysicsObject.insertIntoPhysicsWorld(physicsWorld) is called to add
the geometries, constraints and bodies into the scene.

Thanks
Jeff

Morten Silcowitz

unread,
Jul 5, 2011, 5:18:59 PM7/5/11
to jinn...@googlegroups.com
Hi Jeff

I may have scanned somewhat briefly through your code, but the idea
with Scene.addGeometry is that the geometries you add, stay in the
same world position as you added them with, no matter how many you
add. So each time you add, both body and local geometry transform
changes, while geometry world space transforms stay the same.

When geometries are added to the same body, it will change its
position, but not its rotation. So if you add a geometry that has some
rotation, then the geometry world transform and body world transform
will surely be different.

Do not add geometry using methods in Body, only use methods defined in
Scene. Only one call to Scene.addGeoemtry per geometry instance should
be made.

Let me know if this helps

Morten

Jeffrey Elrod

unread,
Jul 6, 2011, 3:09:36 PM7/6/11
to jinn...@googlegroups.com
Hi Morten,
 
I made the changes you suggested.  The 3D rendering engine I'm using contains a spatial controller class that I can use to render the rotation and position of the spatial that represents the correspoding geometry in jinngine.  I was using Body to get the position and rotation.  The position was being updated, but not the rotation.  I ended up using the geometry's world transform to update the spatial's position and rotation.  That worked fine.  The funny thing is that when I created the ragdoll using the parameters from your RagdollExample, using the body's position and rotation updated the corresponding spatials just fine.  The only difference in my hovercraft example and the ragdoll example is that joints are being used in ragdoll example while the hovercraft contains no joints.  Could the joint constraints in jinngine be forcing the position and rotation in body to be updated?
 
Anyway, thanks for you help! :)
Jeff

Reply all
Reply to author
Forward
0 new messages