protected override void LoadContent() { model = Game.Content.Load <Model>("convexhull"); if (cvhs == null) { List <JVector> jvecs = new List <JVector>(); List <TriangleVertexIndices> indices = new List <TriangleVertexIndices>(); ExtractData(jvecs, indices, model); int[] convexHullIndices = JConvexHull.Build(jvecs, JConvexHull.Approximation.Level6); List <JVector> hullPoints = new List <JVector>(); for (int i = 0; i < convexHullIndices.Length; i++) { hullPoints.Add(jvecs[convexHullIndices[i]]); } cvhs = new ConvexHullShape(hullPoints); } body = new RigidBody(cvhs); body.Tag = BodyTag.DontDrawMe; }
public static ConvexHullShape BuildConvexHullShape(Model model, Vector3 scale) { List <JVector> jvecs = new List <JVector>(); List <TriangleVertexIndices> indices = new List <TriangleVertexIndices>(); ExtractData(jvecs, indices, model); int[] convexHullIndices = JConvexHull.Build(jvecs, JConvexHull.Approximation.Level6); List <JVector> hullPoints = new List <JVector>(); for (int i = 0; i < convexHullIndices.Length; i++) { hullPoints.Add(Helper.ToJitterVector(Helper.ToXNAVector(jvecs[convexHullIndices[i]]) * scale)); } return(new ConvexHullShape(hullPoints)); }