Esempio n. 1
0
        public void buildMesh(Vector3 position)
        {
            VoxelDrawMesh draw = new VoxelDrawMesh();

            Debug.Log(real_.Count + "count");
            foreach (KeyValuePair <VectorInt3, VoxelShadowHandler> kv in this.real_)
            {
                VectorInt4 v = draw.addRect(Vector3.up, kv.Key + new VectorInt3(0, 0, -1), VoxelShadowHandler.GetUV(kv.Value.real), VoxelShadowHandler.GetUV(kv.Value.ghost), Color.black);
            }

            _mesh = draw.crateMeshFilter("Shadow", _material);
            if (_offset != null)
            {
                _mesh.gameObject.transform.SetParent(this._offset.transform);
            }
            else
            {
                _mesh.gameObject.transform.SetParent(this.transform);
            }

            _mesh.gameObject.transform.localPosition = Vector3.zero;
            _mesh.gameObject.transform.localScale    = Vector3.one;
            _mesh.gameObject.transform.localRotation = Quaternion.Euler(Vector3.zero);

            _mesh.gameObject.SetActive(true);
            Renderer renderer = _mesh.GetComponent <Renderer> ();

            renderer.material = this._material;
            showMesh(position);
        }
Esempio n. 2
0
        public void buildMesh()
        {
            VoxelDrawMesh draw = new VoxelDrawMesh ();
            //	_drawMesh._clear ();
            Dictionary<VectorInt3, VoxelHandler> voxs = this.voxels;
            //			Debug.Log (voxs.Count + "!!!!");
            foreach (KeyValuePair<VectorInt3, VoxelHandler> kv in voxs) {
                if(!voxs.ContainsKey(kv.Key + new VectorInt3(0,  -1, 0))){
                    VectorInt4 v = draw.addRect (Vector3.back, kv.Key,  VoxelHandler.GetUV(kv.Value.back), VoxelHandler.GetUV(kv.Value.lback), kv.Value.color);
                    kv.Value.vertices.Add(v);
                }

                if(!voxs.ContainsKey(kv.Key + new VectorInt3(0, 1, 0))){
                    VectorInt4 v = draw.addRect (Vector3.forward, kv.Key,  VoxelHandler.GetUV(kv.Value.front), VoxelHandler.GetUV(kv.Value.lfront), kv.Value.color);
                    kv.Value.vertices.Add(v);
                }

                if(!voxs.ContainsKey(kv.Key + new VectorInt3(0, 0, 1))){
                    VectorInt4 v = draw.addRect (Vector3.up, kv.Key, VoxelHandler.GetUV(kv.Value.up), VoxelHandler.GetUV(kv.Value.lup), kv.Value.color);
                    kv.Value.vertices.Add(v);
                }

                if(!voxs.ContainsKey(kv.Key + new VectorInt3(0, 0, -1))){
                    VectorInt4 v = draw.addRect (Vector3.down, kv.Key, VoxelHandler.GetUV(kv.Value.down), VoxelHandler.GetUV(kv.Value.ldown), kv.Value.color);
                    kv.Value.vertices.Add(v);
                }

                if(!voxs.ContainsKey(kv.Key + new VectorInt3(1, 0, 0))){
                    VectorInt4 v = draw.addRect (Vector3.left, kv.Key, VoxelHandler.GetUV(kv.Value.left), VoxelHandler.GetUV(kv.Value.lleft), kv.Value.color);
                    kv.Value.vertices.Add(v);
                }

                if(!voxs.ContainsKey(kv.Key + new VectorInt3(-1, 0, 0))){
                    VectorInt4 v = draw.addRect (Vector3.right, kv.Key, VoxelHandler.GetUV(kv.Value.right), VoxelHandler.GetUV(kv.Value.lright), kv.Value.color);
                    kv.Value.vertices.Add(v);
                }
            }
            //Resources.
            _mesh = draw.crateMeshFilter ("Static", _material);
            _mesh.gameObject.transform.SetParent (this._offset.transform);
            _mesh.gameObject.transform.localPosition = new Vector3 (0, 0, 0);

            _mesh.transform.localRotation = Quaternion.LookRotation(Vector3.up);
            _mesh.gameObject.SetActive (true);
            showMesh ();
        }
Esempio n. 3
0
		public void buildMesh (Vector3 position)
		{	
			VoxelDrawMesh draw = new VoxelDrawMesh ();
			Debug.Log (real_.Count + "count");
			foreach (KeyValuePair<VectorInt3, VoxelShadowHandler> kv in this.real_) {
				VectorInt4 v = draw.addRect (Vector3.up, kv.Key + new VectorInt3(0, 0, -1) , VoxelShadowHandler.GetUV(kv.Value.real), VoxelShadowHandler.GetUV(kv.Value.ghost), Color.black);
			}

			_mesh = draw.crateMeshFilter ("Shadow", _material);
			if (_offset != null) {
				_mesh.gameObject.transform.SetParent (this._offset.transform);
			} else {
				_mesh.gameObject.transform.SetParent (this.transform);		
			}
			
			_mesh.gameObject.transform.localPosition = Vector3.zero;
			_mesh.gameObject.transform.localScale = Vector3.one;
			_mesh.gameObject.transform.localRotation = Quaternion.Euler (Vector3.zero);
			
			_mesh.gameObject.SetActive (true);
			Renderer renderer = _mesh.GetComponent<Renderer> ();
			renderer.material = this._material;
			showMesh (position);
		}
Esempio n. 4
0
        public void buildMesh()
        {
            VoxelDrawMesh draw = new VoxelDrawMesh();

            Dictionary <VectorInt3, VoxelHandler> voxs = this.voxels;

            foreach (KeyValuePair <VectorInt3, VoxelHandler> kv in voxs)
            {
                if (!voxs.ContainsKey(kv.Key + new VectorInt3(0, -1, 0)))
                {
                    VectorInt4 v = draw.addRect(Vector3.back, kv.Key, VoxelHandler.GetUV(kv.Value.back), VoxelHandler.GetUV(kv.Value.lback), kv.Value.color);
                    kv.Value.vertices.Add(v);
                }

                if (!voxs.ContainsKey(kv.Key + new VectorInt3(0, 1, 0)))
                {
                    VectorInt4 v = draw.addRect(Vector3.forward, kv.Key, VoxelHandler.GetUV(kv.Value.front), VoxelHandler.GetUV(kv.Value.lfront), kv.Value.color);
                    kv.Value.vertices.Add(v);
                }

                if (!voxs.ContainsKey(kv.Key + new VectorInt3(0, 0, 1)))
                {
                    VectorInt4 v = draw.addRect(Vector3.up, kv.Key, VoxelHandler.GetUV(kv.Value.up), VoxelHandler.GetUV(kv.Value.lup), kv.Value.color);
                    kv.Value.vertices.Add(v);
                }


                if (!voxs.ContainsKey(kv.Key + new VectorInt3(0, 0, -1)))
                {
                    VectorInt4 v = draw.addRect(Vector3.down, kv.Key, VoxelHandler.GetUV(kv.Value.down), VoxelHandler.GetUV(kv.Value.ldown), kv.Value.color);
                    kv.Value.vertices.Add(v);
                }


                if (!voxs.ContainsKey(kv.Key + new VectorInt3(1, 0, 0)))
                {
                    VectorInt4 v = draw.addRect(Vector3.left, kv.Key, VoxelHandler.GetUV(kv.Value.left), VoxelHandler.GetUV(kv.Value.lleft), kv.Value.color);
                    kv.Value.vertices.Add(v);
                }


                if (!voxs.ContainsKey(kv.Key + new VectorInt3(-1, 0, 0)))
                {
                    VectorInt4 v = draw.addRect(Vector3.right, kv.Key, VoxelHandler.GetUV(kv.Value.right), VoxelHandler.GetUV(kv.Value.lright), kv.Value.color);
                    kv.Value.vertices.Add(v);
                }
            }
            //Resources.
            _mesh = draw.crateMeshFilter("VoxelMesh", _material);
            if (_offset != null)
            {
                _mesh.gameObject.transform.SetParent(this._offset.transform);
            }
            else
            {
                _mesh.gameObject.transform.SetParent(this.transform);
            }

            _mesh.gameObject.transform.localPosition = Vector3.zero;
            _mesh.gameObject.transform.localScale    = Vector3.one;
            _mesh.gameObject.transform.localRotation = Quaternion.Euler(Vector3.zero);

            _mesh.gameObject.SetActive(true);
            Renderer renderer = _mesh.GetComponent <Renderer> ();

            renderer.material = this._material;
            showMesh();
        }