Example #1
0
        // ---------------------------------------------------------------------------------------------
        //
        // ---------------------------------------------------------------------------------------------
        private VoxelUtils.VoxelChunk createCutVoxelChunk(VoxelUtils.VoxelVector3Int p, int w, int h, int d)
        {
            //if (_isExperimentalChunk) {
            //Debug.Log ("createCutVoxelChunk " + p.ToString () + ", " + w + ", " + h + ", " + d);
            //}

            float width  = w * VoxelUtils.CHUNK_SIZE;
            float height = h * VoxelUtils.CHUNK_SIZE;
            float depth  = d * VoxelUtils.CHUNK_SIZE;

            Vector3 pos = new Vector3((p.x * VoxelUtils.CHUNK_SIZE) + (width / 2f), (p.y * VoxelUtils.CHUNK_SIZE) + (height / 2f), (p.z * VoxelUtils.CHUNK_SIZE) + (depth / 2f));

            Bounds b = new Bounds();              //coll.bounds;

            b.size   = new Vector3(width - VoxelUtils.CHUNK_SIZE, height - VoxelUtils.CHUNK_SIZE, depth - VoxelUtils.CHUNK_SIZE);
            b.center = pos;

            VoxelUtils.VoxelChunk vc = new VoxelUtils.VoxelChunk();
            vc.pos           = p;
            vc.size          = new VoxelUtils.VoxelVector3Int(w, h, d);
            vc.bounds        = b;
            vc.corners       = VoxelUtils.createVoxelCorners(p, w, h, d);
            vc.materialIndex = 0;
            vc.meshCreated   = false;

            return(vc);
        }
Example #2
0
        // ---------------------------------------------------------------------------------------------
        // create single voxel
        // ---------------------------------------------------------------------------------------------
        public VoxelUtils.VoxelChunk createVoxelChunk(VoxelUtils.VoxelVector3Int p, int w, int h, int d)
        {
            //if (_isExperimentalChunk) {
            //	Debug.Log ("createVoxelChunk " + p.ToString () + ", " + w + ", " + h + ", " + d);
            //}

            GameObject cube = AssetFactory.Instance.createVoxelChunkClone();

            cube.transform.SetParent(_trfmVoxels);
            _iVoxelCount++;
            cube.name = "voxchunk_" + _iVoxelCount.ToString();

            //if (_isExperimentalChunk) {
            //	Debug.Log ("cube: " + cube.name + ", " + _trfmVoxels.name);
            //}

            float width  = w * VoxelUtils.CHUNK_SIZE;
            float height = h * VoxelUtils.CHUNK_SIZE;
            float depth  = d * VoxelUtils.CHUNK_SIZE;

            Vector3 pos = new Vector3((p.x * VoxelUtils.CHUNK_SIZE) + (width / 2f), (p.y * VoxelUtils.CHUNK_SIZE) + (height / 2f), (p.z * VoxelUtils.CHUNK_SIZE) + (depth / 2f));

            Bounds b = new Bounds();

            b.size   = new Vector3(width, height, depth);
            b.center = pos;

            VoxelUtils.VoxelChunk vc = new VoxelUtils.VoxelChunk();
            vc.go            = cube;
            vc.goPos         = pos;
            vc.pos           = p;
            vc.size          = new VoxelUtils.VoxelVector3Int(w, h, d);
            vc.bounds        = b;
            vc.corners       = VoxelUtils.createVoxelCorners(p, w, h, d);
            vc.materialIndex = 0;
            vc.meshCreated   = false;

            return(vc);
        }