Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Box2DColliderShape"/> class.
        /// </summary>
        /// <param name="halfExtents">The half extents.</param>
        public Box2DColliderShape(Vector2 halfExtents)
        {
            Type = ColliderShapeTypes.Box;
            Is2D = true;

            InternalShape = new BulletSharp.Box2DShape(halfExtents) { LocalScaling = new Vector3(1, 1, 0) };

            DebugPrimitiveMatrix = Matrix.Scaling(new Vector3(halfExtents.X * 2, halfExtents.Y * 2, 0f) * 1.01f);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Box2DColliderShape"/> class.
        /// </summary>
        /// <param name="size">The half extents.</param>
        public Box2DColliderShape(Vector2 size)
        {
            Type = ColliderShapeTypes.Box;
            Is2D = true;

            InternalShape = new BulletSharp.Box2DShape(size/2) { LocalScaling = new Vector3(1, 1, 0) };

            DebugPrimitiveMatrix = Matrix.Scaling(new Vector3(size.X, size.Y, 0f) * 1.01f);
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Box2DColliderShape"/> class.
        /// </summary>
        /// <param name="size">The half extents.</param>
        public Box2DColliderShape(Vector2 size)
        {
            Type = ColliderShapeTypes.Box;
            Is2D = true;

            InternalShape = new BulletSharp.Box2DShape(size / 2)
            {
                LocalScaling = new Vector3(1, 1, 0)
            };

            DebugPrimitiveMatrix = Matrix.Scaling(new Vector3(size.X, size.Y, 0f) * 1.01f);
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Box2DColliderShape"/> class.
        /// </summary>
        /// <param name="halfExtents">The half extents.</param>
        public Box2DColliderShape(Vector2 halfExtents)
        {
            Type = ColliderShapeTypes.Box;
            Is2D = true;

            InternalShape = new BulletSharp.Box2DShape(halfExtents)
            {
                LocalScaling = new Vector3(1, 1, 0)
            };

            DebugPrimitiveMatrix = Matrix.Scaling(new Vector3(halfExtents.X * 2, halfExtents.Y * 2, 1.0f) * 1.01f);
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Box2DColliderShape"/> class.
        /// </summary>
        /// <param name="halfExtents">The half extents.</param>
        public Box2DColliderShape(Vector2 halfExtents)
        {
            Type = ColliderShapeTypes.Box;
            Is2D = true;

            HalfExtent = halfExtents;

            InternalShape = new BulletSharp.Box2DShape(halfExtents)
            {
                LocalScaling = new Vector3(1, 1, 0)
            };

            if (!PhysicsEngine.Singleton.CreateDebugPrimitives)
            {
                return;
            }
            DebugPrimitive        = GeometricPrimitive.Cube.New(PhysicsEngine.Singleton.DebugGraphicsDevice);
            DebugPrimitiveScaling = Matrix.Scaling(new Vector3(halfExtents.X * 2, halfExtents.Y * 2, 0.05f) * 1.01f);
        }
Esempio n. 6
0
 /// <summary>
 /// Create the collision box2d.
 /// </summary>
 /// <param name="width">Box base width (X axis).</param>
 /// <param name="height">Box base height (Y axis).</param>
 /// <param name="depth">Bow base depth (Z axis).</param>
 public CollisionBox2D(float width = 1f, float height = 1f, float depth = 1f)
 {
     _shape = new BulletSharp.Box2DShape(width / 2f, height / 2f, depth / 2f);
 }