I'm trying to build a convex hull using the data from a ModelMeshPart. I am taking the Model and for each part of the Model, generate a convex hull. So far, i have done this:
Code: Select all
public ConvexHullShape getConvexHull()
{
if (this.convex_hull == null)
{
List<Vector3> verts = new List<Vector3>(1000);
foreach (var i in this.renderable_mesh.MeshParts)
{
Vector3[] lulz;
lulz = new Vector3[i.NumVertices];
i.VertexBuffer.GetData<Vector3>(lulz, i.VertexOffset, i.NumVertices);
foreach (var point in lulz)
{
verts.Add(point);
}
}
Vector3 computed_origin;
this.convex_hull = new ConvexHullShape(verts, out computed_origin);
}
return this.convex_hull;
}
This causes a problem when I try to use the ConvexHull on a vehicle, as it crushes all the suspension on one side and the vehicle tips over.