/// <summary> /// Initializes a new instance of the <see cref="ConeColliderShape"/> class. /// </summary> /// <param name="orientation">Up axis.</param> /// <param name="radius">The radius of the cone</param> /// <param name="height">The height of the cone</param> public ConeColliderShape(float heightParam, float radiusParam, ShapeOrientation orientationParam) { Type = ColliderShapeTypes.Cone; Is2D = false; //always false for cone Height = heightParam; Radius = radiusParam; Orientation = orientationParam; Matrix rotation; cachedScaling = Vector3.One; switch (Orientation) { case ShapeOrientation.UpX: InternalShape = new BulletSharp.ConeShapeX(Radius, Height) { LocalScaling = cachedScaling, }; rotation = Matrix.RotationZ((float)Math.PI / 2.0f); break; case ShapeOrientation.UpY: InternalShape = new BulletSharp.ConeShape(Radius, Height) { LocalScaling = cachedScaling, }; rotation = Matrix.Identity; break; case ShapeOrientation.UpZ: InternalShape = new BulletSharp.ConeShapeZ(Radius, Height) { LocalScaling = cachedScaling, }; rotation = Matrix.RotationX((float)Math.PI / 2.0f); break; default: throw new ArgumentOutOfRangeException(nameof(Orientation)); } DebugPrimitiveMatrix = Matrix.Scaling(new Vector3(Radius * 2, Height, Radius * 2) * DebugScaling) * rotation; }
/// <summary> /// Initializes a new instance of the <see cref="ConeColliderShape"/> class. /// </summary> /// <param name="orientation">Up axis.</param> /// <param name="radius">The radius of the cone</param> /// <param name="height">The height of the cone</param> public ConeColliderShape(float height, float radius, ShapeOrientation orientation) { Type = ColliderShapeTypes.Cone; Is2D = false; //always false for cone Matrix rotation; CachedScaling = Vector3.One; switch (orientation) { case ShapeOrientation.UpX: InternalShape = new BulletSharp.ConeShapeX(radius, height) { LocalScaling = CachedScaling }; rotation = Matrix.RotationZ((float)Math.PI / 2.0f); break; case ShapeOrientation.UpY: InternalShape = new BulletSharp.ConeShape(radius, height) { LocalScaling = CachedScaling }; rotation = Matrix.Identity; break; case ShapeOrientation.UpZ: InternalShape = new BulletSharp.ConeShapeZ(radius, height) { LocalScaling = CachedScaling }; rotation = Matrix.RotationX((float)Math.PI / 2.0f); break; default: throw new ArgumentOutOfRangeException(nameof(orientation)); } DebugPrimitiveMatrix = Matrix.Scaling(new Vector3(radius * 2, height, radius * 2) * DebugScaling) * rotation; }