コード例 #1
0
ファイル: ConeShape.cs プロジェクト: ByteChkR/Byt3
        ///<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
ファイル: TransformableShape.cs プロジェクト: ByteChkR/Byt3
        ///<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);
        }
コード例 #3
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);
        }
コード例 #4
0
ファイル: TriangleShape.cs プロジェクト: ByteChkR/Byt3
        ///<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.
            Vector3 center = (vA + vB + vC) / 3;

            this.vA = vA - center;
            this.vB = vB - center;
            this.vC = vC - center;
            UpdateConvexShapeInfo(description);
        }
コード例 #5
0
ファイル: MinkowskiSumShape.cs プロジェクト: ByteChkR/Byt3
        /// <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;
        }
コード例 #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
ファイル: CapsuleShape.cs プロジェクト: ByteChkR/Byt3
        ///<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);
        }
コード例 #10
0
ファイル: CylinderShape.cs プロジェクト: ByteChkR/Byt3
 ///<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);
 }