예제 #1
0
        // ---------------------------------------------------------------------------------------------
        //
        // ---------------------------------------------------------------------------------------------
        private VoxelUtils.VoxelChunk createCutGameObject(VoxelUtils.VoxelVector3Int p, int w, int h, int d)
        {
            //GameObject cube = Instantiate(prefabCut);
            //cube.transform.SetParent (_voxelChunkContainer);
            //cube.name = "cube_cut";

            float width  = w * VoxelUtils.CHUNK_SIZE;
            float height = h * VoxelUtils.CHUNK_SIZE;
            float depth  = d * VoxelUtils.CHUNK_SIZE;
            //cube.transform.localScale = new Vector3(width, height, depth);

            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));
            //cube.transform.localPosition = pos;

            //BoxCollider coll = cube.GetComponent<BoxCollider> ();
            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;
            //b.size = new Vector3 (b.size.x - VoxelUtils.CHUNK_SIZE, b.size.y - VoxelUtils.CHUNK_SIZE, b.size.z - VoxelUtils.CHUNK_SIZE);

            VoxelUtils.VoxelChunk vs = new VoxelUtils.VoxelChunk();
            //vs.go      = cube;
            vs.pos     = p;
            vs.size    = new VoxelUtils.VoxelVector3Int(w, h, d);
            vs.bounds  = b;            //coll.bounds;
            vs.corners = VoxelUtils.createVoxelCorners(p, w, h, d);

            //Debug.Log ("cut chunk corners: "+vs.corners.ToString());

            return(vs);
        }
예제 #2
0
        // ---------------------------------------------------------------------------------------------
        // create single voxel
        // ---------------------------------------------------------------------------------------------
        private VoxelUtils.VoxelChunk createVoxelChunk(VoxelUtils.VoxelVector3Int p, int w, int h, int d)
        {
            GameObject cube = Instantiate(prefabCube);

            cube.transform.SetParent(_voxelChunkContainer);
            _iCount++;
            cube.name = "cube_" + _iCount.ToString();

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

            cube.transform.localScale = new Vector3(width, height, depth);

            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));

            cube.transform.localPosition = pos;

            BoxCollider coll = cube.GetComponent <BoxCollider> ();

            VoxelUtils.VoxelChunk vs = new VoxelUtils.VoxelChunk();
            vs.go      = cube;
            vs.pos     = p;
            vs.size    = new VoxelUtils.VoxelVector3Int(w, h, d);
            vs.bounds  = coll.bounds;
            vs.corners = VoxelUtils.createVoxelCorners(p, w, h, d);

            //Debug.Log ("pos: "+vs.pos.ToString());
            //Debug.Log ("size: "+vs.size.ToString());
            //Debug.Log ("new chunk corners: "+vs.corners.ToString());
            //Debug.Log (vs.bounds);

            return(vs);
        }
예제 #3
0
        // ---------------------------------------------------------------------------------------------
        // create single voxel
        // ---------------------------------------------------------------------------------------------
        private VoxelUtils.VoxelChunk createVoxelChunk(VoxelUtils.VoxelVector3Int p, int w, int h, int d)
        {
            GameObject cube = Instantiate(prefabCube);

            cube.transform.SetParent(_voxelChunkContainer);
            _iCount++;
            cube.name = "cube_" + _iCount.ToString();

            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 vs = new VoxelUtils.VoxelChunk();
            vs.go      = cube;
            vs.goPos   = pos;
            vs.pos     = p;
            vs.size    = new VoxelUtils.VoxelVector3Int(w, h, d);
            vs.bounds  = b;           //coll.bounds;
            vs.corners = VoxelUtils.createVoxelCorners(p, w, h, d);

            return(vs);
        }
예제 #4
0
        // ---------------------------------------------------------------------------------------------
        // create single voxel
        // ---------------------------------------------------------------------------------------------
        private VoxelUtils.VoxelChunk createVoxelChunk(VoxelUtils.VoxelVector3Int p, int w, int h, int d)
        {
            GameObject cube = Instantiate(prefabCube);

            cube.transform.SetParent(_voxelChunkContainer);
            _iCount++;
            cube.name = "cube_" + _iCount.ToString();

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

            /*
             * cube.transform.localScale = Vector3.one;// new Vector3(width, height, depth);
             *
             * Mesh mesh = cube.GetComponent<MeshFilter> ().mesh;
             * VoxelChunkMesh.create (mesh, width, height, depth, w, h, d, false);
             */

            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));
            //cube.transform.localPosition = pos;

            //BoxCollider coll = cube.GetComponent<BoxCollider> ();
            //coll.size = new Vector3 (width, height, depth);
            //coll.center = Vector3.zero;
            //Debug.Log (coll.bounds);
            Bounds b = new Bounds();

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

            VoxelUtils.VoxelChunk vs = new VoxelUtils.VoxelChunk();
            vs.go      = cube;
            vs.goPos   = pos;
            vs.pos     = p;
            vs.size    = new VoxelUtils.VoxelVector3Int(w, h, d);
            vs.bounds  = b;           //coll.bounds;
            vs.corners = VoxelUtils.createVoxelCorners(p, w, h, d);

            return(vs);
        }
예제 #5
0
        // ---------------------------------------------------------------------------------------------
        //
        // ---------------------------------------------------------------------------------------------
        private VoxelUtils.VoxelChunk createCutVoxelChunk(VoxelUtils.VoxelVector3Int p, int w, int h, int 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 vs = new VoxelUtils.VoxelChunk();
            vs.pos     = p;
            vs.size    = new VoxelUtils.VoxelVector3Int(w, h, d);
            vs.bounds  = b;            //coll.bounds;
            vs.corners = VoxelUtils.createVoxelCorners(p, w, h, d);

            return(vs);
        }