Exemplo n.º 1
0
		public void SetBlocksWithMask (byte type, Geovox.Matrix3<bool> mask)
		{
			for (int x = mask.offsetX; x<mask.offsetX+mask.sizeX; x++) 
				for (int z = mask.offsetZ; z<mask.offsetZ+mask.sizeZ; z++)
			{
				//checking if this column needs to be set
				bool set = false;
				mask.SetPos(x,mask.offsetY,z);
				for (int y=mask.offsetY; y<mask.offsetY+mask.sizeY; y++)
				{
					if (mask.current) { set=true; break; }
					mask.MovePosNextY();
				}
				
				//setting
				if (set) WriteColumn(x,z).SetBlocksWithMask(type, mask, x, z);
			}
		}
Exemplo n.º 2
0
			/*public void FromMatrix (Matrix2<byte> matrix, int x) //for grass
				{
					list.Clear();
					matrix.SetPos(x, 0);
				
					byte curType = 255; //should be unequal to matrix.current

					for (int z=0; z<matrix.offsetZ+matrix.sizeZ; z++)
					{
						if (matrix.current != curType || list[list.Count-1] >= specialLevel) //if type changed or prev level is more than 245 - creating new list entry
						{
							curType = matrix.current;
						
							list.Add(curType); //type
							list.Add(0);	//depth
						}
					
						list[list.Count-1]++; //adding depth to last entry
						matrix.MovePosNextZ();
					}
				
					//removing top level
					while (list.Count != 0 && list[list.Count-2]==0)
						list.RemoveRange(list.Count-2, 2);
				}*/
			
			public void SetBlocksWithMask (byte t, Geovox.Matrix3<bool> mask, int x, int z)
			{
				ToMatrix(setBlockMatrix, 0,0);
				
				mask.SetPos(x,mask.offsetY,z);
				setBlockMatrix.SetPos(0,mask.offsetY,0);
				
				for (int y=mask.offsetY; y<mask.offsetY+mask.sizeY; y++)
				{
					if (mask.current) setBlockMatrix[0,y,0] = t;
					mask.MovePosNextY();
					setBlockMatrix.MovePosNextY();
				}
				
				FromMatrix(setBlockMatrix, 0,0);
			}
Exemplo n.º 3
0
			public void ToExistMatrix (Geovox.Matrix3<byte> matrix, bool[] exist, int x, int z) //0 if block is empty, 255 if filled
			{
				matrix.SetPos(x, matrix.offsetY, z);
				
				//resetting matrix if column empty
				if(list.Count==0)
				{
					for(int y=matrix.offsetY;y<matrix.offsetY+matrix.sizeY;y++)
					{
						matrix.current = 0;
						matrix.MovePosNextY();
					}
					return;
				}
				
				//writing byte column to matrix
				int i = 0;
				int curMaxLevel = GetLevel(0);
				byte curType = GetType(0);
				
				for(int y=0; y<matrix.offsetY+matrix.sizeY; y++) //starting from 0, not from offsetY
				{
					//changing cur type if reached type max level
					if(y >= curMaxLevel)
					{
						i++;
						
						if(i >= count) curType = 0;
						else
						{
							curType = GetType(i);
							if (curType >= exist.Length) curType = 0;
							curMaxLevel += GetLevel(i);
						}
					}
					
					//filling matrix
					if(y >= matrix.offsetY)
					{
						//matrix.current = exist[curType] ? 255 | 0;
						if (curType>=exist.Length) curType=0;
						
						if (exist[curType]) matrix.current = 255;
						else matrix.current = 0;
						
						matrix.MovePosNextY();
					}
				}
			}
Exemplo n.º 4
0
			public void FromMatrix (Geovox.Matrix3<byte> matrix, int x, int z)
			{
				list.Clear();
				matrix.SetPos(x, 0, z);
				
				byte curType = 255; //should be unequal to matrix.current
				
				for (int y=0; y<matrix.offsetY+matrix.sizeY; y++)
				{
					if (matrix.current != curType || list[list.Count-1] >= specialLevel) //if type changed or prev level is more than 245 - creating new list entry
					{
						curType = matrix.current;
						
						list.Add(curType); //type
						list.Add(0);	//depth
					}
					
					list[list.Count-1]++; //adding depth to last entry
					matrix.MovePosNextY();
				}
				
				//removing top level
				while (list.Count != 0 && list[list.Count-2]==0)
					list.RemoveRange(list.Count-2, 2);
			}
Exemplo n.º 5
0
			public void ToMatrix (Geovox.Matrix3<byte> matrix, int x, int z) 
			{
				matrix.SetPos(x, matrix.offsetY, z);
				
				//resetting matrix if column empty
				if(list.Count==0)
				{
					for(int y=matrix.offsetY;y<matrix.offsetY+matrix.sizeY;y++)
					{
						matrix.current = 0;
						matrix.MovePosNextY();
					}
					return;
				}
				
				//writing byte column to matrix
				int i = 0;
				int curMaxLevel = GetLevel(0);
				byte curType = GetType(0);
				
				for(int y=0; y<matrix.offsetY+matrix.sizeY; y++) //starting from 0, not from offsetY
				{
					//changing cur type if reached type max level
					if(y >= curMaxLevel)
					{
						i++;
						
						if(i >= count) curType = 0;
						else
						{
							curType = GetType(i);
							curMaxLevel += GetLevel(i);
						}
					}
					
					//filling matrix
					if(y >= matrix.offsetY)
					{
						matrix.current = curType;
						matrix.MovePosNextY();
					}
				}
			}