public static void CreateShapes(Demo demo, PhysicsScene scene) { ShapePrimitive shapePrimitive = null; Shape shape = null; Vector3[] convexTab1 = new Vector3[16]; convexTab1[0] = new Vector3(-0.5f, 1.0f, -1.0f); convexTab1[1] = new Vector3(-1.0f, 1.0f, -0.5f); convexTab1[2] = new Vector3(-1.0f, 1.0f, 0.5f); convexTab1[3] = new Vector3(-0.5f, 1.0f, 1.0f); convexTab1[4] = new Vector3(0.5f, 1.0f, 1.0f); convexTab1[5] = new Vector3(1.0f, 1.0f, 0.5f); convexTab1[6] = new Vector3(1.0f, 1.0f, -0.5f); convexTab1[7] = new Vector3(0.5f, 1.0f, -1.0f); convexTab1[8] = new Vector3(-0.25f, -1.0f, -0.5f); convexTab1[9] = new Vector3(-0.5f, -1.0f, -0.25f); convexTab1[10] = new Vector3(-0.5f, -1.0f, 0.25f); convexTab1[11] = new Vector3(-0.25f, -1.0f, 0.5f); convexTab1[12] = new Vector3(0.25f, -1.0f, 0.5f); convexTab1[13] = new Vector3(0.5f, -1.0f, 0.25f); convexTab1[14] = new Vector3(0.5f, -1.0f, -0.25f); convexTab1[15] = new Vector3(0.25f, -1.0f, -0.5f); shapePrimitive = scene.Factory.ShapePrimitiveManager.Create("Lamp1Convex"); shapePrimitive.CreateConvex(convexTab1); shape = scene.Factory.ShapeManager.Create("Lamp1Convex"); shape.Set(shapePrimitive, Matrix4.Identity, 0.0f); shape.CreateMesh(0.0f); if (!demo.Meshes.ContainsKey("Lamp1Convex")) { demo.Meshes.Add("Lamp1Convex", new DemoMesh(demo, shape, demo.Textures["Default"], Vector2.One, false, false, false, false, true, CullFaceMode.Back, false, false)); } }
public static void CreateShapes(Demo demo, PhysicsScene scene) { ShapePrimitive shapePrimitive = null; Shape shape = null; Vector3[] convexTab = new Vector3[8]; convexTab[0] = new Vector3(-1.0f, -1.0f, 1.0f); convexTab[1] = new Vector3(-1.0f, 1.0f, 1.0f); convexTab[2] = new Vector3(1.0f, 0.752f, 1.0f); convexTab[3] = new Vector3(1.0f, -0.752f, 1.0f); convexTab[4] = new Vector3(-1.0f, -1.0f, -1.0f); convexTab[5] = new Vector3(-1.0f, 1.0f, -1.0f); convexTab[6] = new Vector3(1.0f, 0.752f, -1.0f); convexTab[7] = new Vector3(1.0f, -0.752f, -1.0f); shapePrimitive = scene.Factory.ShapePrimitiveManager.Create("Box2Convex1"); shapePrimitive.CreateConvex(convexTab); shape = scene.Factory.ShapeManager.Create("Box2Convex1"); shape.Set(shapePrimitive, Matrix4.Identity, 0.0f); shape.CreateMesh(0.0f); if (!demo.Meshes.ContainsKey("Box2Convex1")) { demo.Meshes.Add("Box2Convex1", new DemoMesh(demo, shape, demo.Textures["Default"], Vector2.One, false, false, false, false, false, CullFaceMode.Back, false, false)); } }
public static void CreateShapes(Demo demo, PhysicsScene scene) { TriangleMesh triangleMesh = null; ShapePrimitive shapePrimitive = null; Shape shape = null; triangleMesh = scene.Factory.TriangleMeshManager.Create("TorusMesh1"); triangleMesh.CreateTorusY(10, 15, 3.0f, 1.0f); if (!demo.Meshes.ContainsKey("TorusMesh1")) { demo.Meshes.Add("TorusMesh1", new DemoMesh(demo, triangleMesh, demo.Textures["Default"], Vector2.One, true, true, true, false, true, CullFaceMode.Back, false, false)); } scene.Factory.CreatePhysicsObjectsFromConcave("ConcaveTorus1", triangleMesh); scene.Factory.CreatePhysicsObjectsFromConcave("ConcaveTorus2", triangleMesh); shapePrimitive = scene.Factory.ShapePrimitiveManager.Create("ConvexTorus1"); shapePrimitive.CreateConvexHull(triangleMesh); shape = scene.Factory.ShapeManager.Create("ConvexTorus1"); shape.Set(shapePrimitive, Matrix4.Identity, 0.0f); triangleMesh = scene.Factory.TriangleMeshManager.Create("UserMesh1"); TriangleMeshRegion r01 = triangleMesh.TriangleMeshRegionManager.Create("r01"); Vertex v1 = r01.VertexManager.Create("v1"); v1.SetPosition(-1.0f, -1.0f, -1.0f); Vertex v2 = r01.VertexManager.Create("v2"); v2.SetPosition(0.0f, -1.0f, 1.0f); Vertex v3 = r01.VertexManager.Create("v3"); v3.SetPosition(1.0f, -1.0f, -1.0f); Vertex v4 = r01.VertexManager.Create("v4"); v4.SetPosition(0.0f, 1.0f, 0.0f); Triangle t01 = r01.TriangleManager.Create("t01"); t01.Index1 = 0; t01.Index2 = 1; t01.Index3 = 3; Triangle t02 = r01.TriangleManager.Create("t02"); t02.Index1 = 0; t02.Index2 = 3; t02.Index3 = 2; Triangle t03 = r01.TriangleManager.Create("t03"); t03.Index1 = 2; t03.Index2 = 3; t03.Index3 = 1; Triangle t04 = r01.TriangleManager.Create("t04"); t04.Index1 = 0; t04.Index2 = 2; t04.Index3 = 1; triangleMesh.Update(true, true); if (!demo.Meshes.ContainsKey("UserMesh1")) { demo.Meshes.Add("UserMesh1", new DemoMesh(demo, triangleMesh, demo.Textures["Default"], Vector2.One, false, false, true, false, false, CullFaceMode.Back, false, false)); } shapePrimitive = scene.Factory.ShapePrimitiveManager.Create("UserMesh1"); shapePrimitive.CreateConvex(triangleMesh); shape = scene.Factory.ShapeManager.Create("UserMesh1"); shape.Set(shapePrimitive, Matrix4.Identity, 0.0f); shapePrimitive = scene.Factory.ShapePrimitiveManager.Create("Cylinder2RY"); shapePrimitive.CreateCylinder2RY(2.0f, 2.0f, 1.0f); shape = scene.Factory.ShapeManager.Create("Cylinder2RY"); shape.Set(shapePrimitive, Matrix4.Identity, 0.0f); triangleMesh = scene.Factory.TriangleMeshManager.Create("Cylinder2RY"); triangleMesh.CreateCylinder2RY(1, 15, 2.0f, 2.0f, 1.0f); if (!demo.Meshes.ContainsKey("Cylinder2RY")) { demo.Meshes.Add("Cylinder2RY", new DemoMesh(demo, triangleMesh, demo.Textures["Default"], Vector2.One, true, true, true, false, true, CullFaceMode.Back, false, false)); } triangleMesh = scene.Factory.TriangleMeshManager.Create("TubeMesh1"); triangleMesh.CreateTubeY(1, 15, 2.0f, 1.0f, 0.5f, 1.0f, 0.5f); if (!demo.Meshes.ContainsKey("TubeMesh1")) { demo.Meshes.Add("TubeMesh1", new DemoMesh(demo, triangleMesh, demo.Textures["Default"], Vector2.One, true, true, true, false, true, CullFaceMode.Back, false, false)); } }
/// <summary> /// /// </summary> /// <remarks> /// For all of the shapes that has directions (e.g., Cylinder, Hemisphere), Y direction is /// used, so if you would like it to face other directions, use MataliObject.ShapeOriginalMatrix /// to orient them. /// /// For a cylinder with different bottom and top radius, IPhysicsObject.ShapeData are used. /// ShapeData[0] - bottom radius, ShapeData[1] - height, ShapeData[2] = top radius /// /// For Compound shape, an additional information can be set by using /// MataliObject.CompoundShape. /// /// For additional shape types such as Heightmap, Point, and so on, set Shape to ShapeType.Extra /// and define MataliObject.ExtraShape. /// </remarks> /// <param name="mataliPhysicsObj"></param> /// <param name="physObj"></param> private void SetShape(MataliPhysicsObject mataliPhysicsObj, IPhysicsObject physObj) { Vector3 boundingBox = Vector3.Zero; if (physObj.Model != null) { boundingBox = Vector3Helper.GetDimensions(physObj.Model.MinimumBoundingBox); } Vector3 size = Vector3.Zero; MataliObject mataliObj = null; if (physObj is MataliObject) { mataliObj = (MataliObject)physObj; } switch (physObj.Shape) { case ShapeType.Box: if (physObj.ShapeData.Count == 3) { size = new Vector3(physObj.ShapeData[0], physObj.ShapeData[1], physObj.ShapeData[2]); } else { size = boundingBox; } size /= 2; break; case ShapeType.Sphere: if (physObj.ShapeData.Count == 1) { size = new Vector3(physObj.ShapeData[0], 0, 0); } else { size = boundingBox / 2; } break; case ShapeType.Cone: case ShapeType.Cylinder: case ShapeType.Capsule: if (physObj.ShapeData.Count == 2) { size = new Vector3(physObj.ShapeData[0], physObj.ShapeData[1], physObj.ShapeData[0]); } else if (physObj.ShapeData.Count == 3) { size = new Vector3(physObj.ShapeData[0], physObj.ShapeData[1], physObj.ShapeData[2]); } else { size = new Vector3(boundingBox.X / 2, boundingBox.Y, boundingBox.X / 2); } break; case ShapeType.Compound: // size is used solely for naming, not used for the collision shape size = new Vector3(physObj.ShapeData.Count, physObj.ShapeData[0], physObj.ShapeData[physObj.ShapeData.Count - 1]); break; case ShapeType.ConvexHull: // size is used solely for naming, not used for the collision shape size = new Vector3(physObj.MeshProvider.Vertices.Count, physObj.MeshProvider.Indices.Count, physObj.MeshProvider.Vertices[0].X); break; case ShapeType.Extra: if (mataliObj == null) { throw new GoblinException("For extra shape type, you need to define the 'physObj' " + "as MataliObject instance"); } if (mataliObj.ExtraShape == ExtraShapeType.Undefined) { throw new GoblinException("Undefined type is not allowed if Extra shape type is specified"); } // size is used solely for naming, not used for the collision shape switch (mataliObj.ExtraShape) { case ExtraShapeType.Point: if (physObj.ShapeData.Count != 3) { throw new GoblinException("For Point shape type, you need to specify the position (x,y,z) in ShapeData"); } size = new Vector3(physObj.ShapeData[0], physObj.ShapeData[1], physObj.ShapeData[2]); break; case ExtraShapeType.Heightmap: if (physObj.ShapeData.Count < 2) { throw new GoblinException("There needs to be at least two floats specifying the " + "width and height"); } size = new Vector3(physObj.ShapeData[0], physObj.ShapeData[1], physObj.ShapeData.Count); break; case ExtraShapeType.Edge: if (physObj.ShapeData.Count != 6) { throw new GoblinException("For Edge shape type, you need to specify the start and " + "end positions (x,y,z) in ShapeData"); } size = new Vector3(physObj.ShapeData[0] + physObj.ShapeData[3], physObj.ShapeData[1] + physObj.ShapeData[4], physObj.ShapeData[2] + physObj.ShapeData[5]); break; default: throw new GoblinException(mataliObj.ExtraShape.ToString() + " not implemented yet"); } break; } String shapeName = physObj.Shape.ToString() + size.ToString(); String primitiveName = physObj.Shape.ToString() + size.ToString(); if (mataliObj != null) { String suffix = ""; if (physObj.Shape == ShapeType.Extra) { suffix += mataliObj.ExtraShape.ToString(); } else if (physObj.Shape == ShapeType.Compound) { suffix += mataliObj.CompoundShape.ToString(); } suffix += mataliObj.ShapeOriginalMatrix.ToString(); suffix += mataliObj.ShapeCollisionMargin; shapeName += suffix; primitiveName += suffix; } Shape shape = null; ShapePrimitive primitive = null; if (scene.Factory.ShapeManager.Contains(shapeName)) { shape = scene.Factory.ShapeManager.Find(shapeName); } else { if (physObj.Shape != ShapeType.Compound) { primitive = scene.Factory.ShapePrimitiveManager.Create(primitiveName); } shape = scene.Factory.ShapeManager.Create(shapeName); bool shapeSet = false; switch (physObj.Shape) { case ShapeType.Box: primitive.CreateBox(size.X, size.Y, size.Z); break; case ShapeType.Sphere: primitive.CreateSphere(size.X); break; case ShapeType.Cone: primitive.CreateConeY(size.Y, size.X); break; case ShapeType.Cylinder: if (size.X != size.Z) { primitive.CreateCylinder2RY(size.Y, size.X, size.Z); } else { primitive.CreateCylinderY(size.Y, size.X); } break; case ShapeType.Capsule: primitive.CreateCapsuleY(size.Y - size.X * 2, size.X); break; case ShapeType.Compound: ShapeCompoundType type = ShapeCompoundType.ConvexHull; if (mataliObj != null) { if (mataliObj.CompoundShape == CompoundShapeType.MinkowskiSum) { type = ShapeCompoundType.MinkowskiSum; } } int dataIndex = 0; Shape compoundShapePart = null; ShapePrimitive compoundPrimitive = null; float[] matrixVals = new float[16]; while (dataIndex < physObj.ShapeData.Count) { ShapeType shapeType = (ShapeType)Enum.ToObject(typeof(ShapeType), (int)physObj.ShapeData[dataIndex++]); switch (shapeType) { case ShapeType.Cylinder: size = new Vector3(physObj.ShapeData[dataIndex], physObj.ShapeData[dataIndex + 1], physObj.ShapeData[dataIndex]); dataIndex += 2; break; case ShapeType.Sphere: size = new Vector3(physObj.ShapeData[dataIndex], 0, 0); dataIndex++; break; } shapeName = shapeType.ToString() + size.ToString(); primitiveName = shapeType.ToString() + size.ToString(); if (scene.Factory.ShapeManager.Contains(shapeName)) { compoundShapePart = scene.Factory.ShapeManager.Find(shapeName); } else { compoundPrimitive = scene.Factory.ShapePrimitiveManager.Create(primitiveName); compoundShapePart = scene.Factory.ShapeManager.Create(shapeName); switch (shapeType) { case ShapeType.Cylinder: compoundPrimitive.CreateCylinderY(size.Y, size.X); break; case ShapeType.Sphere: compoundPrimitive.CreateSphere(size.X); break; default: throw new GoblinException(shape.ToString() + " is not supported yet as a compound part"); } compoundShapePart.Set(compoundPrimitive, Matrix.Identity, 0.0f); } for (int i = 0; i < 16; ++i) { matrixVals[i] = physObj.ShapeData[dataIndex + i]; } dataIndex += 16; shape.Add(compoundShapePart, MatrixHelper.FloatsToMatrix(matrixVals), 0.0f, type); } float margin = 0.0f; if (mataliObj != null) { margin = mataliObj.ShapeCollisionMargin; } shape.CreateMesh(margin); shapeSet = true; break; case ShapeType.ConvexHull: case ShapeType.TriangleMesh: float[] frictions = null; float[] restitutions = null; if (physObj.Shape == ShapeType.ConvexHull) { primitive.CreateConvex(physObj.MeshProvider.Vertices); } else { int triangleCount = physObj.MeshProvider.Indices.Count / 3; frictions = new float[triangleCount]; restitutions = new float[triangleCount]; for (int i = 0; i < frictions.Length; i++) { frictions[i] = 1.0f; restitutions[i] = 0.0f; } Vector3[] triVerts = new Vector3[physObj.MeshProvider.Indices.Count]; for (int i = 0; i < triVerts.Length; ++i) { triVerts[i] = physObj.MeshProvider.Vertices[physObj.MeshProvider.Indices[i]]; } bool flipTriangle = (physObj is MataliObject) ? ((MataliObject)physObj).FlipTriangleOrder : true; primitive.CreateTriangleMesh(triVerts, flipTriangle, 2, frictions, restitutions, 1.0f, 0.0f); } break; case ShapeType.Extra: switch (mataliObj.ExtraShape) { case ExtraShapeType.Heightmap: int width = (int)physObj.ShapeData[0]; int height = (int)physObj.ShapeData[1]; float[] heightData = new float[height * width]; float[] heightFrictions = new float[height * width]; float[] heightRestituions = new float[height * width]; if (physObj.ShapeData.Count < (2 + heightData.Length)) { throw new GoblinException("You also need to specify the hegith map data"); } Buffer.BlockCopy(physObj.ShapeData.ToArray(), 2 * sizeof(float), heightData, 0, heightData.Length * sizeof(float)); if (physObj.ShapeData.Count > (2 + heightData.Length * 2)) { Buffer.BlockCopy(physObj.ShapeData.ToArray(), (2 + heightData.Length) * sizeof(float), heightFrictions, 0, heightFrictions.Length * sizeof(float)); } else { for (int i = 0; i < heightFrictions.Length; ++i) { heightFrictions[i] = mataliObj.TriangleMeshFriction; } } if (physObj.ShapeData.Count > (2 + heightData.Length * 3)) { Buffer.BlockCopy(physObj.ShapeData.ToArray(), (2 + heightData.Length * 2) * sizeof(float), heightRestituions, 0, heightRestituions.Length * sizeof(float)); } else { for (int i = 0; i < heightRestituions.Length; ++i) { heightRestituions[i] = mataliObj.TriangleMeshRestitution; } } primitive.CreateHeightmap(0, 0, width, height, width, height, heightData, heightFrictions, heightRestituions, mataliObj.TriangleMeshFriction, mataliObj.TriangleMeshRestitution, mataliObj.IsDynamic); shape.Set(primitive, mataliObj.ShapeOriginalMatrix, mataliObj.ShapeCollisionMargin); shape.CreateMesh(0.0f); shapeSet = true; mataliPhysicsObj.InternalControllers.CreateHeightmapController(true); break; case ExtraShapeType.Point: primitive.CreatePoint(physObj.ShapeData[0], physObj.ShapeData[1], physObj.ShapeData[2]); break; case ExtraShapeType.Edge: primitive.CreateEdge(new Vector3(physObj.ShapeData[0], physObj.ShapeData[1], physObj.ShapeData[2]), new Vector3(physObj.ShapeData[3], physObj.ShapeData[4], physObj.ShapeData[5])); break; case ExtraShapeType.Plane: primitive.CreatePlaneY(physObj.ShapeData[0], (physObj.ShapeData[1] > 0)); break; case ExtraShapeType.Triangle: primitive.CreateTriangle( new Vector3(physObj.ShapeData[0], physObj.ShapeData[1], physObj.ShapeData[2]), new Vector3(physObj.ShapeData[3], physObj.ShapeData[4], physObj.ShapeData[5]), new Vector3(physObj.ShapeData[6], physObj.ShapeData[7], physObj.ShapeData[8])); break; case ExtraShapeType.Tetrahedron: primitive.CreateTetrahedron( new Vector3(physObj.ShapeData[0], physObj.ShapeData[1], physObj.ShapeData[2]), new Vector3(physObj.ShapeData[3], physObj.ShapeData[4], physObj.ShapeData[5]), new Vector3(physObj.ShapeData[6], physObj.ShapeData[7], physObj.ShapeData[8]), new Vector3(physObj.ShapeData[9], physObj.ShapeData[10], physObj.ShapeData[11])); break; case ExtraShapeType.Fluid: break; case ExtraShapeType.Hemisphere: primitive.CreateHemisphereY(physObj.ShapeData[0]); break; } break; } if (!shapeSet) { if (mataliObj != null) { shape.Set(primitive, mataliObj.ShapeOriginalMatrix, mataliObj.ShapeCollisionMargin); } else { shape.Set(primitive, Matrix.Identity, 0.0f); } if (buildCollisionMesh) { float margin = 0.0f; if (mataliObj != null) { margin = mataliObj.ShapeCollisionMargin; } shape.CreateMesh(margin); } } } mataliPhysicsObj.Shape = shape; }
public static void CreateShapes(Demo demo, PhysicsScene scene) { ShapePrimitive shapePrimitive = null; Shape shape = null; Shape userShape = null; Shape sphere = scene.Factory.ShapeManager.Find("Sphere"); Shape box = scene.Factory.ShapeManager.Find("Box"); Shape coneY = scene.Factory.ShapeManager.Find("ConeY"); Shape cylinderY = scene.Factory.ShapeManager.Find("CylinderY"); shape = scene.Factory.ShapeManager.Create("UserShape 1"); shape.Add(box, Matrix4.Identity, 0.0f, ShapeCompoundType.MinkowskiSum); shape.Add(sphere, Matrix4.Identity, 0.0f, ShapeCompoundType.MinkowskiSum); shape.CreateMesh(0.0f); if (!demo.Meshes.ContainsKey("UserShape1")) { demo.Meshes.Add("UserShape1", new DemoMesh(demo, shape, demo.Textures["Default"], Vector2.One, false, false, false, false, true, CullFaceMode.Back, false, false)); } shape = scene.Factory.ShapeManager.Create("UserShape 2"); shape.Add(coneY, Matrix4.Identity, 0.0f, ShapeCompoundType.MinkowskiSum); shape.Add(sphere, Matrix4.Identity, 0.0f, ShapeCompoundType.MinkowskiSum); shape.CreateMesh(0.0f); if (!demo.Meshes.ContainsKey("UserShape2")) { demo.Meshes.Add("UserShape2", new DemoMesh(demo, shape, demo.Textures["Default"], Vector2.One, false, false, false, false, true, CullFaceMode.Back, false, false)); } shape = scene.Factory.ShapeManager.Create("UserShape 3"); shape.Add(cylinderY, Matrix4.Identity, 0.0f, ShapeCompoundType.MinkowskiSum); shape.Add(sphere, Matrix4.Identity, 0.0f, ShapeCompoundType.MinkowskiSum); shape.CreateMesh(0.0f); if (!demo.Meshes.ContainsKey("UserShape3")) { demo.Meshes.Add("UserShape3", new DemoMesh(demo, shape, demo.Textures["Default"], Vector2.One, false, false, false, false, true, CullFaceMode.Back, false, false)); } shape = scene.Factory.ShapeManager.Create("UserShape 4"); shape.Add(coneY, Matrix4.Identity, 0.0f, ShapeCompoundType.MinkowskiSum); shape.Add(sphere, Matrix4.Identity, 0.0f, ShapeCompoundType.MinkowskiSum); shape.Add(cylinderY, Matrix4.CreateScale(4.0f, 0.5f, 4.0f), 0.0f, ShapeCompoundType.ConvexHull); shape.CreateMesh(0.0f); if (!demo.Meshes.ContainsKey("UserShape4")) { demo.Meshes.Add("UserShape4", new DemoMesh(demo, shape, demo.Textures["Default"], Vector2.One, false, false, false, false, true, CullFaceMode.Back, false, false)); } Vector3[] convexTab1 = new Vector3[6]; convexTab1[0] = new Vector3(0.0f, -2.0f, 0.0f); convexTab1[1] = new Vector3(0.0f, 4.0f, 0.0f); convexTab1[2] = new Vector3(2.0f, 0.0f, 0.0f); convexTab1[3] = new Vector3(-4.0f, 0.0f, 0.0f); convexTab1[4] = new Vector3(0.0f, 0.0f, 4.0f); convexTab1[5] = new Vector3(0.0f, 0.0f, -2.0f); shapePrimitive = scene.Factory.ShapePrimitiveManager.Create("Convex 1"); shapePrimitive.CreateConvex(convexTab1); userShape = scene.Factory.ShapeManager.Create("UserShape 5"); userShape.Set(shapePrimitive, Matrix4.Identity, 0.0f); userShape.CreateMesh(0.0f); if (!demo.Meshes.ContainsKey("UserShape5")) { demo.Meshes.Add("UserShape5", new DemoMesh(demo, userShape, demo.Textures["Default"], Vector2.One, false, false, false, false, true, CullFaceMode.Back, false, false)); } shape = scene.Factory.ShapeManager.Create("UserShape 6"); shape.Add(userShape, Matrix4.Identity, 0.0f, ShapeCompoundType.MinkowskiSum); shape.Add(sphere, Matrix4.CreateScale(0.5f), 0.0f, ShapeCompoundType.MinkowskiSum); shape.CreateMesh(0.0f); if (!demo.Meshes.ContainsKey("UserShape6")) { demo.Meshes.Add("UserShape6", new DemoMesh(demo, shape, demo.Textures["Default"], Vector2.One, false, false, false, false, true, CullFaceMode.Back, false, false)); } Vector3[] convexTab2 = new Vector3[10]; convexTab2[0] = new Vector3(-2.0f, -0.5f, -1.0f); convexTab2[1] = new Vector3(-1.5f, -0.5f, 0.5f); convexTab2[2] = new Vector3(0.0f, -0.5f, 2.0f); convexTab2[3] = new Vector3(1.5f, -0.5f, 0.5f); convexTab2[4] = new Vector3(2.0f, -0.5f, -1.0f); convexTab2[5] = new Vector3(-2.0f, 0.5f, -1.0f); convexTab2[6] = new Vector3(-1.5f, 0.5f, 0.5f); convexTab2[7] = new Vector3(0.0f, 0.5f, 2.0f); convexTab2[8] = new Vector3(1.5f, 0.5f, 0.5f); convexTab2[9] = new Vector3(2.0f, 0.5f, -1.0f); shapePrimitive = scene.Factory.ShapePrimitiveManager.Create("Convex 2"); shapePrimitive.CreateConvex(convexTab2); userShape = scene.Factory.ShapeManager.Create("UserShape 7"); userShape.Set(shapePrimitive, Matrix4.Identity, 0.0f); userShape.CreateMesh(0.0f); if (!demo.Meshes.ContainsKey("UserShape7")) { demo.Meshes.Add("UserShape7", new DemoMesh(demo, userShape, demo.Textures["Default"], Vector2.One, false, false, false, false, true, CullFaceMode.Back, false, false)); } shape = scene.Factory.ShapeManager.Create("UserShape 8"); shape.Add(userShape, Matrix4.Identity, 0.0f, ShapeCompoundType.MinkowskiSum); shape.Add(sphere, Matrix4.CreateScale(0.5f), 0.0f, ShapeCompoundType.MinkowskiSum); shape.CreateMesh(0.0f); if (!demo.Meshes.ContainsKey("UserShape8")) { demo.Meshes.Add("UserShape8", new DemoMesh(demo, shape, demo.Textures["Default"], Vector2.One, false, false, false, false, true, CullFaceMode.Back, false, false)); } }