Exemple #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;
						}
					}
				}
		}
Exemple #2
0
		void Generate_Generic_LittleStructs( VoxelSector Sector, VoxelSector ObjectToPlace, GenericCharCanvas LocationMap, int Offset )
		{
			int x, z, xs, ys, zs, GenerationRadius;
			//ZLightSpeedRandom Random;
			VoxelGfx_Tree TreeMaker = new VoxelGfx_Tree();
			//int Seed;
			ushort ZoneType= 0 ;
			// uint RandNum;


			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;
			*/

			uint SizeMask;

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

			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 ) )) < (4194304 * 50)) // 6
					// if ( (((x & 7) == 0) && ((z & 7) == 0)) )

					if( LocationMap.GetPoint_Fast( (int)(SizeMask - ( ( x + Offset ) & SizeMask )), (int)(( z + Offset ) & SizeMask) ) > 128 )
					{

						ZVector3L Position;
						ZVector3L OffsetRec;

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

						OffsetRec.x = Position.x;
						OffsetRec.y = Position.y;
						OffsetRec.z = Position.z;

						OffsetRec.x -= T3dTemplate_1.Handle_x;
						OffsetRec.y -= T3dTemplate_1.Handle_y;
						OffsetRec.z -= T3dTemplate_1.Handle_z;

						if( OffsetRec.y < 74 && OffsetRec.y > -10 )
						{
							// if ( (x== (75-512)) && (z==(103-512)) ) MANUAL_BREAKPOINT;
							// if (this.Canva_4.GetPoint_Secure(xs & 0xFF,zs & 0xFF))
							Sector.BlitSector( ObjectToPlace, ref OffsetRec );
						}
					}
				}
		}
Exemple #3
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;
						}
					}
				}
		}