Collision box not aligning up correctly
Posted: Fri Jan 27, 2012 7:36 pm
All,
In my project I have simple cubed shaped models. For some reason the BEPU collision box is about 50% offest from the model position on one of the axis. I thought I could fix this by creating a simple offset for my scene entities in my update method, but can't seem to get it to work correctly. I did see some posts related to this but I have not been able to apply any of the solutions to my project. Here is the current method for updating my scene entities. If anyone has any suggestings I would greatly apprecate it!
Vector3 scale = Vector3.Zero;
Quaternion rotate = Quaternion.Identity;
Vector3 position = Vector3.Zero;
sceneObject.World.Decompose(out scale, out rotate, out position);
Vector3 Offset = new Vector3(0, 25, 0);
Matrix worldMatrix = Matrix.Identity;
Vector3 normalizedUp = Vector3.Normalize(box.CollisionInformation.WorldTransform.Matrix.Up);
worldMatrix = Matrix.CreateScale(scale) * Matrix.CreateFromQuaternion(obj.BufferedStates.InterpolatedStates.Orientation) *
Matrix.CreateTranslation((obj.BufferedStates.InterpolatedStates.Position - (normalizedUp * box.HalfHeight)) + Offset);
sceneObject.SetWorldAndWorldToObject(worldMatrix, Matrix.Invert(worldMatrix));
In my project I have simple cubed shaped models. For some reason the BEPU collision box is about 50% offest from the model position on one of the axis. I thought I could fix this by creating a simple offset for my scene entities in my update method, but can't seem to get it to work correctly. I did see some posts related to this but I have not been able to apply any of the solutions to my project. Here is the current method for updating my scene entities. If anyone has any suggestings I would greatly apprecate it!
Vector3 scale = Vector3.Zero;
Quaternion rotate = Quaternion.Identity;
Vector3 position = Vector3.Zero;
sceneObject.World.Decompose(out scale, out rotate, out position);
Vector3 Offset = new Vector3(0, 25, 0);
Matrix worldMatrix = Matrix.Identity;
Vector3 normalizedUp = Vector3.Normalize(box.CollisionInformation.WorldTransform.Matrix.Up);
worldMatrix = Matrix.CreateScale(scale) * Matrix.CreateFromQuaternion(obj.BufferedStates.InterpolatedStates.Orientation) *
Matrix.CreateTranslation((obj.BufferedStates.InterpolatedStates.Position - (normalizedUp * box.HalfHeight)) + Offset);
sceneObject.SetWorldAndWorldToObject(worldMatrix, Matrix.Invert(worldMatrix));