Beispiel #1
0
    internal void AddTriangle(Triangle pTriangle)
    {
        Triangles.Add(pTriangle);

        if (Triangles.Count == 1)
        {
            Box = new Bounds(pTriangle.Box.center, pTriangle.Box.size);
        }
        else
        {
            Box.Encapsulate(pTriangle.Box);
        }

        if (!IsLeaf())
        {
            bool add_to_right = ShouldAddToRight(pTriangle);

            if (add_to_right)
            {
                Right.AddTriangle(pTriangle);
            }
            else
            {
                Left.AddTriangle(pTriangle);
            }
        }
        else
        {
            List <Triangle> left_triangles  = new List <Triangle>();
            List <Triangle> right_triangles = new List <Triangle>();

            bool should_split = DivideLeftRightTriangles(ref left_triangles, ref right_triangles);

            if (should_split)
            {
                //split
            }
        }
    }
Beispiel #2
0
    private void AddTriangle(int pI0, int pI1, int pI2, int pTriangleIndex)
    {
        RawTriangles.Add(pI0);

        int t_index = RawTriangles.Count - 1;

        RawTriangles.Add(pI1);
        RawTriangles.Add(pI2);

        Triangle t = new Triangle();

        t.Index = t_index;

        t.V0 = Vertices[pI0];
        t.V1 = Vertices[pI1];
        t.V2 = Vertices[pI2];

        t.Box = new Bounds(t.GetMidPoint(), Vector3.zero);
        t.Box.Encapsulate(t.V0.Position);
        t.Box.Encapsulate(t.V1.Position);
        t.Box.Encapsulate(t.V2.Position);

        Root.AddTriangle(t);
    }