private void PrepareGroup(Group grp, Hierarchy parent, int index, int catIndex)
        {
            groupVertList = new List <Vector3>();

            Hierarchy groupHier = new Hierarchy(grp);

            hierarchy.Add(groupHier);

            groupHier.ParentIndex = (short)hierarchy.IndexOf(parent);

            groupHier.FirstVertexIndex = (short)vertexList.Count;

            if (index != categoryList[catIndex].Groups.Count - 1)
            {
                groupHier.NextSiblingIndex = (short)hierarchy.Count;
            }

            foreach (Triangle tri in grp.Triangles)
            {
                PrepareTriangle(tri, groupHier);
            }

            Octet oct = new Octet(new List <Triangle>(grp.Triangles));

            oct.Populate();

            PopulateOctreeList(oct);

            groupHier.OctreeStartIndex = (short)octreeList.IndexOf(oct);

            vertexList.AddRange(groupVertList);
        }
Beispiel #2
0
        public Octet(AABB boundingBox)
        {
            Triangles = new List <Triangle>();

            BoundingBox = boundingBox;

            Subdivisions = new Octet[8];
        }
Beispiel #3
0
        public Octet(List <Triangle> tris)
        {
            Triangles = tris;

            BoundingBox = new AABB(tris);

            Subdivisions = new Octet[8];
        }
Beispiel #4
0
        private Octet CreateNode(AABB boundingBox, List <Triangle> triList)
        {
            if (triList.Count == 0)
            {
                return(null);
            }

            Octet ret = new Octet(boundingBox);

            ret.Triangles = triList;
            ret.Parent    = this;

            return(ret);
        }
        private void PopulateOctreeList(Octet oct)
        {
            if (oct == null)
            {
                return;
            }

            octreeList.Add(oct);

            if (oct.IsLeafNode)
            {
                triList.AddRange(oct.Triangles);

                //foreach (Triangle tri in oct.Triangles)
                //PrepareTriangle(tri, null);

                return;
            }

            foreach (Octet octa in oct.Subdivisions)
            {
                PopulateOctreeList(octa);
            }
        }