Aligning a body object to a mesh object [Solved]

Scorch

05-03-2007 01:18:27

This is probably an OgreNewt beginner question, but I am having problems aligning my body objects with my visible mesh's.

I've tried several things over the past two days, and its time to ask for help I think.

Attempt 1: Capsule
Create a ChildSceneNode
Attach Entity to the node
Create a capsule roughly the size of my model.
create a body using said capsule.
Set position, orientation, masMatrix, standardForceCallback of body
Attach to the same node my entity is attached to.

Problem: This had the problem where my capsule was on its side. When I set its orientation to 90 degrees, it moved the mesh with it. so the my capsule was upright, but my mesh was on its side.

Attempt 2: Elipsoid
Create a ChildSceneNode
Attach Entity to the node
create an elipsoid using the bounding box size of my mesh
create a body object using the elipsoid
Set position, orientation, masMatrix, standardForceCallback of body
Attach to the same node my entity is attached to.

Problem:
The body is not centered on the bottom of my mesh. I tried using different values of initial position when I called setPositionOrientation() but this moved my mesh by the same distance.

Attempt 3: Elipsoid + 2 nodes
Create a childSceneNode.
Create a second childSceneNode (child of the first).
Attach mesh to the second node.
create an elipsoid using the bounding box size of my mesh
create a body object using the elipsoid
Set position, orientation, masMatrix, standardForceCallback of body
Attach to first (parent) node.

Problem:
With this method I can allign the mesh with my body, but now when the body moves in effect to gravity, it leaves my mesh behind! ... When a body moves the parent node, shouldn't the child node follow?


Context:
The mesh I am using is a poorly made female human. The scale is way to big but I can fix that later.

Suggestions?
Is there a "Right" way to do this?


/Edit
Attempt 4:
I tried Attempt 2 but this time I moved the node after setting everything up. I found another post that said moving the node shouldn't move the body. But in my case moving the node moves both the body and the mesh ...

nikhil

05-03-2007 05:04:07

a few pics illustrating your problem will be helpful..

anyways, when you say
Create a capsule roughly the size of my model.
You know that there are parameters while creating the capsule collision primitive to offset/orient the collision shape. Probably you need to take a look at them.

And for every physics object in my application. I do-
1)create the node
2)attach the entity
3)DO NOT USE SETPOSTION OR TRANSLATE to set it's initial position
4)Create the collision object and use the position and orientation parameters to offset it accordingly, particularly helpful in case of compound collisions
5)create a body out of the collision object
6)now use the setPositionOrientation to set it's initial position and orientation with in my application.

Hope this helps..

nik

Scorch

05-03-2007 06:21:25

Went back and looked agian:

4)Create the collision object and use the position and orientation parameters to offset it accordingly, particularly helpful in case of compound collisions

I didn't see those in the constructor of the collision object! I am putting some values in there now, and it is moving the object around in relation to my mesh Thanks!

I've got to figure out how all the cordinates relate on creating joints and such, but I'll figure that out, or that at the very least will be an another issue.

Many thanks!

[Solved]