Exemplo n.º 1
0
        public void CreateFromVertices(Vector3[] vertices)
        {
            Vector3 min = new Vector3(float.MaxValue);
            Vector3 max = new Vector3(float.MinValue);

            foreach (Vector3 v in vertices)
            {
                min = Vector3.Min(v, min);
                max = Vector3.Min(v, max);
            }

            Line line02 = new Line(vertices[0], vertices[2], false);
            Line line23 = new Line(vertices[2], vertices[3], false);
            Line line31 = new Line(vertices[3], vertices[1], false);
            Line line10 = new Line(vertices[1], vertices[0], false);

            Line line76 = new Line(vertices[7], vertices[6], false);
            Line line64 = new Line(vertices[6], vertices[4], false);
            Line line45 = new Line(vertices[4], vertices[5], false);
            Line line57 = new Line(vertices[5], vertices[7], false);

            Line line40 = new Line(vertices[4], vertices[0], false);
            Line line01 = new Line(vertices[0], vertices[1], false);
            Line line15 = new Line(vertices[1], vertices[5], false);
            Line line54 = new Line(vertices[5], vertices[4], false);

            Line line32 = new Line(vertices[3], vertices[2], false);
            Line line26 = new Line(vertices[2], vertices[6], false);
            Line line67 = new Line(vertices[6], vertices[7], false);
            Line line73 = new Line(vertices[7], vertices[3], false);

            Line line13 = new Line(vertices[1], vertices[3], false);
            Line line37 = new Line(vertices[3], vertices[7], false);
            Line line75 = new Line(vertices[7], vertices[5], false);
            Line line51 = new Line(vertices[5], vertices[1], false);

            Line line04 = new Line(vertices[0], vertices[4], false);
            Line line46 = new Line(vertices[4], vertices[6], false);
            Line line62 = new Line(vertices[6], vertices[2], false);
            Line line20 = new Line(vertices[2], vertices[0], false);

            Sides[0].Lines[0] = line02;
            Sides[0].Lines[1] = line23;
            Sides[0].Lines[2] = line31;
            Sides[0].Lines[3] = line10;
            Sides[0].CreatePlaneFromLines();

            Sides[1].Lines[0] = line76;
            Sides[1].Lines[1] = line64;
            Sides[1].Lines[2] = line45;
            Sides[1].Lines[3] = line57;
            Sides[1].CreatePlaneFromLines();

            Sides[2].Lines[0] = line40;
            Sides[2].Lines[1] = line01;
            Sides[2].Lines[2] = line15;
            Sides[2].Lines[3] = line54;
            Sides[2].CreatePlaneFromLines();

            Sides[3].Lines[0] = line32;
            Sides[3].Lines[1] = line26;
            Sides[3].Lines[2] = line67;
            Sides[3].Lines[3] = line73;
            Sides[3].CreatePlaneFromLines();

            Sides[4].Lines[0] = line13;
            Sides[4].Lines[1] = line37;
            Sides[4].Lines[2] = line75;
            Sides[4].Lines[3] = line51;
            Sides[4].CreatePlaneFromLines();

            Sides[5].Lines[0] = line04;
            Sides[5].Lines[1] = line46;
            Sides[5].Lines[2] = line62;
            Sides[5].Lines[3] = line20;
            Sides[5].CreatePlaneFromLines();
        }
Exemplo n.º 2
0
        /// <summary>
        /// GenerateLines
        /// </summary>
        /// <param name="vctStart"></param>
        /// <param name="vctEnd"></param>
        /// <param name="vctSideStep"></param>
        /// <param name="worldMatrix"></param>
        /// <param name="m_lineBuffer"></param>
        /// <param name="divideRatio"></param>
        private static void GenerateLines(Vector3 vctStart, Vector3 vctEnd, ref Vector3 vctSideStep, ref Matrix worldMatrix, ref List<VRageMath.Line> m_lineBuffer, int divideRatio)
        {
            for (int i = 0; i <= divideRatio; ++i)
            {
                Vector3 transformedStart = Vector3.Transform(vctStart, worldMatrix);
                Vector3 transformedEnd = Vector3.Transform(vctEnd, worldMatrix);

                if (m_lineBuffer.Count < m_lineBuffer.Capacity)
                {
                    VRageMath.Line line = new VRageMath.Line(transformedStart, transformedEnd, false);
                    //@ generate Line
                    m_lineBuffer.Add(line);

                    vctStart += vctSideStep;
                    vctEnd += vctSideStep;
                }
            }
        }
Exemplo n.º 3
0
 public void Include(ref Line line)
 {
     Include(ref line.From);
     Include(ref line.To);
 }