예제 #1
0
        /// <summary>
        /// Generates a square grid with a step of 1.0
        /// </summary>
        /// <returns></returns>
        public static LineGeometry3D GenerateGrid(Vector3 plane, int min = 0, int max = 10)
        {
            var grid = new LineBuilder();

            //int width = max - min;
            if (plane == Vector3.UnitX)
            {
                for (int i = min; i <= max; i++)
                {
                    grid.AddLine(new Vector3(0, i, min), new Vector3(0, i, max));
                    grid.AddLine(new Vector3(0, min, i), new Vector3(0, max, i));
                }
            }
            else if (plane == Vector3.UnitY)
            {
                for (int i = min; i <= max; i++)
                {
                    grid.AddLine(new Vector3(i, 0, min), new Vector3(i, 0, max));
                    grid.AddLine(new Vector3(min, 0, i), new Vector3(max, 0, i));
                }
            }
            else
            {
                for (int i = min; i <= max; i++)
                {
                    grid.AddLine(new Vector3(i, min, 0), new Vector3(i, max, 0));
                    grid.AddLine(new Vector3(min, i, 0), new Vector3(max, i, 0));
                }
            }

            return(grid.ToLineGeometry3D());
        }
예제 #2
0
        /// <summary>
        /// Returns a line geometry of the axis-aligned bounding-box of the given mesh.
        /// </summary>
        /// <param name="mesh">Input mesh for the computation of the b-box</param>
        /// <returns></returns>
        public static LineGeometry3D GenerateBoundingBox(global::SharpDX.BoundingBox bb)
        {
            var cc = bb.GetCorners();
            var ll = new LineBuilder();

            ll.AddLine(cc[0], cc[1]);
            ll.AddLine(cc[1], cc[2]);
            ll.AddLine(cc[2], cc[3]);
            ll.AddLine(cc[3], cc[0]);

            ll.AddLine(cc[4], cc[5]);
            ll.AddLine(cc[5], cc[6]);
            ll.AddLine(cc[6], cc[7]);
            ll.AddLine(cc[7], cc[4]);

            ll.AddLine(cc[0], cc[4]);
            ll.AddLine(cc[1], cc[5]);
            ll.AddLine(cc[2], cc[6]);
            ll.AddLine(cc[3], cc[7]);
            return(ll.ToLineGeometry3D());
        }
예제 #3
0
        /// <summary>
        /// Returns a line geometry of the axis-aligned bounding-box of the given mesh.
        /// </summary>
        /// <param name="mesh">Input mesh for the computation of the b-box</param>
        /// <returns></returns>
        public static LineGeometry3D GenerateBoundingBox(global::SharpDX.BoundingBox bb)
        {            
            var cc = bb.GetCorners();
            var ll = new LineBuilder();
            ll.AddLine(cc[0], cc[1]);
            ll.AddLine(cc[1], cc[2]);
            ll.AddLine(cc[2], cc[3]);
            ll.AddLine(cc[3], cc[0]);

            ll.AddLine(cc[4], cc[5]);
            ll.AddLine(cc[5], cc[6]);
            ll.AddLine(cc[6], cc[7]);
            ll.AddLine(cc[7], cc[4]);

            ll.AddLine(cc[0], cc[4]);
            ll.AddLine(cc[1], cc[5]);
            ll.AddLine(cc[2], cc[6]);
            ll.AddLine(cc[3], cc[7]);
            return ll.ToLineGeometry3D();
        }
예제 #4
0
        /// <summary>
        /// Generates a square grid with a step of 1.0 
        /// </summary>
        /// <returns></returns>
        public static LineGeometry3D GenerateGrid(Vector3 plane, int min = 0, int max = 10)
        {
            var grid = new LineBuilder();
            //int width = max - min;
            if (plane == Vector3.UnitX)
            {
                for (int i = min; i <= max; i++)
                {
                    grid.AddLine(new Vector3(0, i, min), new Vector3(0, i, max));
                    grid.AddLine(new Vector3(0, min, i), new Vector3(0, max, i));
                }
            }
            else if (plane == Vector3.UnitY)
            {
                for (int i = min; i <= max; i++)
                {
                    grid.AddLine(new Vector3(i, 0, min), new Vector3(i, 0, max));
                    grid.AddLine(new Vector3(min, 0, i), new Vector3(max, 0, i));
                }
            }
            else
            {
                for (int i = min; i <= max; i++)
                {
                    grid.AddLine(new Vector3(i, min, 0), new Vector3(i, max, 0));
                    grid.AddLine(new Vector3(min, i, 0), new Vector3(max, i, 0));
                }
            }

            return grid.ToLineGeometry3D();
        }