Beispiel #1
0
        public void Fill()
        {
            if (divisions > 0)
            {
                // split each axis into min/mid/max
                float[] xDiv = { bounds.Min.X, (bounds.Min.X + bounds.Max.X) * (float)0.5, bounds.Max.X };
                float[] yDiv = { bounds.Min.Y, (bounds.Min.Y + bounds.Max.Y) * (float)0.5, bounds.Max.Y };
                float[] zDiv = { bounds.Min.Z, (bounds.Min.Z + bounds.Max.Z) * (float)0.5, bounds.Max.Z };

                int index = 0;

                for (int x = 0; x < 2; x++)
                {
                    for (int y = 0; y < 2; y++)
                    {
                        for (int z = 0; z < 2; z++)
                        {
                            subdivs[index] = new OctreeBox(new BoundingBox(new Vector3(xDiv[x], yDiv[y], zDiv[z]), new Vector3(xDiv[x + 1], yDiv[y + 1], zDiv[z + 1])), divisions - 1);
                            subdivs[index].Fill();

                            index++;
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public OctreeEngine(BoundingBox bounds, int depth)
        {
            rootBox = new OctreeBox(bounds, depth);

            rootBox.Fill();
        }