Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
SphereColliderShape.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using SiliconStudio.Core.Mathematics;
4 using SiliconStudio.Paradox.Graphics;
5 
6 namespace SiliconStudio.Paradox.Physics
7 {
9  {
10  /// <summary>
11  /// Initializes a new instance of the <see cref="SphereColliderShape"/> class.
12  /// </summary>
13  /// <param name="is2D">if set to <c>true</c> [is2 d].</param>
14  /// <param name="radius">The radius.</param>
15  public SphereColliderShape(bool is2D, float radius)
16  {
17  Type = ColliderShapeTypes.Sphere;
18  Is2D = is2D;
19 
20  Radius = radius;
21 
22  var shape = new BulletSharp.SphereShape(radius);
23 
24  if (Is2D)
25  {
26  InternalShape = new BulletSharp.Convex2DShape(shape) { LocalScaling = new Vector3(1, 1, 0) };
27  }
28  else
29  {
30  InternalShape = shape;
31  }
32 
33  if (!PhysicsEngine.Singleton.CreateDebugPrimitives) return;
34  DebugPrimitive = GeometricPrimitive.Sphere.New(PhysicsEngine.Singleton.DebugGraphicsDevice);
35  DebugPrimitiveScaling = Matrix.Scaling(radius * 2 * 1.01f);
36  }
37 
38  /// <summary>
39  /// Gets the radius.
40  /// </summary>
41  /// <value>
42  /// The radius.
43  /// </value>
44  public float Radius { get; private set; }
45  }
46 }
bool CreateDebugPrimitives
Set to true if you want the engine to create the debug primitives
SphereColliderShape(bool is2D, float radius)
Initializes a new instance of the SphereColliderShape class.
using SiliconStudio.Paradox. Physics
SiliconStudio.Core.Mathematics.Vector3 Vector3