Example #1
0
 public Ch0nk(Dimension dimension, Vector3i position, IMaterial material)
 {
     _dimension = dimension;
     _position = position;
     _eightFoldTree = new EightFoldTree(Size, material);
     //_eightFoldTree[0, 0, 0] = new SandMaterial();
 }
Example #2
0
 public LocalizedEightFoldTree(Vector3i location, EightFoldTree tree)
 {
     Location = location;
     Tree = tree;
 }
Example #3
0
        public void ChangeMaterial(BoundingShape boundingShape, IMaterial material, Ch0nk ch0Nk, Vector3b startLocation)
        {
            Vector3i treeAbsolutePosition = ch0Nk.Position + startLocation;
            BoundingCube treeBoundingBox = new BoundingCube(treeAbsolutePosition, Size);

            //if (_children == null && boundingShape.Encloses(treeBoundingBox) && Size > 1)
                //Console.WriteLine("GOT IT");

            if ((Size == 1) || (_children == null && boundingShape.Encloses(treeBoundingBox)))
            {
                _material = material;
            }
            else
            {
                for (int i = 0; i < 2; i++)
                    for (int j = 0; j < 2; j++)
                        for (int k = 0; k < 2; k++)
                        {
                            Vector3i childAbsolutePosition = ch0Nk.Position + startLocation + new Vector3b(i * _middle, j * _middle, k * _middle);
                            BoundingCube childBoundingBox = new BoundingCube(childAbsolutePosition, _middle);
                            if (childBoundingBox.Intersects(boundingShape))
                            {
                                if (_children == null)
                                    _children = new EightFoldTree[2, 2, 2];

                                if (_children[i, j, k] == null)
                                    _children[i, j, k] = new EightFoldTree(_middle, _material);

                                _children[i, j, k].ChangeMaterial(boundingShape, material, ch0Nk, startLocation + new Vector3b(i * _middle, j * _middle, k * _middle));
                            }
                        }
            }
        }