Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
Box2DColliderShape.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 System.Diagnostics;
4 
5 using SiliconStudio.Core.Mathematics;
6 using SiliconStudio.Paradox.Graphics;
7 
8 namespace SiliconStudio.Paradox.Physics
9 {
11  {
12  /// <summary>
13  /// Initializes a new instance of the <see cref="Box2DColliderShape"/> class.
14  /// </summary>
15  /// <param name="halfExtents">The half extents.</param>
16  public Box2DColliderShape(Vector2 halfExtents)
17  {
18  Type = ColliderShapeTypes.Box;
19  Is2D = true;
20 
21  HalfExtent = halfExtents;
22 
23  InternalShape = new BulletSharp.Box2DShape(halfExtents) { LocalScaling = new Vector3(1, 1, 0) };
24 
25  if (!PhysicsEngine.Singleton.CreateDebugPrimitives) return;
26  DebugPrimitive = GeometricPrimitive.Cube.New(PhysicsEngine.Singleton.DebugGraphicsDevice);
27  DebugPrimitiveScaling = Matrix.Scaling(new Vector3(halfExtents.X * 2, halfExtents.Y * 2, 0.05f) * 1.01f);
28  }
29 
30  /// <summary>
31  /// Gets the half extent.
32  /// </summary>
33  /// <value>
34  /// The half extent.
35  /// </value>
36  public Vector2 HalfExtent { get; private set; }
37  }
38 }
bool CreateDebugPrimitives
Set to true if you want the engine to create the debug primitives
Represents a two dimensional mathematical vector.
Definition: Vector2.cs:42
Box2DColliderShape(Vector2 halfExtents)
Initializes a new instance of the Box2DColliderShape class.
float Y
The Y component of the vector.
Definition: Vector2.cs:79
float X
The X component of the vector.
Definition: Vector2.cs:73
using SiliconStudio.Paradox. Physics
SiliconStudio.Core.Mathematics.Vector3 Vector3