Ejemplo n.º 1
0
        /// <summary>
        /// Creates the bouding box
        /// </summary>
        /// <param name="width">Width of the bounding box (x-axis)</param>
        /// <param name="height">Height of the bouding box (z-axis)</param>
        /// <param name="size">Size of the bouding box (y-axis)</param>
        /// <param name="origin">Center point of the box, size,height,width will be added.</param>
        /// <param name="yaw">Yaw/Rotation of the object</param>
        public BoundingBox(float width, float height, float size, Point origin, ushort yaw)
        {
            //Rotate the bounding box to an alternative grid
            Matrix m = Matrix.GetFromInverseRotation(yaw);
            Point b = Matrix.WorldTransform(origin, m);

            //Create the bounding box
            Point a = new Point(width, height, size);
            TransformationOrigin(a);
            AddWorldTransformPoint(b);

            //Save yaw for later calculations
            this.yaw = yaw;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Check if the point is in the box. This function assumes
        /// the point hasn't been prerotated yet.
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        public bool IsInBox(Point point)
        {
            //Rotate the bounding box to an alternative grid
            Matrix m = Matrix.GetFromInverseRotation(yaw);
            Point b = Matrix.WorldTransform(point, m);

            if (BetweenCoordX(b.x) && BetweenCoordY(b.y) && BetweenCoordZ(b.z))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Ejemplo n.º 3
0
 private void TransformationOrigin(Point b)
 {
     max_x = b.x / 2;
     max_y = b.y / 2;
     max_z = b.z / 2;
     min_x = -max_x;
     min_y = -max_y;
     min_z = -max_z;
 }
Ejemplo n.º 4
0
 private void AddWorldTransformPoint(Point b)
 {
     min_x += b.x;
     min_y += b.y;
     min_z += b.z;
     max_x += b.x;
     max_y += b.y;
     max_z += b.z;
 }