Rendered XNA model not matching ConvexHull position [Solved]
Posted: Mon Dec 19, 2011 4:39 am
The problem:
the following code creates a correctly shaped convexhull but the collisions were off. ConvexHull and Mobilemesh (others?) find their own center of mass not the same as the center 3DSmax used for export even after aligning the model.
Using the ModelDrawer this was verified.
Model model = Content.Load<Model>("myModel");
Vector3[] vertices;
int []indices;
BEPUphysics.DataStructures.TriangleMesh.GetVerticesAndIndicesFromModel(model, out vertices, out indices);
Entity entity = physEntity = new ConvexHull(vertices);
To Fix:
Add the following line after after creating the entity.
physEntity.CollisionInformation.LocalPosition = physEntity.Position;
There were quite a few post with people having similar issues but I never found a direct way to fix it...
Hopefully this will help someone who needs it.
the following code creates a correctly shaped convexhull but the collisions were off. ConvexHull and Mobilemesh (others?) find their own center of mass not the same as the center 3DSmax used for export even after aligning the model.
Using the ModelDrawer this was verified.
Model model = Content.Load<Model>("myModel");
Vector3[] vertices;
int []indices;
BEPUphysics.DataStructures.TriangleMesh.GetVerticesAndIndicesFromModel(model, out vertices, out indices);
Entity entity = physEntity = new ConvexHull(vertices);
To Fix:
Add the following line after after creating the entity.
physEntity.CollisionInformation.LocalPosition = physEntity.Position;
There were quite a few post with people having similar issues but I never found a direct way to fix it...
Hopefully this will help someone who needs it.