public ConvexHullColliderShape(IReadOnlyList <Vector3> points, IEnumerable <uint> indices) { Type = ColliderShapeTypes.ConvexHull; Is2D = false; InternalShape = new BulletSharp.ConvexHullShape(points); if (!PhysicsEngine.Singleton.CreateDebugPrimitives) { return; } var verts = new VertexPositionNormalTexture[points.Count]; for (var i = 0; i < points.Count; i++) { verts[i].Position = points[i]; verts[i].TextureCoordinate = Vector2.Zero; verts[i].Normal = Vector3.Zero; } var intIndices = indices.Select(x => (int)x).ToArray(); var meshData = new GeometricMeshData <VertexPositionNormalTexture>(verts, intIndices, false); DebugPrimitive = new GeometricPrimitive(PhysicsEngine.Singleton.DebugGraphicsDevice, meshData); DebugPrimitiveScaling = Matrix.Scaling(new Vector3(1, 1, 1) * 1.01f); }
public ConvexHullColliderShape(IReadOnlyList <Vector3> points, IReadOnlyList <uint> indices, Vector3 scaling) { Type = ColliderShapeTypes.ConvexHull; Is2D = false; InternalShape = new BulletSharp.ConvexHullShape(points); DebugPrimitiveMatrix = Matrix.Scaling(new Vector3(1, 1, 1) * 1.01f); Scaling = scaling; pointsList = points; indicesList = indices; }
public ConvexHullColliderShape(IReadOnlyList<Vector3> points, IReadOnlyList<uint> indices, Vector3 scaling) { Type = ColliderShapeTypes.ConvexHull; Is2D = false; InternalShape = new BulletSharp.ConvexHullShape(points); DebugPrimitiveMatrix = Matrix.Scaling(new Vector3(1, 1, 1) * 1.01f); Scaling = scaling; pointsList = points; indicesList = indices; }
public ConvexHullColliderShape(IReadOnlyList <Vector3> points, IReadOnlyList <uint> indices, Vector3 scaling) { Type = ColliderShapeTypes.ConvexHull; Is2D = false; cachedScaling = scaling; pointsList = points; indicesList = indices; InternalShape = new BulletSharp.ConvexHullShape(PointsAsBullet()) { LocalScaling = cachedScaling, }; DebugPrimitiveMatrix = Matrix.Scaling(Vector3.One * DebugScaling); }
/// <summary> /// Create the collision convext hull. /// </summary> /// <param name="points">Points to create convex hull from.</param> public CollisionConvexHull(Vector3[] points) { // convert to bullet vectors and create the shape BulletSharp.Math.Vector3[] bvectors = ToBullet.Vectors(points); _shape = new BulletSharp.ConvexHullShape(bvectors); }