Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ConvexHullColliderShape.cs
Go to the documentation of this file.
1 using System.Collections.Generic;
2 using System.Linq;
3 
4 using SiliconStudio.Core.Mathematics;
5 using SiliconStudio.Paradox.Graphics;
6 
7 namespace SiliconStudio.Paradox.Physics
8 {
10  {
11  public ConvexHullColliderShape(IReadOnlyList<Vector3> points, IEnumerable<uint> indices)
12  {
13  Type = ColliderShapeTypes.ConvexHull;
14  Is2D = false;
15 
16  InternalShape = new BulletSharp.ConvexHullShape(points);
17 
18  if (!PhysicsEngine.Singleton.CreateDebugPrimitives) return;
19 
20  var verts = new VertexPositionNormalTexture[points.Count];
21  for (var i = 0; i < points.Count; i++)
22  {
23  verts[i].Position = points[i];
24  verts[i].TextureCoordinate = Vector2.Zero;
25  verts[i].Normal = Vector3.Zero;
26  }
27 
28  var intIndices = indices.Select(x => (int)x).ToArray();
29  var meshData = new GeometricMeshData<VertexPositionNormalTexture>(verts, intIndices, false);
30 
31  DebugPrimitive = new GeometricPrimitive(PhysicsEngine.Singleton.DebugGraphicsDevice, meshData);
32  DebugPrimitiveScaling = Matrix.Scaling(new Vector3(1, 1, 1) * 1.01f);
33  }
34  }
35 }
bool CreateDebugPrimitives
Set to true if you want the engine to create the debug primitives
A geometric primitive. Use Cube, Cylinder, GeoSphere, Plane, Sphere, Teapot, Torus. See Draw+vertices to learn how to use it.
Describes a custom vertex format structure that contains position, normal and texture information...
ConvexHullColliderShape(IReadOnlyList< Vector3 > points, IEnumerable< uint > indices)
using SiliconStudio.Paradox. Physics
SiliconStudio.Core.Mathematics.Vector3 Vector3