Ejemplo n.º 1
0
		void GenerateBigTrees( VoxelSector Sector )
		{
			int x, z, xs, ys, zs, GenerationRadius;
			VoxelGfx_Tree TreeMaker = new VoxelGfx_Tree();
			VoxelGfx_Tree_Straight TreeMaker_2 = new VoxelGfx_Tree_Straight();
			VoxelGfx_Tree_Giant TreeMaker_3 = new VoxelGfx_Tree_Giant();
			//int Seed;
			ushort ZoneType = 0;
			uint RandNum, TreeType;
			bool ZoneOk;

			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;

			/*
			  Sector.SetCube(0,20,0, 2);
			  Sector.SetCube(15,20,15, 2);
			  return;
			*/
			GenerationRadius = 150;
			RandomGen.Reset();
			random_seed[2] = 0;
			random_seed[3] = 0;
			for( x = xs - GenerationRadius; x < xs + GenerationRadius; x++ )
				for( z = zs - GenerationRadius; z < zs + GenerationRadius; z++ )
				{
					random_seed[0] = x;
					random_seed[1] = z;
					RandNum = (uint)RandomGen.GetEntropy( 10, false );
					if( RandNum < 10 )
					{
						ZVector3f Position;
						Position.x = x - xs;
						Position.z = z - zs;
						Position.y = GetZoneHeight( x, z, ZoneType ) - ys;
						TreeMaker.Seed = (uint)( Math.Abs( x ) * 3 + ( ( Math.Abs( z ) << 9 ) * 5 ) );
						TreeMaker_2.Seed = TreeMaker.Seed;
						TreeType = RandNum & 7;

						ZoneOk = ( ZoneType == 5 );
						switch( TreeType )
						{
							case 0:
							case 1:
							case 2:
								if( Position.y > -128 && Position.y < 64 && ZoneOk ) TreeMaker.DrawTree( Sector, ref Position );
								break;

							case 3:
							case 4:
							case 5:
							case 6:
								if( Position.y > -192 && Position.y < 64 && ZoneOk ) TreeMaker_2.DrawTree( Sector, ref Position );
								break;
							case 7:
								if( Position.y > -1024 && Position.y < 64 && ZoneOk ) TreeMaker_3.DrawTree( Sector, ref Position );
								break;
						}
					}
				}
		}
Ejemplo n.º 2
0
		void GenerateBigTrees( VoxelSector Sector )
		{
			int x, z, xs, ys, zs, GenerationRadius;
			VoxelGfx_Tree TreeMaker = new VoxelGfx_Tree();
			VoxelGfx_Tree_Straight TreeMaker_2 = new VoxelGfx_Tree_Straight();
			VoxelGfx_Tree_Giant TreeMaker_3 = new VoxelGfx_Tree_Giant();
			LightSpeedRandom Random = new LightSpeedRandom();
			//int Seed;
			ushort ZoneType = 0;
			uint RandNum, TreeType;
			bool ZoneOk;

			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;

			/*
			  Sector.SetCube(0,20,0, 2);
			  Sector.SetCube(15,20,15, 2);
			  return;
			*/

			GenerationRadius = 150;
			for( x = xs - GenerationRadius; x < xs + GenerationRadius; x++ )
				for( z = zs - GenerationRadius; z < zs + GenerationRadius; z++ )
				{
					if( ( RandNum = Random.GetNumber( (uint)(Math.Abs( x ) + ( Math.Abs( z ) << 8 ) )) ) < ( 4194304 / 3 ) ) // 6
					{
						ZVector3f Position;
						Position.x = x - xs;
						Position.z = z - zs;
						Position.y = GetZoneHeight( x, z, out ZoneType ) - ys;
						TreeMaker.Seed = (uint)( Math.Abs( x ) * 3 + ( ( Math.Abs( z ) << 9 ) * 5 ) );
						TreeMaker_2.Seed = TreeMaker.Seed;
						TreeType = RandNum & 7;

						ZoneOk = ( ZoneType == 5 );
						switch( TreeType )
						{
							case 0:
							case 1:
							case 2:
								if( Position.y > -128 && Position.y < 64 && ZoneOk ) TreeMaker.DrawTree( Sector, ref Position );
								break;

							case 3:
							case 4:
							case 5:
							case 6:
								if( Position.y > -192 && Position.y < 64 && ZoneOk ) TreeMaker_2.DrawTree( Sector, ref Position );
								break;
							case 7:
								if( Position.y > -1024 && Position.y < 64 && ZoneOk ) TreeMaker_3.DrawTree( Sector, ref Position );
								break;
						}
					}
				}
		}