Пример #1
0
        ///<summary>
        /// Constructs a new cone shape.
        ///</summary>
        ///<param name="height">Height of the cone.</param>
        ///<param name="radius">Radius of the cone base.</param>
        /// <param name="description">Cached information about the shape. Assumed to be correct; no extra processing or validation is performed.</param>
        public ConeShape(float height, float radius, ConvexShapeDescription description)
        {
            this.height = height;
            this.radius = radius;

            UpdateConvexShapeInfo(description);
        }
Пример #2
0
 protected void UpdateConvexShapeInfo(ConvexShapeDescription description)
 {
     UpdateEntityShapeVolume(description.EntityShapeVolume);
     MinimumRadius   = description.MinimumRadius;
     MaximumRadius   = description.MaximumRadius;
     collisionMargin = description.CollisionMargin;
 }
Пример #3
0
        ///<summary>
        /// Constructs a new transformable shape.
        ///</summary>
        /// <param name="shape">Base shape to transform.</param>
        /// <param name="transform">Transform to use.</param>
        /// <param name="description">Cached information about the shape. Assumed to be correct; no extra processing or validation is performed.</param>
        public TransformableShape(ConvexShape shape, Matrix3x3 transform, ConvexShapeDescription description)
        {
            this.shape     = shape;
            this.transform = transform;

            UpdateConvexShapeInfo(description);
        }
Пример #4
0
        ///<summary>
        /// Constructs a new box shape from cached information.
        ///</summary>
        ///<param name="width">Width of the box.</param>
        ///<param name="height">Height of the box.</param>
        ///<param name="length">Length of the box.</param>
        /// <param name="description">Cached information about the shape. Assumed to be correct; no extra processing or validation is performed.</param>
        public BoxShape(float width, float height, float length, ConvexShapeDescription description)
        {
            halfWidth  = width * 0.5f;
            halfHeight = height * 0.5f;
            halfLength = length * 0.5f;

            UpdateConvexShapeInfo(description);
        }
Пример #5
0
        ///<summary>
        /// Constructs a triangle shape from cached data.
        ///</summary>
        ///<param name="vA">First vertex in the triangle.</param>
        ///<param name="vB">Second vertex in the triangle.</param>
        ///<param name="vC">Third vertex in the triangle.</param>
        /// <param name="description">Cached information about the shape. Assumed to be correct; no extra processing or validation is performed.</param>
        public TriangleShape(Vector3 vA, Vector3 vB, Vector3 vC, ConvexShapeDescription description)
        {
            //Recenter.  Convexes should contain the origin.
            var center = (vA + vB + vC) / 3;

            this.vA = vA - center;
            this.vB = vB - center;
            this.vC = vC - center;
            UpdateConvexShapeInfo(description);
        }
Пример #6
0
        /// <summary>
        /// Creates a ConvexHullShape from cached information. Assumes all data provided is accurate- no pre-processing is performed.
        /// </summary>
        /// <param name="localSurfaceVertices">List of vertex positions on the surface of the convex hull shape, centered on the desired origin. These vertices are used as-is for the shape representation; no additional processing occurs.</param>
        /// <param name="description">Cached information about the shape. Assumed to be correct; no extra processing or validation is performed.</param>
        public ConvexHullShape(IList <Vector3> localSurfaceVertices, ConvexShapeDescription description)
        {
            if (localSurfaceVertices.Count == 0)
            {
                throw new ArgumentException("Vertices list used to create a ConvexHullShape cannot be empty.");
            }

            unexpandedMaximumRadius = description.MaximumRadius - collisionMargin;
            unexpandedMinimumRadius = description.MinimumRadius - collisionMargin;
            vertices = new Vector3[localSurfaceVertices.Count];
            localSurfaceVertices.CopyTo(vertices, 0);
            UpdateConvexShapeInfo(description);
        }
Пример #7
0
        ///<summary>
        /// Constructs a wrapped shape from cached data.
        ///</summary>
        ///<param name="shapeEntries">Already centered shape entries used to construct the shape.</param>
        /// <param name="description">Cached information about the shape. Assumed to be correct; no extra processing or validation is performed.</param>
        ///<exception cref="Exception">Thrown when the shape list is empty.</exception>
        public WrappedShape(IList <ConvexShapeEntry> shapeEntries, ConvexShapeDescription description)
        {
            if (shapeEntries.Count == 0)
            {
                throw new ArgumentException("Cannot create a wrapped shape with no contained shapes.");
            }
            for (int i = 0; i < shapeEntries.Count; i++)
            {
                shapes.Add(shapeEntries[i]);
            }

            UpdateConvexShapeInfo(description);
            shapes.Changed += ShapesChanged;
        }
Пример #8
0
 ///<summary>
 /// Constructs a new sphere shape.
 ///</summary>
 /// <param name="description">Cached information about the shape. Assumed to be correct; no extra processing or validation is performed.</param>
 public SphereShape(ConvexShapeDescription description)
 {
     UpdateConvexShapeInfo(description);
 }
Пример #9
0
 /// <summary>
 /// Constructs a minkowski sum shape from cached data.
 /// </summary>
 /// <param name="shapeEntries">Entries composing the minkowski sum.</param>
 /// <param name="localOffset">Local offset of the elements in the minkowski sum.</param>
 /// <param name="description">Cached information about the shape. Assumed to be correct; no extra processing or validation is performed.</param>
 public MinkowskiSumShape(IList <OrientedConvexShapeEntry> shapeEntries, Vector3 localOffset, ConvexShapeDescription description)
 {
     for (int i = 0; i < shapeEntries.Count; i++)
     {
         shapes.Add(shapeEntries[i]);
     }
     this.localOffset = localOffset;
     UpdateConvexShapeInfo(description);
     shapes.Changed += ShapesChanged;
 }
Пример #10
0
        ///<summary>
        /// Constructs a new capsule shape from cached information.
        ///</summary>
        ///<param name="length">Length of the capsule's inner line segment.</param>
        /// <param name="description">Cached information about the shape. Assumed to be correct; no extra processing or validation is performed.</param>
        public CapsuleShape(float length, ConvexShapeDescription description)
        {
            halfLength = length * 0.5f;

            UpdateConvexShapeInfo(description);
        }
Пример #11
0
 ///<summary>
 /// Constructs a new cylinder shape from cached data.
 ///</summary>
 ///<param name="height">Height of the cylinder.</param>
 ///<param name="radius">Radius of the cylinder.</param>
 /// <param name="description">Cached information about the shape. Assumed to be correct; no extra processing or validation is performed.</param>
 public CylinderShape(float height, float radius, ConvexShapeDescription description)
 {
     halfHeight  = height * .5f;
     this.radius = radius;
     UpdateConvexShapeInfo(description);
 }