コード例 #1
0
ファイル: SphereColliderShape.cs プロジェクト: glepag1/stride
        /// <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;
            }
        }
コード例 #2
0
        /// <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;
            }
        }
コード例 #3
0
ファイル: SphereColliderShape.cs プロジェクト: tiomke/paradox
        /// <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;
            }
        }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
        /// <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();
            }
        }
コード例 #8
0
ファイル: CollisionSphere.cs プロジェクト: raizam/GeonBit
 /// <summary>
 /// Create the collision sphere.
 /// </summary>
 /// <param name="radius">Sphere radius.</param>
 public CollisionSphere(float radius = 1f)
 {
     _shape = new BulletSharp.SphereShape(radius);
 }
コード例 #9
0
 public SphereShape(float radius)
 {
     Radius                 = radius;
     BulletShape            = new BulletSharp.SphereShape(radius);
     BulletShape.UserObject = this;
 }