コード例 #1
0
ファイル: genesis.cs プロジェクト: d3x0r/Voxelarium
		void GenerateZone_Generic_MappedTerrain( VoxelSector VoxelSector, ushort TerrainVoxelType, GenericCharCanvas TerrainMap, int Offset )
		{
			int x, y, z, Voxel_y, Deep;
			int Sector_y;
			ushort VoxelType;
			int height;
			ZVector3L ZonePos;



			int ZoneSize = TerrainMap.Width; // Must also change it in the function giving the Zone Height.
			int ZoneMaxIndex = ZoneSize - 1;

			Sector_y = VoxelSector.Pos_y;
			ZonePos.x = ( ( VoxelSector.Pos_x << VoxelSector.ZVOXELBLOCSHIFT_X ) + Offset ) & ZoneMaxIndex;
			ZonePos.z = ( ( VoxelSector.Pos_z << VoxelSector.ZVOXELBLOCSHIFT_Z ) + Offset ) & ZoneMaxIndex;
			ZonePos.y = ( VoxelSector.Pos_y << VoxelSector.ZVOXELBLOCSHIFT_Y );

			for( z = 0; z < VoxelSector.ZVOXELBLOCSIZE_Z; z++ )
				for( x = 0; x < VoxelSector.ZVOXELBLOCSIZE_X; x++ )
				{

					height = TerrainMap.GetPoint_Fast( ZoneMaxIndex - ( ZonePos.x + x ), ZonePos.z + z );

					for( y = 0, Voxel_y = Sector_y << VoxelSector.ZVOXELBLOCSHIFT_Y; y < VoxelSector.ZVOXELBLOCSIZE_Y; y++, Voxel_y++ )
					{
						Deep = Voxel_y - height;
						VoxelType = 0;

						if( Deep >= 0 ) VoxelType = 0;
						else VoxelType = TerrainVoxelType; //54;

						VoxelSector.SetCube( x, y, z, VoxelType );
					}
				}
		}
コード例 #2
0
ファイル: genesis.cs プロジェクト: d3x0r/Voxelarium
		void Generate_Generic_PlaceVoxel( VoxelSector Sector, ushort VoxelType, GenericCharCanvas LocationMap, int Offset, int RelativeHeight, bool SetActiveSector )
		{
			int x, z, xs, ys, zs, GenerationRadius;
			SaltyRandomGenerator Random = new SaltyRandomGenerator();
			//int Seed;
			ushort ZoneType = 0;
			// uint RandNum, Ratio;


			xs = Sector.Pos_x << VoxelSector.ZVOXELBLOCSHIFT_X;
			ys = Sector.Pos_y << VoxelSector.ZVOXELBLOCSHIFT_Y;
			zs = Sector.Pos_z << VoxelSector.ZVOXELBLOCSHIFT_Z;
			//Seed = xs + 3524*ys + 234 * zs;

			uint SizeMask;
			SizeMask = (uint)( LocationMap.Width - 1 );

			GenerationRadius = 0;

			for( x = xs - GenerationRadius; x < ( xs + 16 + GenerationRadius ); x++ )
				for( z = zs - GenerationRadius; z < ( zs + 16 + GenerationRadius ); z++ )
				{
					// if ((RandNum = Random.GetNumber( abs(x) + ( abs(z) << 8 ) )) < (Ratio)) // 6
					// if ( (((x & 31) == 0) && ((z & 31) == 0)) )
					if( LocationMap.GetPoint_Fast( (int)( SizeMask - ( ( x + Offset ) & SizeMask )), (int)(( z + Offset ) & SizeMask) ) > 128 )
					{
						ZVector3L Position;

						Position.x = x - xs;
						Position.z = z - zs;
						Position.y = ( GetZoneHeight( x, z, ZoneType ) - ys ) + RelativeHeight;

						if( Position.y < 64 && Position.y > 0 )
						{
							Sector.SetCube( Position.x, Position.y, Position.z, VoxelType );
							if( SetActiveSector ) Sector.Flag_IsActiveVoxels = true;
						}

					}
				}
		}
コード例 #3
0
ファイル: genesis.cs プロジェクト: d3x0r/Voxelarium
		void GenerateZone_MathStruct_1( VoxelSector VoxelSector, int HeightOffset, int Sector_x, int Sector_y, int Sector_z )
		{
			int x, y, z, Voxel_y, Deep;
			ushort VoxelType;

			for( z = 0; z < VoxelSector.ZVOXELBLOCSIZE_Z; z++ )
				for( x = 0; x < VoxelSector.ZVOXELBLOCSIZE_X; x++ )
				{
					double sx = ( ( ( Sector_x & 15 ) << 4 ) + x ); //Sx and Sz range from 0 to 255
					double sz = ( ( ( Sector_z & 15 ) << 4 ) + z );

					if( sx > 128 ) sx = 256 - sx;
					if( sz > 128 ) sz = 256 - sz;
					//uint height = sin(sx/81.487330852) * sin(sz/81.487330852) * 50 - 1 ;
					//uint height = sin(sx/81.487330852) * sin(sz/81.487330852) * ( sx * sz / 20.0 );
					//uint height = sin(sx/(81.487330852/4.0)) * sin(sz/(81.487330852/4.0)) * ( sx * sz / 20.0 );
					uint height = (uint)( Math.Sin( Math.Sin( sx / ( 81.487330852 ) ) * Math.Sin( sz / ( 81.487330852 ) ) * 50.0 ) * ( sx * sz / 100.0 ) ) + (uint)HeightOffset;


					// height = Sector_x + Sector_z;
					for( y = 0, Voxel_y = Sector_y << VoxelSector.ZVOXELBLOCSHIFT_Y; y < VoxelSector.ZVOXELBLOCSIZE_Y; y++, Voxel_y++ )
					{
						Deep = Voxel_y - (int)height;
						VoxelType = 0;

						if( Deep >= 0 ) VoxelType = 0;
						else VoxelType = 53;
						VoxelSector.SetCube( x, y, z, VoxelType );
					}
				}
		}
コード例 #4
0
ファイル: genesis.cs プロジェクト: d3x0r/Voxelarium
		void GenerateZone_Mountains( VoxelSector VoxelSector, int Sector_x, int Sector_y, int Sector_z )
		{
			int x, y, z;

			int Voxel_y, Deep;
			ushort VoxelType;
			RandomGen.Reset();
			for( z = 0; z < VoxelSector.ZVOXELBLOCSIZE_Z; z++ )
				for( x = 0; x < VoxelSector.ZVOXELBLOCSIZE_X; x++ )
				{
					int Cube_x = ( Math.Abs( Sector_x ) << VoxelSector.ZVOXELBLOCSHIFT_X ) | x;
					int Cube_z = ( Math.Abs( Sector_z ) << VoxelSector.ZVOXELBLOCSHIFT_Z ) | z;
					int F1 = Sector_x >> 2;
					int F1p = ( Sector_x + 1 ) >> 2;

					double F1_Coef = ( Cube_x & 0x3F ) / 64.0;
					int F2 = Sector_z >> 2;
					int F2p = ( Sector_z + 1 ) >> 2;
					double F2_Coef = ( Cube_z & 0x3F ) / 64.0;

					random_seed[0] = F1;
					random_seed[1] = F2;
					random_seed[2] = F1p;
					random_seed[3] = F2p;

					double Mult1_1 = ( (double)RandomGen.GetEntropy( 16, true ) ) / 163.0;
					double Mult1_2 = ( (double)RandomGen.GetEntropy( 16, true ) ) / 163.0;
					double Mult1 = Mult1_1 * F1_Coef + Mult1_2 * ( 1.0 - F1_Coef );

					double Mult2_1 = ( (double)RandomGen.GetEntropy( 16, true ) ) / 163.0;
					double Mult2_2 = ( (double)RandomGen.GetEntropy( 16, true ) ) / 163.0;
					double Mult2 = Mult2_1 * F2_Coef + Mult2_2 * ( 1.0 - F2_Coef );



					uint height = (uint)( Math.Sin( ( (double)x + ( Sector_x << VoxelSector.ZVOXELBLOCSHIFT_X ) ) / Mult1 ) * Math.Sin( ( (double)z + ( Sector_z << VoxelSector.ZVOXELBLOCSHIFT_Z ) ) / Mult2 ) * 25.0 );
					for( y = 0, Voxel_y = Sector_y << VoxelSector.ZVOXELBLOCSHIFT_Y; y < VoxelSector.ZVOXELBLOCSIZE_Y; y++, Voxel_y++ )
					{
						Deep = Voxel_y - (int)height;
						VoxelType = 0;

						if( Deep >= 0 ) { VoxelType = 0; }
						else if( Deep < -1536 ) { VoxelType = 43; }
						else if( Deep < -1280 ) { VoxelType = 10; }
						else if( Deep < -1024 ) { VoxelType = 5; }
						else if( Deep < -768 ) { VoxelType = 4; }
						else if( Deep < -512 ) { VoxelType = 6; }
						else if( Deep < -256 ) { VoxelType = 7; }
						else if( Deep < -128 ) { VoxelType = 2; }
						else if( Deep < -32 ) { VoxelType = 3; }
						else if( Deep < 0 ) { VoxelType = 1; }
						else VoxelType = 0;

						if( VoxelType != 0 && height > 20 ) VoxelType = 10;

						VoxelSector.SetCube( x, y, z, VoxelType );
					}
				}
		}
コード例 #5
0
ファイル: InternalGenesis.cs プロジェクト: d3x0r/Voxelarium
		void GenerateZone_RandomStickSea( VoxelSector VoxelSector, int HeightOffset, int Sector_x, int Sector_y, int Sector_z )
		{
			int x, y, z, Voxel_y, Deep;
			ushort VoxelType;
			int height;

			for( z = 0; z < VoxelSector.ZVOXELBLOCSIZE_Z; z++ )
				for( x = 0; x < VoxelSector.ZVOXELBLOCSIZE_X; x++ )
				{
					float sx = ( ( ( Sector_x & 15 ) << 4 ) + x ); //Sx and Sz range from 0 to 255
					float sz = ( ( ( Sector_z & 15 ) << 4 ) + z );
					height = (int)( ( RandomGen.GetNumber( (uint)sx ) + RandomGen.GetNumber( (uint)sz ) ) % 15 ) + HeightOffset;

					for( y = 0, Voxel_y = Sector_y << VoxelSector.ZVOXELBLOCSHIFT_Y; y < VoxelSector.ZVOXELBLOCSIZE_Y; y++, Voxel_y++ )
					{
						Deep = Voxel_y - height;
						VoxelType = 0;

						if( Deep >= 0 ) VoxelType = 0;
						else VoxelType = 54;

						VoxelSector.SetCube( x, y, z, VoxelType );
					}
				}
		}
コード例 #6
0
ファイル: genesis.cs プロジェクト: d3x0r/Voxelarium
		void GenerateZone_RandomStickSea( VoxelSector VoxelSector, int HeightOffset, int Sector_x, int Sector_y, int Sector_z )
		{
			int x, y, z, Voxel_y, Deep;
			ushort VoxelType;
			int height;

			RandomGen.Reset();
			random_seed[2] = 0;
			random_seed[3] = 0;
			for( z = 0; z < VoxelSector.ZVOXELBLOCSIZE_Z; z++ )
				for( x = 0; x < VoxelSector.ZVOXELBLOCSIZE_X; x++ )
				{
					double sx = ( ( ( Sector_x & 15 ) << 4 ) + x ); //Sx and Sz range from 0 to 255
					double sz = ( ( ( Sector_z & 15 ) << 4 ) + z );
					random_seed[0] = (int)sx;
					random_seed[1] = (int)sz;
					height = ( RandomGen.GetEntropy( 4, false ) % 15 ) + HeightOffset;

					for( y = 0, Voxel_y = Sector_y << VoxelSector.ZVOXELBLOCSHIFT_Y; y < VoxelSector.ZVOXELBLOCSIZE_Y; y++, Voxel_y++ )
					{
						Deep = Voxel_y - height;
						VoxelType = 0;

						if( Deep >= 0 ) VoxelType = 0;
						else VoxelType = 54;

						VoxelSector.SetCube( x, y, z, VoxelType );
					}
				}
		}
コード例 #7
0
ファイル: genesis.cs プロジェクト: d3x0r/Voxelarium
		void GenerateZone_BlackWoods( VoxelSector VoxelSector, int Sector_x, int Sector_y, int Sector_z )
		{
			int x, y, z, Voxel_y, Deep;
			ushort VoxelType;
			int height;
			float P1, P2, P3, P4;

			RandomGen.Reset();
			random_seed[0] = Sector_x;
			random_seed[1] = Sector_z;
			random_seed[2] = 0;
			random_seed[3] = 0;
			for( z = 0; z < VoxelSector.ZVOXELBLOCSIZE_Z; z++ )
				for( x = 0; x < VoxelSector.ZVOXELBLOCSIZE_X; x++ )
				{
					int sx = ( Sector_x << VoxelSector.ZVOXELBLOCSHIFT_X ) + x;
					int sz = ( Sector_z << VoxelSector.ZVOXELBLOCSHIFT_Z ) + z;
					float Coef1 = ( sx % 16 ) * ( 1.0f / 16.0f );
					float Coef2 = ( sz % 16 ) * ( 1.0f / 16.0f );

					P1 = ( RandomGen.GetEntropy( 5, true ) ) % 30;
					P2 = ( RandomGen.GetEntropy( 5, true ) ) % 30;
					P3 = ( RandomGen.GetEntropy( 5, true ) ) % 30;
					P4 = ( RandomGen.GetEntropy( 5, true ) ) % 30;

					height = (int)Interpolation_2d( P1, P2, P3, P4, Coef1, Coef2 ) - 15 + BlackWoods_Level;

					// height = (RandomGen.GetNumber(sx) + RandomGen.GetNumber(sz) ) % 15;

					for( y = 0, Voxel_y = Sector_y << VoxelSector.ZVOXELBLOCSHIFT_Y; y < VoxelSector.ZVOXELBLOCSIZE_Y; y++, Voxel_y++ )
					{
						Deep = Voxel_y - height;
						VoxelType = 0;

						if( Deep >= 0 ) VoxelType = 0;
						else VoxelType = 66;

						VoxelSector.SetCube( x, y, z, VoxelType );
					}
				}
		}
コード例 #8
0
ファイル: genesis.cs プロジェクト: d3x0r/Voxelarium
		void Generate_Terrain_1538( VoxelSector VoxelSector, int HeightOffset, int Sector_x, int Sector_y, int Sector_z )
		{
			int x, y, z, nx, ny, nz;
			ushort VoxelType;
			float dns, cns, reduce, Coef1, Coef2, Coef3;
			float[] P = new float[8], C = new float[8];
			VoxelSector.Flag_NeedSortedRendering = true;

			ushort[] Textures = new ushort[16];
			Textures[0] = 232; // 1
			Textures[1] = 233; // 12
			Textures[2] = 233; // 14
							   /*
								 Textures[0] = 1; // 1
								 Textures[1] = 2; // 12
								 Textures[2] = 3; // 14
							   */
			int sx = ( ( Sector_x + 8192 ) << VoxelSector.ZVOXELBLOCSHIFT_X );
			int sy = ( ( Sector_y + 8192 ) << VoxelSector.ZVOXELBLOCSHIFT_Y );
			int sz = ( ( Sector_z + 8192 ) << VoxelSector.ZVOXELBLOCSHIFT_Z );
			RandomGen.Reset();
			random_seed[0] = sx;
			random_seed[1] = sz;
			random_seed[2] = sx;
			random_seed[3] = 0;

			for( z = 0; z < VoxelSector.ZVOXELBLOCSIZE_Z; z++ )
				for( x = 0; x < VoxelSector.ZVOXELBLOCSIZE_X; x++ )
					for( y = 0; y < VoxelSector.ZVOXELBLOCSIZE_Y; y++ )
					{
						nx = sx + x;
						ny = sy + y;
						nz = sz + z;

						P[0] = ( RandomGen.GetEntropy( 5, false ) ) % 30;
						P[1] = ( RandomGen.GetEntropy( 5, false ) ) % 30;
						P[2] = ( RandomGen.GetEntropy( 5, false ) ) % 30;
						P[3] = ( RandomGen.GetEntropy( 5, false ) ) % 30;
						P[4] = ( RandomGen.GetEntropy( 5, false ) ) % 30;
						P[5] = ( RandomGen.GetEntropy( 5, false ) ) % 30;
						P[6] = ( RandomGen.GetEntropy( 5, false ) ) % 30;
						P[7] = ( RandomGen.GetEntropy( 5, false ) ) % 30;
						Coef1 = ( ( sx + x ) % 16 ) * ( 1.0f / 16.0f );
						Coef3 = ( ( sy + y ) % 16 ) * ( 1.0f / 16.0f );
						Coef2 = ( ( sz + z ) % 16 ) * ( 1.0f / 16.0f );
						dns = Interpolation_3d( P, Coef1, Coef2, Coef3 );

						C[0] = ( RandomGen.GetEntropy( 5, false ) ) % 30;
						C[1] = ( RandomGen.GetEntropy( 5, false ) ) % 30;
						C[2] = ( RandomGen.GetEntropy( 5, false ) ) % 30;
						C[3] = ( RandomGen.GetEntropy( 5, false ) ) % 30;
						C[4] = ( RandomGen.GetEntropy( 5, false ) ) % 30;
						C[5] = ( RandomGen.GetEntropy( 5, false ) ) % 30;
						C[6] = ( RandomGen.GetEntropy( 5, false ) ) % 30;
						C[7] = ( RandomGen.GetEntropy( 5, false ) ) % 30;

						Coef3 = ( ( sy + y + 1 ) % 16 ) * ( 1.0f / 16.0f );
						cns = Interpolation_3d( C, Coef1, Coef2, Coef3 );

						VoxelType = Textures[(uint)( ( cns / 20.0 ) )];

						// Aspérités.

						dns *= (float)( 1.0 + 0.4 * ( Math.Sin( nx / ( 1.3 ) ) * Math.Sin( ny / ( 2.8 ) ) * Math.Sin( nz / ( 1.63 ) ) ) );
						cns *= (float)( 1.0 + 0.4 * ( Math.Sin( nx / ( 1.3 ) ) * Math.Sin( ny / ( 2.8 ) ) * Math.Sin( nz / ( 1.63 ) ) ) );
						// VoxelType = 32768;
						reduce = (float)( ( (double)( sy + y + ( -524288 + 20 ) - HeightOffset ) ) / 10.0 ); // 5.0
						if( reduce < 0.0 ) reduce = 0;
						dns -= reduce;
						cns -= reduce;
						if( dns < 15.0 ) { dns = 0; VoxelType = 0; } //15.0
						else
						{
							if( ( dns - cns ) > 0.3 ) VoxelType = Textures[0];
							else if( dns - cns < -0.2 ) VoxelType = Textures[2];
							else { VoxelType = Textures[1]; if( ( RandomGen.GetEntropy( 10, false ) ) < 256 ) VoxelType = 46; }
						}

						// if (Sector_y > 1) VoxelType = 0;
						VoxelSector.SetCube( x, y, z, VoxelType );
					}
		}
コード例 #9
0
ファイル: genesis.cs プロジェクト: d3x0r/Voxelarium
		void GenerateZone_LavaRiver( VoxelSector VoxelSector )
		{
			ZVector3L Zone, SectorStart;
			GenericCharCanvas RiverCanva = new GenericCharCanvas();
			int x, y, z;
			byte Draw;
			int Depth;
			ushort VoxelType;

			int RiverSize = 48;
			int RiverDepth = 64;


			RiverCanva.SetSize( 256, 256 );
			Zone.x = ( VoxelSector.Pos_x >> ( 8 - VoxelSector.ZVOXELBLOCSHIFT_X ) ) + ( Z_GENESISMAP_SIZE >> 1 );
			Zone.z = ( VoxelSector.Pos_z >> ( 8 - VoxelSector.ZVOXELBLOCSHIFT_Z ) ) + ( Z_GENESISMAP_SIZE >> 1 );

			SectorStart.x = ( VoxelSector.Pos_x << VoxelSector.ZVOXELBLOCSHIFT_X ) & 255;
			SectorStart.z = ( VoxelSector.Pos_z << VoxelSector.ZVOXELBLOCSHIFT_Z ) & 255;
			SectorStart.y = ( VoxelSector.Pos_y << VoxelSector.ZVOXELBLOCSHIFT_Y );

			RiverCanva.Clear();

			if( ConvCN[ZoneMap_New[Zone.x - 1][Zone.z]] == 7 ) RiverCanva.DrawBox( 0, 128 - RiverSize / 2, 127, 128 + RiverSize / 2, 1 );
			if( ConvCN[ZoneMap_New[Zone.x + 1][Zone.z]] == 7 ) RiverCanva.DrawBox( 128, 128 - RiverSize / 2, 255, 128 + RiverSize / 2, 1 );
			if( ConvCN[ZoneMap_New[Zone.x][Zone.z - 1]] == 7 ) RiverCanva.DrawBox( 128 - RiverSize / 2, 0, 128 + RiverSize / 2, 127, 1 );
			if( ConvCN[ZoneMap_New[Zone.x][Zone.z + 1]] == 7 ) RiverCanva.DrawBox( 128 - RiverSize / 2, 128, 128 + RiverSize / 2, 255, 1 );
			RiverCanva.DrawCircleFilled( 128, 128, (float)( (double)RiverSize ) / 2.0f, 1, 1.0f );

			//RiverCanva.DebugDump();
			for( x = 0; x < VoxelSector.ZVOXELBLOCSIZE_X; x++ )
			{
				for( z = 0; z < VoxelSector.ZVOXELBLOCSIZE_Z; z++ )
				{
					Draw = RiverCanva.GetPoint_Fast( SectorStart.x + x, SectorStart.z + z );
					for( y = 0; y < VoxelSector.ZVOXELBLOCSIZE_Y; y++ )
					{
						Depth = SectorStart.y + y;

						VoxelType = 0;
						if( Draw > 0 )
						{
							if( Depth < ( -RiverDepth ) ) VoxelType = 52;
						}
						else if( Depth < 0 ) VoxelType = 3;
						VoxelSector.SetCube( x, y, z, VoxelType );
					}
				}

			}

		}
コード例 #10
0
ファイル: genesis.cs プロジェクト: d3x0r/Voxelarium
		void GenerateZone_BigMountains( VoxelSector VoxelSector, int HeightOffset, int Sector_x, int Sector_y, int Sector_z )
		{
			int x, y, z, Voxel_y, Deep;
			ushort VoxelType;
			int height, height2, sx, sz;

			sx = Sector_x << VoxelSector.ZVOXELBLOCSHIFT_X;
			sz = Sector_z << VoxelSector.ZVOXELBLOCSHIFT_Z;
			RandomGen.Reset();
			random_seed[2] = 0;
			random_seed[3] = 0;
			random_seed[0] = Sector_x;
			random_seed[1] = Sector_z;

			for( z = 0; z < VoxelSector.ZVOXELBLOCSIZE_Z; z++ )
				for( x = 0; x < VoxelSector.ZVOXELBLOCSIZE_X; x++ )
				{
					// Linear altitude augmentation

					height = (int)GetHeightMap( sx + x, sz + z ) * 100;

					// Chaotic relief
					sx = ( Sector_x << VoxelSector.ZVOXELBLOCSHIFT_X ) + x;
					sz = ( Sector_z << VoxelSector.ZVOXELBLOCSHIFT_Z ) + z;
					float Coef1 = ( sx % 16 ) * ( 1.0f / 16.0f );
					float Coef2 = ( sz % 16 ) * ( 1.0f / 16.0f );
					float P1, P2, P3, P4;
					P1 = ( RandomGen.GetEntropy( 5, true ) ) % 30;
					P2 = ( RandomGen.GetEntropy( 5, true ) ) % 30;
					P3 = ( RandomGen.GetEntropy( 5, true ) ) % 30;
					P4 = ( RandomGen.GetEntropy( 5, true ) ) % 30;

					height2 = (int)Interpolation_2d( P1 + height, P2 + height, P3 + height, P4 + height, Coef1, Coef2 ) - 15;

					if( height < 16.0 ) height2 = (int)( height2 * ( (float)height / 16.0f ) );


					height = height2 + HeightOffset;


					// height = (RandomGen.GetNumber(sx) + RandomGen.GetNumber(sz) ) % 15;

					for( y = 0, Voxel_y = Sector_y << VoxelSector.ZVOXELBLOCSHIFT_Y; y < VoxelSector.ZVOXELBLOCSIZE_Y; y++, Voxel_y++ )
					{
						Deep = Voxel_y - height;
						VoxelType = 0;

						if( Deep >= 0 ) VoxelType = 0;
						else VoxelType = 54;

						VoxelSector.SetCube( x, y, z, VoxelType );
					}
				}
		}
コード例 #11
0
ファイル: genesis.cs プロジェクト: d3x0r/Voxelarium
		/*
		void GenerateZone_WaterLands(ZVoxelSector * VoxelSector, int HeightOffset, int Sector_x, int Sector_y, int Sector_z)
		{
		  int x,y,z, Voxel_y, Deep;
		  ushort VoxelType;
		  int height;
		  double P1, P2,P3,P4;
		  // ZGenericByteCanva Canva;
		  ZVector3L SectorStart;
		  byte Stencil;
		  //ZLineCoords LineCoords;

		  SectorStart.x = (VoxelSector.Pos_x << VoxelSector.ZVOXELBLOCSHIFT_X) & 255;
		  SectorStart.z = (VoxelSector.Pos_z << VoxelSector.ZVOXELBLOCSHIFT_Z) & 255;
		  SectorStart.y = (VoxelSector.Pos_y << VoxelSector.ZVOXELBLOCSHIFT_Y);

		  VoxelSector.Flag_IsActiveVoxels = true;

		  for (z=0 ; z<ZVOXELBLOCSIZE_Z ; z++)
			for (x=0 ; x<ZVOXELBLOCSIZE_X ; x++)
			{
			  uint sx = (Sector_x << VoxelSector.ZVOXELBLOCSHIFT_X) + x;
			  uint sz = (Sector_z << VoxelSector.ZVOXELBLOCSHIFT_Z) + z;
			  uint rx = sx >> 4; double Coef1 = (sx % 16) * (1.0 / 16.0);
			  uint rz = sz >> 4; double Coef2 = (sz % 16) * (1.0 / 16.0);

			  P1 = (RandomGen.GetNumber(rx) + RandomGen.GetNumber(rz) ) % 30 ;
			  P2 = (RandomGen.GetNumber(rx+1) + RandomGen.GetNumber(rz) ) % 30 ;
			  P3 = (RandomGen.GetNumber(rx) + RandomGen.GetNumber(rz+1) ) % 30 ;
			  P4 = (RandomGen.GetNumber(rx+1) + RandomGen.GetNumber(rz+1) ) % 30 ;

			  height = Interpolation_2d(P1,P2,P3,P4,Coef1,Coef2) - 15 + HeightOffset;

			  // height = (RandomGen.GetNumber(sx) + RandomGen.GetNumber(sz) ) % 15;

			  Stencil = Canva_1.GetPoint_Fast( SectorStart.x + x, SectorStart.z + z );

			  for (y=0, Voxel_y = Sector_y << VoxelSector.ZVOXELBLOCSHIFT_Y ; y<ZVOXELBLOCSIZE_Y ; y++, Voxel_y++)
			  {
				Deep = Voxel_y - height;
				VoxelType = 0;

				if (Deep >=0)
				{
				  if (Voxel_y > 0) VoxelType = 0;
				  else VoxelType = 0;
				}
				else          VoxelType = 3;

				if (Stencil==0)
				{
				  if (Voxel_y < -10 && Voxel_y >=-20 )  VoxelType = 85;//86;
				  else if (Voxel_y < -20 ) VoxelType = 3;
				  else               VoxelType = 0;
				}

				VoxelSector.SetCube(x,y,z, VoxelType);
			  }
			}
		}
		*/

		void GenerateZone_AcidHills( VoxelSector VoxelSector, int HeightOffset, int Sector_x, int Sector_y, int Sector_z )
		{
			int x, y, z, Voxel_y, Deep;
			ushort VoxelType;
			int height;
			float P1, P2, P3, P4;
			//  ZGenericByteCanva Canva;
			ZVector3L SectorStart;
			byte Stencil;
			//  ZLineCoords LineCoords;

			/*
			  Canva.SetSize(256,256);
			  Canva.Clear(0);
			  // Canva.DrawCircleFilled(128.0,128.0,128.0,1);
			  Canva.Polygon_Start();
			  LineCoords = {{0.0  ,128.0},{128.0,255.0}}; Canva.Polygon_Segment(&LineCoords);
			  LineCoords = {{128.0,255.0},{255.0,128.0}}; Canva.Polygon_Segment(&LineCoords);
			  LineCoords = {{255.0,128.0},{128.0,0.0  }}; Canva.Polygon_Segment(&LineCoords);
			  LineCoords = {{128.0,0.0  },{0.0,128.0  }}; Canva.Polygon_Segment(&LineCoords);
			  Canva.Polygon_Render(1);
			*/


			SectorStart.x = ( VoxelSector.Pos_x << VoxelSector.ZVOXELBLOCSHIFT_X ) & 255;
			SectorStart.z = ( VoxelSector.Pos_z << VoxelSector.ZVOXELBLOCSHIFT_Z ) & 255;
			SectorStart.y = ( VoxelSector.Pos_y << VoxelSector.ZVOXELBLOCSHIFT_Y );

			VoxelSector.Flag_IsActiveVoxels = true;
			RandomGen.Reset();
			random_seed[2] = 0;
			random_seed[3] = 0;

			for( z = 0; z < VoxelSector.ZVOXELBLOCSIZE_Z; z++ )
				for( x = 0; x < VoxelSector.ZVOXELBLOCSIZE_X; x++ )
				{
					int sx = ( Sector_x << VoxelSector.ZVOXELBLOCSHIFT_X ) + x;
					int sz = ( Sector_z << VoxelSector.ZVOXELBLOCSHIFT_Z ) + z;
					int rx = sx >> 4; float Coef1 = ( sx % 16 ) * ( 1.0f / 16.0f );
					int rz = sz >> 4; float Coef2 = ( sz % 16 ) * ( 1.0f / 16.0f );

					random_seed[0] = rx;
					random_seed[1] = rz;
					P1 = ( RandomGen.GetEntropy( 6, true ) ) % 30;
					P2 = ( RandomGen.GetEntropy( 6, true ) ) % 30;
					P3 = ( RandomGen.GetEntropy( 6, true ) ) % 30;
					P4 = ( RandomGen.GetEntropy( 6, true ) ) % 30;

					height = (int)Interpolation_2d( P1, P2, P3, P4, Coef1, Coef2 ) - 15;

					// height = (RandomGen.GetNumber(sx) + RandomGen.GetNumber(sz) ) % 15;

					Stencil = Canva_1.GetPoint_Fast( SectorStart.x + x, SectorStart.z + z );

					for( y = 0, Voxel_y = ( Sector_y << VoxelSector.ZVOXELBLOCSHIFT_Y ) - HeightOffset; y < VoxelSector.ZVOXELBLOCSIZE_Y; y++, Voxel_y++ )
					{
						Deep = Voxel_y - height;
						VoxelType = 0;

						if( Deep >= 0 )
						{
							if( Voxel_y > 0 ) VoxelType = 0;
							else VoxelType = 0;
						}
						else VoxelType = 10;

						if( Stencil == 0 )
						{
							if( Voxel_y < -10 && Voxel_y >= -20 ) VoxelType = 86;//86;
							else if( Voxel_y < -20 ) VoxelType = 10;
							else VoxelType = 0;
						}

						VoxelSector.SetCube( x, y, z, VoxelType );
					}
				}
		}
コード例 #12
0
ファイル: genesis.cs プロジェクト: d3x0r/Voxelarium
		void GenerateZone_WaterLands( VoxelSector VoxelSector, int HeightOffset, int Sector_x, int Sector_y, int Sector_z )
		{
			int x, y, z, Voxel_y, Deep, Deep2;
			ushort VoxelType;
			int height;
			float P1, P2, P3, P4;
			// ZGenericByteCanva Canva;
			ZVector3L SectorStart;
			byte Stencil;
			//ZLineCoords LineCoords;

			SectorStart.x = ( VoxelSector.Pos_x << VoxelSector.ZVOXELBLOCSHIFT_X ) & 255;
			SectorStart.z = ( VoxelSector.Pos_z << VoxelSector.ZVOXELBLOCSHIFT_Z ) & 255;
			SectorStart.y = ( VoxelSector.Pos_y << VoxelSector.ZVOXELBLOCSHIFT_Y );

			VoxelSector.Flag_IsActiveVoxels = true;

			RandomGen.Reset();
			random_seed[2] = 0;
			random_seed[3] = 0;
			for( z = 0; z < VoxelSector.ZVOXELBLOCSIZE_Z; z++ )
				for( x = 0; x < VoxelSector.ZVOXELBLOCSIZE_X; x++ )
				{
					int sx = ( Sector_x << VoxelSector.ZVOXELBLOCSHIFT_X ) + x;
					int sz = ( Sector_z << VoxelSector.ZVOXELBLOCSHIFT_Z ) + z;
					int rx = sx >> 4; float Coef1 = ( sx % 16 ) * ( 1.0f / 16.0f );
					int rz = sz >> 4; float Coef2 = ( sz % 16 ) * ( 1.0f / 16.0f );

					random_seed[0] = rx;
					random_seed[1] = rz;
					P1 = ( RandomGen.GetEntropy( 6, true ) ) % 30;
					P2 = ( RandomGen.GetEntropy( 6, true ) ) % 30;
					P3 = ( RandomGen.GetEntropy( 6, true ) ) % 30;
					P4 = ( RandomGen.GetEntropy( 6, true ) ) % 30;

					height = (int)Interpolation_2d( P1, P2, P3, P4, Coef1, Coef2 ) - 15 + HeightOffset;

					// height = (RandomGen.GetNumber(sx) + RandomGen.GetNumber(sz) ) % 15;

					Stencil = Canva_1.GetPoint_Fast( SectorStart.x + x, SectorStart.z + z );

					for( y = 0, Voxel_y = Sector_y << VoxelSector.ZVOXELBLOCSHIFT_Y; y < VoxelSector.ZVOXELBLOCSIZE_Y; y++, Voxel_y++ )
					{
						Deep = Voxel_y - height;
						Deep2 = Voxel_y - HeightOffset;

						VoxelType = 0;

						if( Deep >= 0 )
						{
							if( Deep2 > 0 ) VoxelType = 0;
							else VoxelType = 0;
						}
						else VoxelType = 10;

						if( Stencil == 0 )
						{
							if( Deep2 < -10 && Deep2 >= -20 ) VoxelType = 85;//86;
							else if( Deep2 < -20 ) VoxelType = 10;
							else VoxelType = 0;
						}

						VoxelSector.SetCube( x, y, z, VoxelType );
					}
				}
		}
コード例 #13
0
ファイル: InternalGenesis.cs プロジェクト: d3x0r/Voxelarium
		void GenerateZone_AcidHills( VoxelSector VoxelSector, int HeightOffset, int Sector_x, int Sector_y, int Sector_z )
		{
			int x, y, z, Voxel_y, Deep;
			ushort VoxelType;
			int height;
			float P1, P2, P3, P4;
			//  ZGenericByteCanva Canva;
			ZVector3L SectorStart;
			byte Stencil;
			//  ZLineCoords LineCoords;


			SectorStart.x = ( VoxelSector.Pos_x );
			SectorStart.z = ( VoxelSector.Pos_z );
			SectorStart.y = ( VoxelSector.Pos_y );

			VoxelSector.Flag_IsActiveVoxels = true;

			for( z = 0; z < VoxelSector.ZVOXELBLOCSIZE_Z; z++ )
				for( x = 0; x < VoxelSector.ZVOXELBLOCSIZE_X; x++ )
				{
					int sx = ( Sector_x << VoxelSector.ZVOXELBLOCSHIFT_X ) + x;
					int sz = ( Sector_z << VoxelSector.ZVOXELBLOCSHIFT_Z ) + z;
					uint rx = (uint)sx >> VoxelSector.ZVOXELBLOCSHIFT_X; float Coef1 = ( sx % 16 ) * ( 1.0f / 16.0f );
					uint rz = (uint)sz >> VoxelSector.ZVOXELBLOCSHIFT_Z; float Coef2 = ( sz % 16 ) * ( 1.0f / 16.0f );

					P1 = ( RandomGen.GetNumber( rx ) + RandomGen.GetNumber( rz ) ) % 30;
					P2 = ( RandomGen.GetNumber( rx + 1 ) + RandomGen.GetNumber( rz ) ) % 30;
					P3 = ( RandomGen.GetNumber( rx ) + RandomGen.GetNumber( rz + 1 ) ) % 30;
					P4 = ( RandomGen.GetNumber( rx + 1 ) + RandomGen.GetNumber( rz + 1 ) ) % 30;

					height = (int)Interpolation_2d( P1, P2, P3, P4, Coef1, Coef2 ) - 15;

					// height = (RandomGen.GetNumber(sx) + RandomGen.GetNumber(sz) ) % 15;

					Stencil = Canva_1.GetPoint_Fast( SectorStart.x + x, SectorStart.z + z );

					for( y = 0, Voxel_y = ( Sector_y << VoxelSector.ZVOXELBLOCSHIFT_Y ) - HeightOffset; y < VoxelSector.ZVOXELBLOCSIZE_Y; y++, Voxel_y++ )
					{
						Deep = Voxel_y - height;
						VoxelType = 0;

						if( Deep >= 0 )
						{
							if( Voxel_y > 0 ) VoxelType = 0;
							else VoxelType = 0;
						}
						else VoxelType = 10;

						if( Stencil == 0 )
						{
							if( Voxel_y < -10 && Voxel_y >= -20 ) VoxelType = 86;//86;
							else if( Voxel_y < -20 ) VoxelType = 10;
							else VoxelType = 0;
						}

						VoxelSector.SetCube( x, y, z, VoxelType );
					}
				}
		}
コード例 #14
0
ファイル: genesis.cs プロジェクト: d3x0r/Voxelarium
		void GenerateAddBombs( VoxelSector Sector, double Probability, ushort VoxelType, bool SetActiveSector )
		{
			int x, z, xs, ys, zs, GenerationRadius;
			SaltyRandomGenerator Random = new SaltyRandomGenerator();
			//int Seed;
			ushort ZoneType = 0;
			uint RandNum, Ratio;


			xs = Sector.Pos_x << VoxelSector.ZVOXELBLOCSHIFT_X;
			ys = Sector.Pos_y << VoxelSector.ZVOXELBLOCSHIFT_Y;
			zs = Sector.Pos_z << VoxelSector.ZVOXELBLOCSHIFT_Z;
			//Seed = xs + 3524*ys + 234 * zs;

			Ratio = (uint)( 1024 * Probability );

			GenerationRadius = 0;
			Random.Reset();
			random_seed[0] = xs;
			random_seed[1] = ys;
			random_seed[2] = zs;
			random_seed[3] = 0;

			for( x = xs - GenerationRadius; x < ( xs + 16 + GenerationRadius ); x++ )
				for( z = zs - GenerationRadius; z < ( zs + 16 + GenerationRadius ); z++ )
				{
					if( ( RandNum = (uint)RandomGen.GetEntropy( 10, false ) ) < ( Ratio ) ) // 6
																							// if ( (((x & 31) == 0) && ((z & 31) == 0)) )
																							// if ( Canva_4.GetPoint_Fast( x & 255, z & 255 ) != 0)
					{

						ZVector3L Position;
						ZVector3L Offset;

						Position.x = x - xs;
						Position.z = z - zs;
						Position.y = ( GetZoneHeight( x, z, ZoneType ) - ys );

						if( Position.y < 64 && Position.y > 0 )
						{
							Sector.SetCube( Position.x, Position.y, Position.z, VoxelType );
							if( SetActiveSector ) Sector.Flag_IsActiveVoxels = true;
						}


					}
				}
		}
コード例 #15
0
ファイル: genesis.cs プロジェクト: d3x0r/Voxelarium
		void GenerateZone_PureSinusArea( VoxelSector VoxelSector, int Sector_x, int Sector_y, int Sector_z )
		{
			int x, y, z, Voxel_y, Deep;
			ushort VoxelType;
			int height;

			for( z = 0; z < VoxelSector.ZVOXELBLOCSIZE_Z; z++ )
				for( x = 0; x < VoxelSector.ZVOXELBLOCSIZE_X; x++ )
				{
					//uint sx = (Sector_x << VoxelSector.ZVOXELBLOCSHIFT_X) + x;
					//uint sz = (Sector_z << VoxelSector.ZVOXELBLOCSHIFT_Z) + z;
					double sx = ( ( ( Sector_x & 15 ) << 4 ) + x ); //Sx and Sz range from 0 to 255
					double sz = ( ( ( Sector_z & 15 ) << 4 ) + z );

					height = (int)( Math.Sin( sx * ( 3.141592654 / 32.0 ) ) * Math.Sin( sz * ( 3.14159265 / 32.0 ) ) * 32.0 );

					// height = (RandomGen.GetNumber(sx) + RandomGen.GetNumber(sz) ) % 15;

					for( y = 0, Voxel_y = Sector_y << VoxelSector.ZVOXELBLOCSHIFT_Y; y < VoxelSector.ZVOXELBLOCSIZE_Y; y++, Voxel_y++ )
					{
						Deep = Voxel_y - height;
						VoxelType = 0;

						if( Deep >= 0 ) VoxelType = 0;
						else VoxelType = 48;

						/*
								if      (Deep >=0 )    {VoxelType = 0; }
								else if (Deep < -1536) {VoxelType = 43;}
								else if (Deep < -1280) {VoxelType = 10;}
								else if (Deep < -1024) {VoxelType = 5; }
								else if (Deep < -768)  {VoxelType = 4; }
								else if (Deep < -512)  {VoxelType = 6; }
								else if (Deep < -256)  {VoxelType = 7; }
								else if (Deep < -128)  {VoxelType = 2; }
								else if (Deep < -32)   {VoxelType = 3; }
								else if (Deep < 0)     {VoxelType = 1; }
								else                    VoxelType = 0;
						*/


						VoxelSector.SetCube( x, y, z, VoxelType );
					}
				}
		}
コード例 #16
0
ファイル: genesis.cs プロジェクト: d3x0r/Voxelarium
		/*

		void Generate_Terrain_1536(ZVoxelSector * VoxelSector, int HeightOffset, int Sector_x, int Sector_y, int Sector_z)
		{
		  int x,y,z;
		  ushort VoxelType;
		  double nx,ny,nz, dns,cns, reduce, P[8], C[8], Coef1,Coef2,Coef3;
		  uint Rx,Ry,Rz;
		  VoxelSector.Flag_NeedSortedRendering = true;

		  ushort Textures[16];
		  Textures[0] = 32767 + 3;
		  Textures[1] = 32767 + 2;
		  Textures[2] = 32767 + 1;

		  int sx = ((Sector_x+8192) << VoxelSector.ZVOXELBLOCSHIFT_X);
		  int sy = ((Sector_y+8192) << VoxelSector.ZVOXELBLOCSHIFT_Y);
		  int sz = ((Sector_z+8192) << VoxelSector.ZVOXELBLOCSHIFT_Z);

		  for (z=0 ; z<ZVOXELBLOCSIZE_Z ; z++)
			for (x=0 ; x<ZVOXELBLOCSIZE_X ; x++)
			  for (y=0 ; y<ZVOXELBLOCSIZE_Y ; y++)
			  {
				nx = sx + x;
				ny = sy + y;
				nz = sz + z;

				Rx = (sx + x) >> 4; Ry = (sy + y) >> 4; Rz = (sz + z) >> 4;
				P[0] = ( RandomGen.GetNumber(Rx   ) + RandomGen.GetNumber(Ry)   + RandomGen.GetNumber(Rz  ) ) % 30 ;
				P[1] = ( RandomGen.GetNumber(Rx+1 ) + RandomGen.GetNumber(Ry)   + RandomGen.GetNumber(Rz  ) ) % 30 ;
				P[2] = ( RandomGen.GetNumber(Rx   ) + RandomGen.GetNumber(Ry)   + RandomGen.GetNumber(Rz+1) ) % 30 ;
				P[3] = ( RandomGen.GetNumber(Rx+1 ) + RandomGen.GetNumber(Ry)   + RandomGen.GetNumber(Rz+1) ) % 30 ;
				P[4] = ( RandomGen.GetNumber(Rx   ) + RandomGen.GetNumber(Ry+1) + RandomGen.GetNumber(Rz  ) ) % 30 ;
				P[5] = ( RandomGen.GetNumber(Rx+1 ) + RandomGen.GetNumber(Ry+1) + RandomGen.GetNumber(Rz  ) ) % 30 ;
				P[6] = ( RandomGen.GetNumber(Rx   ) + RandomGen.GetNumber(Ry+1) + RandomGen.GetNumber(Rz+1) ) % 30 ;
				P[7] = ( RandomGen.GetNumber(Rx+1 ) + RandomGen.GetNumber(Ry+1) + RandomGen.GetNumber(Rz+1) ) % 30 ;
				double Coef1 = ((sx + x) % 16) * (1.0 / 16.0);
				// Coef1 = 1.0 - Coef1;
				double Coef3 = ((sy + y) % 16) * (1.0 / 16.0);
				// Coef3 = 1.0 - Coef3;
				double Coef2 = ((sz + z) % 16) * (1.0 / 16.0);
				dns = Interpolation_3d(P,Coef1,Coef2,Coef3);

				C[0] = ( RandomGen.GetNumber(Rx+200   ) + RandomGen.GetNumber(Ry + 200) + RandomGen.GetNumber(Rz+200  ) ) % 30 ;
				C[1] = ( RandomGen.GetNumber(Rx+201 )   + RandomGen.GetNumber(Ry + 200) + RandomGen.GetNumber(Rz+200  ) ) % 30 ;
				C[2] = ( RandomGen.GetNumber(Rx+200   ) + RandomGen.GetNumber(Ry + 200) + RandomGen.GetNumber(Rz+201) ) % 30 ;
				C[3] = ( RandomGen.GetNumber(Rx+201 )   + RandomGen.GetNumber(Ry + 200) + RandomGen.GetNumber(Rz+201) ) % 30 ;
				C[4] = ( RandomGen.GetNumber(Rx+200   ) + RandomGen.GetNumber(Ry + 201) + RandomGen.GetNumber(Rz+200  ) ) % 30 ;
				C[5] = ( RandomGen.GetNumber(Rx+201 )   + RandomGen.GetNumber(Ry + 201) + RandomGen.GetNumber(Rz+200  ) ) % 30 ;
				C[6] = ( RandomGen.GetNumber(Rx+200   ) + RandomGen.GetNumber(Ry + 201) + RandomGen.GetNumber(Rz+201) ) % 30 ;
				C[7] = ( RandomGen.GetNumber(Rx+201 )   + RandomGen.GetNumber(Ry + 201) + RandomGen.GetNumber(Rz+201) ) % 30 ;

				cns = Interpolation_3d(C,Coef1,Coef2,Coef3);


				VoxelType = Textures[(uint)floor((cns/20.0))];

				// VoxelType = 32768;
				reduce = ( ((double)(sy + y -524288.0)) / 10.0);
				if (reduce < 0.0) reduce = 0.0;
				dns -= reduce;
				if   (dns< 15.0) {dns = 0.0;VoxelType=0;} //15.0

				// if (Sector_y > 1) VoxelType = 0;
				VoxelSector.SetCube(x,y,z, VoxelType);

			  }
		}

		*/

		void Generate_Terrain_1537( VoxelSector VoxelSector, int HeightOffset, int Sector_x, int Sector_y, int Sector_z )
		{
			int x, y, z, nx, ny, nz;
			ushort VoxelType;
			VoxelSector.Flag_NeedSortedRendering = true;

			/*
			  Textures[0] = 1; // 1
			  Textures[1] = 2; // 12
			  Textures[2] = 3; // 14
			*/
			int sx = ( ( Sector_x + 8192 ) << VoxelSector.ZVOXELBLOCSHIFT_X );
			int sy = ( ( Sector_y + 8192 ) << VoxelSector.ZVOXELBLOCSHIFT_Y );
			int sz = ( ( Sector_z + 8192 ) << VoxelSector.ZVOXELBLOCSHIFT_Z );

			RandomGen.Reset();
			random_seed[0] = Sector_x;
			random_seed[1] = Sector_z;
			random_seed[2] = 0;
			random_seed[3] = 0;
			for( z = 0; z < VoxelSector.ZVOXELBLOCSIZE_Z; z++ )
				for( x = 0; x < VoxelSector.ZVOXELBLOCSIZE_X; x++ )
					for( y = 0; y < VoxelSector.ZVOXELBLOCSIZE_Y; y++ )
					{
						nx = sx + x;
						ny = sy + y;
						nz = sz + z;

						double Den = //sin(nx/(50.0+nx/10000.0)) * sin(ny/(50.0+ny/10000.0)) * sin(nz/(50.0+nz/10000.0)) *
									 Math.Sin( nx / ( 30.0 ) ) * Math.Sin( ny / ( 30.0 ) ) * Math.Sin( nz / ( 30.0 ) )
									 /*(1.0 + 0.6 * (sin(nx/(1.3)) * sin(ny/(2.8)) * sin(nz/(1.63)))) */
									 * ( 1.0 + 0.4 * ( (double)RandomGen.GetEntropy( 10, false ) / 1024.0 ) );
						if( Den > 0.3 ) { VoxelType = 233; if( Den > 0.35 ) VoxelType = 232; }
						else VoxelType = 0;
						VoxelSector.SetCube( x, y, z, VoxelType );
					}
		}
コード例 #17
0
ファイル: genesis.cs プロジェクト: d3x0r/Voxelarium
		void GenerateZone_NaturalMountains( VoxelSector VoxelSector, int Sector_x, int Sector_y, int Sector_z )
		{
			int x, y, z, Voxel_y, Deep;
			ushort VoxelType;
			int height;
			float P1, P2, P3, P4;

			RandomGen.Reset();
			random_seed[0] = Sector_x;
			random_seed[1] = Sector_y;
			random_seed[2] = 0;
			random_seed[3] = 0;
			for( z = 0; z < VoxelSector.ZVOXELBLOCSIZE_Z; z++ )
				for( x = 0; x < VoxelSector.ZVOXELBLOCSIZE_X; x++ )
				{
					int sx = ( Sector_x << VoxelSector.ZVOXELBLOCSHIFT_X ) + x;
					int sz = ( Sector_z << VoxelSector.ZVOXELBLOCSHIFT_Z ) + z;
					float Coef1 = ( sx % 16 ) * ( 1.0f / 16.0f );
					float Coef2 = ( sz % 16 ) * ( 1.0f / 16.0f );

					P1 = ( RandomGen.GetEntropy( 5, true ) ) % 30;
					P2 = ( RandomGen.GetEntropy( 5, true ) ) % 30;
					P3 = ( RandomGen.GetEntropy( 5, true ) ) % 30;
					P4 = ( RandomGen.GetEntropy( 5, true ) ) % 30;

					height = (int)Interpolation_2d( P1, P2, P3, P4, Coef1, Coef2 ) - 15;

					// height = (RandomGen.GetNumber(sx) + RandomGen.GetNumber(sz) ) % 15;

					for( y = 0, Voxel_y = Sector_y << VoxelSector.ZVOXELBLOCSHIFT_Y; y < VoxelSector.ZVOXELBLOCSIZE_Y; y++, Voxel_y++ )
					{
						Deep = Voxel_y - height;
						VoxelType = 0;

						if( Deep >= 0 ) VoxelType = 0;
						else VoxelType = 48;

						/*
								if      (Deep >=0 )    {VoxelType = 0; }
								else if (Deep < -1536) {VoxelType = 43;}
								else if (Deep < -1280) {VoxelType = 10;}
								else if (Deep < -1024) {VoxelType = 5; }
								else if (Deep < -768)  {VoxelType = 4; }
								else if (Deep < -512)  {VoxelType = 6; }
								else if (Deep < -256)  {VoxelType = 7; }
								else if (Deep < -128)  {VoxelType = 2; }
								else if (Deep < -32)   {VoxelType = 3; }
								else if (Deep < 0)     {VoxelType = 1; }
								else                    VoxelType = 0;
						*/


						VoxelSector.SetCube( x, y, z, VoxelType );
					}
				}
		}
コード例 #18
0
ファイル: genesis.cs プロジェクト: d3x0r/Voxelarium
		void GenerateZone_WaterMountain( VoxelSector VoxelSector, int HeightOffset, int Sector_x, int Sector_y, int Sector_z )
		{
			int x, y, z, Voxel_y, Deep;
			ushort VoxelType;
			int height;
			float P1, P2, P3, P4;
			ZVector3L SectorStart;
			byte Stencil, Stencil2;
			bool CStencil;

			SectorStart.x = ( VoxelSector.Pos_x << VoxelSector.ZVOXELBLOCSHIFT_X ) & 255;
			SectorStart.z = ( VoxelSector.Pos_z << VoxelSector.ZVOXELBLOCSHIFT_Z ) & 255;
			SectorStart.y = ( VoxelSector.Pos_y << VoxelSector.ZVOXELBLOCSHIFT_Y );

			VoxelSector.Flag_IsActiveVoxels = true;

			RandomGen.Reset();
			random_seed[2] = 0;
			random_seed[3] = 0;
			for( z = 0; z < VoxelSector.ZVOXELBLOCSIZE_Z; z++ )
				for( x = 0; x < VoxelSector.ZVOXELBLOCSIZE_X; x++ )
				{
					int sx = ( Sector_x << VoxelSector.ZVOXELBLOCSHIFT_X ) + x;
					int sz = ( Sector_z << VoxelSector.ZVOXELBLOCSHIFT_Z ) + z;
					int rx = sx >> 4; float Coef1 = ( sx % 16 ) * ( 1.0f / 16.0f );
					int rz = sz >> 4; float Coef2 = ( sz % 16 ) * ( 1.0f / 16.0f );
					random_seed[0] = rx;
					random_seed[1] = rz;
					P1 = ( RandomGen.GetEntropy( 6, true ) ) % 60;
					P2 = ( RandomGen.GetEntropy( 6, true ) ) % 60;
					P3 = ( RandomGen.GetEntropy( 6, true ) ) % 60;
					P4 = ( RandomGen.GetEntropy( 6, true ) ) % 60;

					height = (int)Interpolation_2d( P1, P2, P3, P4, Coef1, Coef2 ) - 15;

					// height = (RandomGen.GetNumber(sx) + RandomGen.GetNumber(sz) ) % 15;

					Stencil = Canva_1.GetPoint_Fast( SectorStart.x + x, SectorStart.z + z );
					Stencil2 = Canva_2.GetPoint_Fast( SectorStart.x + x, SectorStart.z + z );
					CStencil = ( Stencil > 0 ) || ( Stencil2 < 1 );

					for( y = 0, Voxel_y = ( Sector_y << VoxelSector.ZVOXELBLOCSHIFT_Y ) - HeightOffset; y < VoxelSector.ZVOXELBLOCSIZE_Y; y++, Voxel_y++ )
					{

						Deep = Voxel_y - height + ( ( CStencil ) ? 15 : 0 );
						VoxelType = 0;

						if( Deep >= 0 )
						{
							VoxelType = 0;
						}
						else
						{
							if( CStencil ) VoxelType = 10;
							else VoxelType = 3;
						}

						VoxelSector.SetCube( x, y, z, VoxelType );
					}
				}
		}
コード例 #19
0
ファイル: InternalGenesis.cs プロジェクト: d3x0r/Voxelarium
		void Generate_Terrain_1536( VoxelSector VoxelSector, int HeightOffset, int Sector_x, int Sector_y, int Sector_z )
		{
			int x, y, z, nx, ny, nz;
			ushort VoxelType;
			float dns, cns, reduce, Coef1, Coef2, Coef3;
			float[] P = new float[8], C = new float[8];
			uint Rx, Ry, Rz;
			VoxelSector.Flag_NeedSortedRendering = true;

			ushort[] Textures = new ushort[16];
			Textures[0] = 232; // 1
			Textures[1] = 233; // 12
			Textures[2] = 233; // 14
							   /*
								 Textures[0] = 1; // 1
								 Textures[1] = 2; // 12
								 Textures[2] = 3; // 14
							   */
			int sx = ( ( Sector_x + 8192 ) << VoxelSector.ZVOXELBLOCSHIFT_X );
			int sy = ( ( Sector_y + 8192 ) << VoxelSector.ZVOXELBLOCSHIFT_Y );
			int sz = ( ( Sector_z + 8192 ) << VoxelSector.ZVOXELBLOCSHIFT_Z );

			for( z = 0; z < VoxelSector.ZVOXELBLOCSIZE_Z; z++ )
				for( x = 0; x < VoxelSector.ZVOXELBLOCSIZE_X; x++ )
					for( y = 0; y < VoxelSector.ZVOXELBLOCSIZE_Y; y++ )
					{
						nx = sx + x;
						ny = sy + y;
						nz = sz + z;

						Rx = (uint)( sx + x ) >> VoxelSector.ZVOXELBLOCSHIFT_X;
						Ry = (uint)( sy + y ) >> VoxelSector.ZVOXELBLOCSHIFT_Y;
						Rz = (uint)( sz + z ) >> VoxelSector.ZVOXELBLOCSHIFT_Z;

						P[0] = ( RandomGen.GetNumber( Rx ) + RandomGen.GetNumber( Ry ) + RandomGen.GetNumber( Rz ) ) % 30;
						P[1] = ( RandomGen.GetNumber( Rx + 1 ) + RandomGen.GetNumber( Ry ) + RandomGen.GetNumber( Rz ) ) % 30;
						P[2] = ( RandomGen.GetNumber( Rx ) + RandomGen.GetNumber( Ry ) + RandomGen.GetNumber( Rz + 1 ) ) % 30;
						P[3] = ( RandomGen.GetNumber( Rx + 1 ) + RandomGen.GetNumber( Ry ) + RandomGen.GetNumber( Rz + 1 ) ) % 30;
						P[4] = ( RandomGen.GetNumber( Rx ) + RandomGen.GetNumber( Ry + 1 ) + RandomGen.GetNumber( Rz ) ) % 30;
						P[5] = ( RandomGen.GetNumber( Rx + 1 ) + RandomGen.GetNumber( Ry + 1 ) + RandomGen.GetNumber( Rz ) ) % 30;
						P[6] = ( RandomGen.GetNumber( Rx ) + RandomGen.GetNumber( Ry + 1 ) + RandomGen.GetNumber( Rz + 1 ) ) % 30;
						P[7] = ( RandomGen.GetNumber( Rx + 1 ) + RandomGen.GetNumber( Ry + 1 ) + RandomGen.GetNumber( Rz + 1 ) ) % 30;
						Coef1 = ( ( sx + x ) % 16 ) * ( 1.0f / 16.0f );
						Coef3 = ( ( sy + y ) % 16 ) * ( 1.0f / 16.0f );
						Coef2 = ( ( sz + z ) % 16 ) * ( 1.0f / 16.0f );
						dns = Interpolation_3d( P, Coef1, Coef2, Coef3 );

						Ry = (uint)( sy + y + 1 ) >> VoxelSector.ZVOXELBLOCSHIFT_Y;
						C[0] = ( RandomGen.GetNumber( Rx ) + RandomGen.GetNumber( Ry ) + RandomGen.GetNumber( Rz ) ) % 30;
						C[1] = ( RandomGen.GetNumber( Rx + 1 ) + RandomGen.GetNumber( Ry ) + RandomGen.GetNumber( Rz ) ) % 30;
						C[2] = ( RandomGen.GetNumber( Rx ) + RandomGen.GetNumber( Ry ) + RandomGen.GetNumber( Rz + 1 ) ) % 30;
						C[3] = ( RandomGen.GetNumber( Rx + 1 ) + RandomGen.GetNumber( Ry ) + RandomGen.GetNumber( Rz + 1 ) ) % 30;
						C[4] = ( RandomGen.GetNumber( Rx ) + RandomGen.GetNumber( Ry + 1 ) + RandomGen.GetNumber( Rz ) ) % 30;
						C[5] = ( RandomGen.GetNumber( Rx + 1 ) + RandomGen.GetNumber( Ry + 1 ) + RandomGen.GetNumber( Rz ) ) % 30;
						C[6] = ( RandomGen.GetNumber( Rx ) + RandomGen.GetNumber( Ry + 1 ) + RandomGen.GetNumber( Rz + 1 ) ) % 30;
						C[7] = ( RandomGen.GetNumber( Rx + 1 ) + RandomGen.GetNumber( Ry + 1 ) + RandomGen.GetNumber( Rz + 1 ) ) % 30;

						Coef3 = ( ( sy + y + 1 ) % 16 ) * ( 1.0f / 16.0f );
						cns = Interpolation_3d( C, Coef1, Coef2, Coef3 );

						VoxelType = Textures[(uint)( ( cns / 20.0 ) )];

						// VoxelType = 32768;
						reduce = ( ( (float)( sy + y + ( -524288 + 20 ) - HeightOffset ) ) / 10.0f ); // 5.0
						if( reduce < 0.0 ) reduce = 0;
						dns -= reduce;
						cns -= reduce;
						if( dns < 15.0 ) { dns = 0; VoxelType = 0; } //15.0
						else
						{
							if( ( dns - cns ) > 0.3 ) VoxelType = Textures[0];
							else if( dns - cns < -0.2 ) VoxelType = Textures[2];
							else { VoxelType = Textures[1]; if( ( RandomGen.GetNumber( (uint)nx ) + RandomGen.GetNumber( (uint)ny ) + RandomGen.GetNumber( (uint)nz ) ) < 10000000 ) VoxelType = 46; }
						}

						// if (Sector_y > 1) VoxelType = 0;
						VoxelSector.SetCube( x, y, z, VoxelType );
					}
		}