예제 #1
0
		// To optimize

		public void Blit( GenericCharCanvas Source, int xs, int ys, int xSize, int ySize, int xd, int yd )
		{
			int x, y;
			bool Reloop;


			do
			{
				Reloop = false;
				if( xSize > ( Source.Width - xs ) ) xSize = Source.Width - xs;
				if( ySize > ( Source.Height - ys ) ) ySize = Source.Height - ys;
				if( Width < ( xd + xSize ) ) xSize += Width - ( xd + xSize );
				if( Height < ( yd + ySize ) ) ySize += Height - ( yd + ySize );
				if( xd < 0 ) { xSize += xd; xs -= xd; xd = 0; Reloop = true; }
				if( yd < 0 ) { ySize += yd; ys -= yd; yd = 0; Reloop = true; }
			} while( Reloop );

			if( xSize <= 0 || ySize <= 0 ) return;

			for( y = 0; y < ySize; y++ )
				for( x = 0; x < xSize; x++ )
				{
					SetPoint_Secure( x + xd, y + yd, Source.GetPoint_Secure( x + xs, y + ys ) );
				}
		}
예제 #2
0
		// To optimize

		GenericCharCanvas GetRectCopy( int xStart, int yStart, int xSize, int ySize )
		{
			GenericCharCanvas NewCanva;
			int x, y;

			// Bound Checking

			if( xStart < 0 ) { xSize += xStart; xStart = 0; }
			if( yStart < 0 ) { ySize += yStart; yStart = 0; }
			if( xSize > ( Width - xStart ) ) xSize = Width - xStart;
			if( ySize > ( Height - yStart ) ) ySize = Height - yStart;
			if( xSize <= 0 || ySize <= 0 ) return ( null );

			NewCanva = new GenericCharCanvas( xSize, ySize );

			for( y = 0; y < ySize; y++ )
				for( x = 0; x < xSize; x++ )
				{
					NewCanva.SetPoint_Secure( x, y, GetPoint_Secure( x + xStart, y + yStart ) );
				}

			return ( NewCanva );
		}
예제 #3
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;
						}

					}
				}
		}
예제 #4
0
파일: genesis.cs 프로젝트: d3x0r/Voxelarium
		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 );
						}
					}
				}
		}
예제 #5
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 );
					}
				}
		}
예제 #6
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 );
					}
				}

			}

		}