Collision Position Bug?

Nox587

08-08-2007 15:04:52

I am using the latest Ogrenewt from CVS, and I did a lot of searching around to find out what was causing my problem.

I was creating a cylinder with the cylinder collision primitive, and I supplied a position and orientation as parameters to the constructor. I then create a body, attach a node, and call the setPositionOrientation method on the body.

This for some reason was causing my collision to be in a different position then my node/entity. I tried several things to correct this, and in the end the only thing that worked for me was removing the position and orientation parameters in the constructor of the cylinder primitive.

The position and orientation values I used for the constructor are the same as the ones provided to the setPositionOrientaiton method, but for some reason supplying them to the constructor doesn't seem to work correctly. It also seems that the orientation of the cylinder was off, as one half of it would "float" off the box it was coliding with (this was with a force of 9.8m/s down the y axis).

I noticed there is a method being called in the constructor converting the position and orientation into a matrix, perhaps there is a bug in this method?

walaber

08-08-2007 21:00:55

passing a quaternion / position to the constructor for the Cylinder object offsets that collision shape from it's local origin. you only need to pass something there if you need to apply a LOCAL transformation to the object, to get it to line up with your object.

for example, in Newton, a Cylinder defaults to having its HEIGHT aligned along the local X axis, and the radius on the Y and Z axis'. if you want your Cylinder "standing up" by default, you need to pass rotation around the Z axis of 90 degrees.

then, after you make your OgreNewt:Body object, set the position and orientation of the BODY.

please reply if that does not make sense.

Nox587

09-08-2007 06:23:54

I think I understand what you are saying. Does this mean if I set the position and orientation in the collision constructor, and then later set the position and orientation of the body, the collision position and orientation will be offset from the node/entity attached to the body?

Example:

...
m_Collision = new OgreNewt::CollisionPrimitives::Cylinder(m_World, radius, height, orientation, position);

m_Body = new OgreNewt::Body(m_World, m_Collision);
m_Body->attachToNode(m_Node);
m_Body->setPositionOrientation(position, orientation);
delete m_Collision;

...