コード例 #1
0
ファイル: EightFoldTree.cs プロジェクト: catdawg/Ch0nkEngine
        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));
                            }
                        }
            }
        }
コード例 #2
0
ファイル: BoundingSphere.cs プロジェクト: catdawg/Ch0nkEngine
 private bool IntersectsCube(BoundingCube boundingCube)
 {
     return boundingCube.Intersects(this);
 }