예제 #1
0
파일: Block.cs 프로젝트: jmanke/VoxelEngine
 public Block(int x, int y, int z, int lod, int size, VoxelObject voxelObject)
 {
     this.x           = x;
     this.y           = y;
     this.z           = z;
     this.lod         = lod;
     this.size        = size;
     this.id          = GenerateId(x, y, z, lod);
     this.spacing     = (int)Mathf.Pow(2, lod);
     this.voxelObject = voxelObject;
 }
예제 #2
0
        public void GenerateVoxelObject(VoxelObjectSettings voxelObjectSettings, Vector3 position)
        {
            var voxelObject = new VoxelObject(voxelObjectSettings, this);

            voxelObject.root.position = position;
            voxelObjects.Add(voxelObject);

            System.Threading.ThreadPool.QueueUserWorkItem(o =>
            {
                voxelObject.GenerateIsovalues();
                MainThread.ExecuteOnMainThread(() => voxelObject.SetLod(currLod));
            });
        }
예제 #3
0
        public Octree(int depth, int size, VoxelObject voxelObject)
        {
            root     = new Block(0, 0, 0, depth - 1, size, voxelObject);
            blockLod = new List <Block> [depth];

            for (int i = 0; i < blockLod.Length; i++)
            {
                blockLod[i] = new List <Block>();
            }

            blockLod[depth - 1].Add(root);

            BuildTreeRecursive(root);
        }