Exemple #1
0
        private void toShadow(VectorInt3 position, VoxelHandler handler, bool spot = false)
        {
            VoxelShadowHandler vsh = null;

            bool glost = (handler.position.z != 0);

            position.z = 0;

            if (real_.ContainsKey(position))
            {
                vsh = real_ [position];
            }
            else
            {
                vsh              = new VoxelShadowHandler();
                vsh._position    = position;
                vsh._realSpot    = false;
                vsh._ghostSpot   = false;
                real_ [position] = vsh;
            }

            if (!glost)
            {
                vsh._realSpot  = vsh._realSpot || spot;
                vsh._ghostSpot = vsh._ghostSpot || spot;
            }
            else
            {
                vsh._ghostSpot = vsh._ghostSpot || spot;
            }
        }
Exemple #2
0
        private void shadowTest(VectorInt3 offset, VoxelShadowHandler handler, byte index)
        {
            var voxs = this.real_;

            if (handler._realSpot)
            {
                handler.realAdd(index);
            }

            VectorInt3 key = offset;

            if (voxs.ContainsKey(key))
            {
                VoxelShadowHandler o = voxs[key];
                if (o._realSpot)
                {
                    handler.realAdd(index);
                }
            }

            if (handler._ghostSpot)
            {
                if (!voxs.ContainsKey(key))
                {
                    handler.ghostAdd(index);
                }
                else
                {
                    VoxelShadowHandler o = voxs [key];
                    if (!o._ghostSpot)
                    {
                        handler.ghostAdd(index);
                    }
                }
            }
            else
            {
                handler.ghostAdd(index);
            }
        }
Exemple #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);
        }
Exemple #4
0
		private void shadowTest(VectorInt3 offset, VoxelShadowHandler handler, byte index){


			var voxs = this.real_;
			if (handler._realSpot) {
				handler.realAdd (index);
			}
		
			VectorInt3 key = offset;
			if (voxs.ContainsKey (key)) {
				VoxelShadowHandler o = voxs[key];
				if(o._realSpot){
					handler.realAdd (index);	
				}

			} 

			if (handler._ghostSpot) {
					if (!voxs.ContainsKey (key)) {
							handler.ghostAdd (index);	
					} else {
							VoxelShadowHandler o = voxs [key];
							if (!o._ghostSpot) {
									handler.ghostAdd (index);	
							}

					}

			} else {
				handler.ghostAdd (index);	
			}
		}
Exemple #5
0
		private void toShadow(VectorInt3 position, VoxelHandler handler, bool spot = false){
			
			VoxelShadowHandler vsh = null;

			bool glost = (handler.position.z != 0);
			position.z = 0;

			if (real_.ContainsKey (position)) {
				vsh = real_ [position];
			} else {
				vsh = new VoxelShadowHandler ();
				vsh._position = position;
				vsh._realSpot = false;
				vsh._ghostSpot = false;
				real_ [position] = vsh;	
			}

			if (!glost) 
			{
				vsh._realSpot = vsh._realSpot || spot;	
				vsh._ghostSpot = vsh._ghostSpot || spot;
			} else 
			{
				vsh._ghostSpot = vsh._ghostSpot || spot;
			}
		

		}