Example #1
0
        public override bool Encloses(BoundingShape boundingShape)
        {
            if (boundingShape is BoundingBox)
                return EnclosesBox((BoundingBox)boundingShape);

            return false;
        }
Example #2
0
        public override bool Intersects(BoundingShape boundingShape)
        {
            if (boundingShape is BoundingSphere)
                return IntersectsSphere((BoundingSphere) boundingShape);
            else if (boundingShape is BoundingBox)
                return IntersectsBox((BoundingBox)boundingShape);

            return false;
        }
Example #3
0
 public void ChangeMaterial(BoundingShape boundingShape, IMaterial material)
 {
     //ONLY FOR NOW: check all, but it can be optimized
     foreach (Ch0nk ch0Nk in _chonks.Values)
     {
         //if the ch0nk bounding box intersects, then go deeper
         if (ch0Nk.BoundingCube.Intersects(boundingShape))
             ch0Nk.ChangeMaterial(boundingShape, material);
     }
 }
Example #4
0
 public abstract bool Encloses(BoundingShape boundingShape);
Example #5
0
 public abstract bool Intersects(BoundingShape boundingShape);
Example #6
0
 public void ChangeMaterial(BoundingShape boundingShape, IMaterial material)
 {
     _eightFoldTree.ChangeMaterial(boundingShape, material,this,new Vector3b());
 }
Example #7
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));
                            }
                        }
            }
        }