/// <summary> /// Initializes a new instance of the <see cref="SphereColliderShape"/> class. /// </summary> /// <param name="is2D">if set to <c>true</c> [is2 d].</param> /// <param name="radius">The radius.</param> public SphereColliderShape(bool is2D, float radiusParam) { Type = ColliderShapeTypes.Sphere; Is2D = is2D; Radius = radiusParam; cachedScaling = Is2D ? new Vector3(1, 1, 0) : Vector3.One; var shape = new BulletSharp.SphereShape(Radius) { LocalScaling = cachedScaling, }; if (Is2D) { InternalShape = new BulletSharp.Convex2DShape(shape) { LocalScaling = cachedScaling }; } else { InternalShape = shape; } DebugPrimitiveMatrix = Matrix.Scaling(2 * Radius * DebugScaling); if (Is2D) { DebugPrimitiveMatrix.M33 = 0f; } }
/// <summary> /// Initializes a new instance of the <see cref="SphereColliderShape"/> class. /// </summary> /// <param name="is2D">if set to <c>true</c> [is2 d].</param> /// <param name="radius">The radius.</param> public SphereColliderShape(bool is2D, float radius) { Type = ColliderShapeTypes.Sphere; Is2D = is2D; var shape = new BulletSharp.SphereShape(radius) { LocalScaling = Vector3.One }; if (Is2D) { InternalShape = new BulletSharp.Convex2DShape(shape) { LocalScaling = new Vector3(1, 1, 0) }; } else { InternalShape = shape; } DebugPrimitiveMatrix = Matrix.Scaling(2 * radius * 1.01f); if (Is2D) { DebugPrimitiveMatrix.M33 = 0f; } }
/// <summary> /// Initializes a new instance of the <see cref="SphereColliderShape"/> class. /// </summary> /// <param name="is2D">if set to <c>true</c> [is2 d].</param> /// <param name="radius">The radius.</param> public SphereColliderShape(bool is2D, float radius) { Type = ColliderShapeTypes.Sphere; Is2D = is2D; Radius = radius; var shape = new BulletSharp.SphereShape(radius); if (Is2D) { InternalShape = new BulletSharp.Convex2DShape(shape) { LocalScaling = new Vector3(1, 1, 0) }; } else { InternalShape = shape; } if (!PhysicsEngine.Singleton.CreateDebugPrimitives) { return; } DebugPrimitive = GeometricPrimitive.Sphere.New(PhysicsEngine.Singleton.DebugGraphicsDevice); DebugPrimitiveScaling = Matrix.Scaling(radius * 2 * 1.01f); }
/// <summary> /// Initializes a new instance of the <see cref="SphereColliderShape"/> class. /// </summary> /// <param name="is2D">if set to <c>true</c> [is2 d].</param> /// <param name="radius">The radius.</param> public SphereColliderShape(bool is2D, float radius) { Type = ColliderShapeTypes.Sphere; Is2D = is2D; var shape = new BulletSharp.SphereShape(radius); if (Is2D) { InternalShape = new BulletSharp.Convex2DShape(shape) { LocalScaling = new Vector3(1, 1, 0) }; } else { InternalShape = shape; } DebugPrimitiveMatrix = Is2D ? Matrix.Scaling(new Vector3(radius * 2 * 1.01f, radius * 2 * 1.01f, 1.0f)) : Matrix.Scaling(radius * 2 * 1.01f); }
/// <summary> /// Initializes a new instance of the <see cref="SphereColliderShape"/> class. /// </summary> /// <param name="is2D">if set to <c>true</c> [is2 d].</param> /// <param name="radius">The radius.</param> public SphereColliderShape(bool is2D, float radiusParam, Vector3?offset = null) { Type = ColliderShapeTypes.Sphere; Is2D = is2D; Radius = radiusParam; cachedScaling = Is2D ? new Vector3(1, 1, 0) : Vector3.One; var shape = new BulletSharp.SphereShape(Radius) { LocalScaling = cachedScaling, }; if (Is2D) { InternalShape = new BulletSharp.Convex2DShape(shape) { LocalScaling = cachedScaling }; } else { InternalShape = shape; } DebugPrimitiveMatrix = Matrix.Scaling(2 * Radius * DebugScaling); if (Is2D) { DebugPrimitiveMatrix.M33 = 0f; } if (offset.HasValue) { LocalOffset = offset.Value; UpdateLocalTransformations(); } }
/// <summary> /// Create the collision sphere. /// </summary> /// <param name="radius">Sphere radius.</param> public CollisionSphere(float radius = 1f) { _shape = new BulletSharp.SphereShape(radius); }
public SphereShape(float radius) { Radius = radius; BulletShape = new BulletSharp.SphereShape(radius); BulletShape.UserObject = this; }