internal bool PushToList( VoxelSector Sector ) { if( nEntries > ( ListSize - 4 ) ) return ( false ); SectorList[End] = Sector; End = ( End + 1 ) & WrapMask; nEntries++; // printf("Push"); return ( true ); }
internal VoxelRef( VoxelWorld world, VoxelTypeManager vtm, byte x = 0, byte y = 0, byte z = 0, VoxelSector Sector = null, ushort VoxelType = 0 ) { this.x = x; this.y = y; this.z = z; this.wx = ( Sector.Pos_x << VoxelSector.ZVOXELBLOCSHIFT_X )+ x; this.wy = ( Sector.Pos_y << VoxelSector.ZVOXELBLOCSHIFT_Y )+y; this.wz = ( Sector.Pos_z << VoxelSector.ZVOXELBLOCSHIFT_Z )+z; this.Sector = Sector; this.Offset = ( (uint)x << VoxelSector.ZVOXELBLOCSHIFT_Y ) + y + ((uint)z << ( VoxelSector.ZVOXELBLOCSHIFT_X+VoxelSector.ZVOXELBLOCSHIFT_Y)); this.World = world; this.Type = vtm[VoxelType]; VoxelTypeManager = vtm; VoxelExtension = null; }
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 ); } } }
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 ); } }
void GenerateRTFM( VoxelSector Sector ) { if( Sector.Pos_x == 0 && Sector.Pos_y == 0 && Sector.Pos_z == 2 ) { Sector.SetCube_WithExtension( 1, 0, 8, 212, null ); } }
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; } } } }
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 ); } } }
void GenerateZone_FlatAcidResistant( VoxelSector VoxelSector, int HeightOffset, int Sector_x, int Sector_y, int Sector_z ) { int y, Voxel_y; uint i; ushort[] TypeTable = new ushort[VoxelSector.ZVOXELBLOCSIZE_Y]; bool[] MineralInclude = new bool[VoxelSector.ZVOXELBLOCSIZE_Y]; ushort Type; ushort[] Data = VoxelSector.Data.Data; VoxelSector.Flag_Void_Transparent = true; VoxelSector.Flag_Void_Regular = true; // Probabilizer InclusionProbabilizer Probabilizer = new InclusionProbabilizer(); RandomGen.Reset(); random_seed[0] = Sector_x; random_seed[1] = Sector_y; random_seed[2] = Sector_z; random_seed[3] = 0; int Deepness = Sector_y; // Deepness = -2; switch( Deepness ) { case -1: default: Probabilizer.AddEntry( 60, 50.0f, 1.0f ); // Charbon Probabilizer.AddEntry( 112, 50.0f, 1.0f ); // Cuivre Probabilizer.AddEntry( 127, 50.0f, 0.4f ); // Etain Probabilizer.AddEntry( 44, 0, 0.10f ); // Vitrail // Rare ores Probabilizer.AddEntry( 74, 0, 0.05f ); // Fer Probabilizer.AddEntry( 26, 0, 0.1f ); // Or break; case -2: Probabilizer.AddEntry( 74, 50.0f, 1.0f ); // Fer Probabilizer.AddEntry( 60, 50.0f, 1.0f ); // Charbon Probabilizer.AddEntry( 26, 0, 0.1f ); // Or Probabilizer.AddEntry( 110, 50.0f, 0.2f ); // Nickel Probabilizer.AddEntry( 121, 50.0f, 0.2f ); // Chrome break; } uint FenceBound = Probabilizer.ComputeProbabilities( 1.0f ); // Random Seed for that particular sector. RandomGen.Reset(); random_seed[0] = Sector_x; random_seed[1] = Sector_z; random_seed[2] = 0; random_seed[3] = 0; // Layers of ground. for( y = 0, Voxel_y = ( Sector_y << VoxelSector.ZVOXELBLOCSHIFT_Y ) - HeightOffset; y < VoxelSector.ZVOXELBLOCSIZE_Y; y++, Voxel_y++ ) { Type = 0; if( Voxel_y >= 0 ) Type = 0; else { Type = 10; VoxelSector.Flag_Void_Regular = false; } TypeTable[y] = Type; //TypeTable[y]= 0; // debug MineralInclude[y] = ( ( Voxel_y < -5L ) && ( Type != 0 ) ); } // If sector is void, fill it more quickly if( VoxelSector.Flag_Void_Regular ) { for( i = 0; i < ( VoxelSector.ZVOXELBLOCSIZE_X * VoxelSector.ZVOXELBLOCSIZE_Y * VoxelSector.ZVOXELBLOCSIZE_Z ); i++ ) Data[i] = 0; return; } // Fill zone with inclusions ushort LastMineral = 0; uint Num = 0; for( i = 0; i < ( VoxelSector.ZVOXELBLOCSIZE_X * VoxelSector.ZVOXELBLOCSIZE_Y * VoxelSector.ZVOXELBLOCSIZE_Z ); i++ ) { Data[i] = TypeTable[i & VoxelSector.ZVOXELBLOCMASK_Y]; if( MineralInclude[i & VoxelSector.ZVOXELBLOCMASK_Y] ) { if( Probabilizer.IsBelowFence( RandomGen ) ) { Num = Probabilizer.GetTypeNum( RandomGen ); Data[i] = LastMineral = Probabilizer.GetVoxelType( Num ); } else if( LastMineral != 0 ) { if( Probabilizer.AllowRepeat( Num, RandomGen ) ) Data[i] = LastMineral; else LastMineral = 0; } // LastMineral = 0; } } }
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 ); } } }
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 ); } } }
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 ); } } } }
/* 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 ); } } }
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 ); } } }
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 ); } } }
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; } } } }
void GenerateZone_Flat( VoxelSector VoxelSector, int Sector_x, int Sector_y, int Sector_z ) { int y, Voxel_y; uint i, RandomNumber; ushort[] TypeTable = new ushort[VoxelSector.ZVOXELBLOCSIZE_Y]; bool[] MineralInclude = new bool[VoxelSector.ZVOXELBLOCSIZE_Y]; ushort Type; ushort[] Data = VoxelSector.Data.Data; VoxelSector.Flag_Void_Transparent = true; VoxelSector.Flag_Void_Regular = true; RandomGen.Reset(); random_seed[0] = Sector_x; random_seed[1] = Sector_y; random_seed[2] = Sector_z; random_seed[3] = 0; //RandomSeed = ( RandomGen.GetNumber( Sector_x & ZLIGHTSPEEDRANDOM_LENMASK ) ^ RandomGen.GetNumber( Sector_y & ZLIGHTSPEEDRANDOM_LENMASK ) ^ RandomGen.GetNumber( Sector_z & ZLIGHTSPEEDRANDOM_LENMASK ) ) & ZLIGHTSPEEDRANDOM_LENMASK; for( y = 0, Voxel_y = ( Sector_y << VoxelSector.ZVOXELBLOCSHIFT_Y ); y < VoxelSector.ZVOXELBLOCSIZE_Y; y++, Voxel_y++ ) { Type = 0; if( Voxel_y >= 0 ) Type = 0; else if( Voxel_y < -1536 ) { Type = 43; VoxelSector.Flag_Void_Regular = false; } else if( Voxel_y < -1280 ) { Type = 10; VoxelSector.Flag_Void_Regular = false; } else if( Voxel_y < -1024 ) { Type = 5; VoxelSector.Flag_Void_Regular = false; } else if( Voxel_y < -768 ) { Type = 4; VoxelSector.Flag_Void_Regular = false; } else if( Voxel_y < -512 ) { Type = 6; VoxelSector.Flag_Void_Regular = false; } else if( Voxel_y < -256 ) { Type = 7; VoxelSector.Flag_Void_Regular = false; } else if( Voxel_y < -128 ) { Type = 2; VoxelSector.Flag_Void_Regular = false; } else if( Voxel_y < -32 ) { Type = 3; VoxelSector.Flag_Void_Regular = false; } else if( Voxel_y < 0 ) { Type = 1; VoxelSector.Flag_Void_Regular = false; } else Type = 0; TypeTable[y] = Type; MineralInclude[y] = ( ( Voxel_y < -1L ) && ( Type != 0 ) ); } ushort LastMineral = 0; for( i = 0; i < ( VoxelSector.ZVOXELBLOCSIZE_X * VoxelSector.ZVOXELBLOCSIZE_Y * VoxelSector.ZVOXELBLOCSIZE_Z ); i++ ) { Data[i] = TypeTable[i & VoxelSector.ZVOXELBLOCMASK_Y]; if( MineralInclude[i & VoxelSector.ZVOXELBLOCMASK_Y] ) { RandomNumber = (uint)RandomGen.GetEntropy( 10, false ); //if (RandomNumber < 42949672UL) Data[i]=26; //if (RandomNumber < 4294967UL) Data[i]=27; if( RandomNumber < InclusionQuantity ) { switch( RandomNumber & 0xf ) { case 0: case 1: case 2: case 3: case 4: case 5: LastMineral = 74; break; // Fer case 6: LastMineral = 112; break; // Cuivre case 7: LastMineral = 26; break; // Or case 8: LastMineral = 28; break; // Amethiste case 9: LastMineral = 109; break; // Diamond. case 10: LastMineral = 110; break; // Nickel case 11: LastMineral = 44; break; // Vitrail bleu/blanc case 12: LastMineral = 46; break; // Pierre vitrifiée case 13: LastMineral = 47; break; // Emeraude ? case 14: LastMineral = 60; break; // Charbon case 15: LastMineral = 111; break; // Uranium } } if( LastMineral != 0 ) { switch( LastMineral ) { default: if( ( RandomNumber & 3 ) != 0 ) Data[i] = LastMineral; else LastMineral = 0; break; } } } } // if (Pos_y<0) {Cnt=1;Flag_Void_Regular=false;Flag_Void_Transparent=true;} // if (Pos_y>=0){Cnt=0;Flag_Void_Regular=true;Flag_Void_Transparent=true;} /* if( VoxelSector.Pos_x == 0 && VoxelSector.Pos_y == 0 && VoxelSector.Pos_z == -2 && VoxelGlobalSettings.COMPILEOPTION_ALLOWSTARTINGSTORAGE ) { VoxelExtension_Storage StorageExtension; StorageExtension = new ZVoxelExtension_Storage(); StorageExtension.VoxelType[0] = 42; StorageExtension.VoxelQuantity[0] = 1; StorageExtension.VoxelType[1] = 75; StorageExtension.VoxelQuantity[1] = 1; VoxelSector.SetCube_WithExtension( 8, 0, 8, 49, StorageExtension ); } */ }
void GenerateZone_Flat2( VoxelSector VoxelSector, int HeightOffset, int Sector_x, int Sector_y, int Sector_z ) { int y, Voxel_y; uint i; ushort[] TypeTable = new ushort[VoxelSector.ZVOXELBLOCSIZE_Y]; bool[] MineralInclude = new bool[VoxelSector.ZVOXELBLOCSIZE_Y]; ushort Type; ushort[] Data = VoxelSector.Data.Data; VoxelSector.Flag_Void_Transparent = true; VoxelSector.Flag_Void_Regular = true; // Probabilizer InclusionProbabilizer Probabilizer = new InclusionProbabilizer(); int Deepness = Sector_y; RandomGen.Reset(); random_seed[0] = Sector_x; random_seed[1] = Sector_y; random_seed[2] = Sector_z; random_seed[3] = 0; switch( Deepness ) { case -1: default: Probabilizer.AddEntry( 44, 0, 0.1f ); // Matériau X Probabilizer.AddEntry( 60, 50, 1.0f ); // Charbon Probabilizer.AddEntry( 112, 50, 1.0f ); // Cuivre Probabilizer.AddEntry( 127, 50, 0.4f ); // Etain // Rare ores Probabilizer.AddEntry( 26, 0, 0.1f ); // Or Probabilizer.AddEntry( 74, 0, 0.05f ); // Fer break; case -2: Probabilizer.AddEntry( 26, 0, 0.1f ); // Or Probabilizer.AddEntry( 60, 50, 1.0f ); // Charbon Probabilizer.AddEntry( 74, 50, 0.1f ); // Fer Probabilizer.AddEntry( 110, 50, 0.2f ); // Nickel Probabilizer.AddEntry( 121, 50, 0.2f ); // Chrome break; case -3: Probabilizer.AddEntry( 26, 0, 0.1f ); // Or Probabilizer.AddEntry( 60, 50, 1.0f ); // Charbon Probabilizer.AddEntry( 74, 50, 1.0f ); // Fer Probabilizer.AddEntry( 110, 50, 0.5f ); // Nickel Probabilizer.AddEntry( 121, 50, 0.5f ); // Chrome Probabilizer.AddEntry( 150, 50, 0.5f ); // Plomb break; case -4: Probabilizer.AddEntry( 26, 0, 0.2f ); // Or Probabilizer.AddEntry( 27, 50, 0.05f ); // Amethyste Probabilizer.AddEntry( 47, 50, 0.05f ); // Emeraude Probabilizer.AddEntry( 60, 50, 1.0f ); // Charbon Probabilizer.AddEntry( 74, 50, 2.0f ); // Fer Probabilizer.AddEntry( 109, 50, 0.04f ); // Diamond Probabilizer.AddEntry( 110, 50, 1.0f ); // Nickel Probabilizer.AddEntry( 121, 50, 1.0f ); // Chrome Probabilizer.AddEntry( 122, 50, 0.05f ); // Titanium Probabilizer.AddEntry( 127, 50, 1.0f ); // Etain Probabilizer.AddEntry( 150, 50, 1.0f ); // Plomb break; case -5: Probabilizer.AddEntry( 26, 0, 0.2f ); // Or Probabilizer.AddEntry( 27, 50, 0.05f ); // Amethyste Probabilizer.AddEntry( 60, 50, 1.0f ); // Charbon Probabilizer.AddEntry( 74, 50, 2.0f ); // Fer Probabilizer.AddEntry( 109, 50, 0.05f ); // Diamond Probabilizer.AddEntry( 110, 50, 1.0f ); // Nickel Probabilizer.AddEntry( 121, 50, 1.0f ); // Chrome Probabilizer.AddEntry( 122, 50, 0.05f ); // Titanium Probabilizer.AddEntry( 150, 50, 1.0f ); // Plomb break; case -6: Probabilizer.AddEntry( 26, 0, 0.2f ); // Or Probabilizer.AddEntry( 27, 50, 0.05f ); // Amethyste Probabilizer.AddEntry( 47, 50, 0.045f ); // Emeraude Probabilizer.AddEntry( 60, 50, 1.0f ); // Charbon Probabilizer.AddEntry( 74, 50, 2.0f ); // Fer Probabilizer.AddEntry( 109, 50, 0.1f ); // Diamond Probabilizer.AddEntry( 110, 50, 1.0f ); // Nickel Probabilizer.AddEntry( 121, 50, 1.0f ); // Chrome Probabilizer.AddEntry( 122, 50, 0.05f ); // Titanium Probabilizer.AddEntry( 150, 50, 1.0f ); // Plomb break; case -7: Probabilizer.AddEntry( 26, 0, 0.2f ); // Or Probabilizer.AddEntry( 27, 50, 0.05f ); // Amethyste Probabilizer.AddEntry( 60, 50, 1.0f ); // Charbon Probabilizer.AddEntry( 74, 50, 2.0f ); // Fer Probabilizer.AddEntry( 110, 50, 1.0f ); // Nickel Probabilizer.AddEntry( 121, 50, 1.0f ); // Chrome Probabilizer.AddEntry( 122, 50, 0.05f ); // Titanium Probabilizer.AddEntry( 150, 50, 1.0f ); // Plomb break; case -8: Probabilizer.AddEntry( 26, 0, 0.2f ); // Or Probabilizer.AddEntry( 27, 50, 0.05f ); // Amethyste Probabilizer.AddEntry( 46, 50, 0.05f ); // Rose des sables Probabilizer.AddEntry( 60, 50, 1.0f ); // Charbon Probabilizer.AddEntry( 74, 50, 2.0f ); // Fer Probabilizer.AddEntry( 110, 50, 1.0f ); // Nickel Probabilizer.AddEntry( 111, 50, 0.05f ); // Uranium Probabilizer.AddEntry( 121, 50, 1.0f ); // Chrome Probabilizer.AddEntry( 122, 50, 0.05f ); // Titanium Probabilizer.AddEntry( 150, 50, 1.0f ); // Plomb break; case -9: Probabilizer.AddEntry( 26, 0, 0.2f ); // Or Probabilizer.AddEntry( 27, 50, 0.05f ); // Amethyste Probabilizer.AddEntry( 60, 50, 1.0f ); // Charbon Probabilizer.AddEntry( 74, 50, 2.0f ); // Fer Probabilizer.AddEntry( 110, 50, 1.0f ); // Nickel Probabilizer.AddEntry( 111, 50, 0.05f ); // Uranium Probabilizer.AddEntry( 121, 50, 1.0f ); // Chrome Probabilizer.AddEntry( 122, 50, 0.05f ); // Titanium Probabilizer.AddEntry( 197, 50, 1.0f ); // Aluminium Ore break; case -10: // Water level Probabilizer.AddEntry( 10, 2, 15.0f ); break; /* case -1: default: Probabilizer.AddEntry(60, 50, 1.0); // Charbon Probabilizer.AddEntry(112,1, 1.0); // Cuivre Probabilizer.AddEntry(127,1, 0.4); // Etain Probabilizer.AddEntry( 44, 0, 0.10); // Vitrail // Rare ores Probabilizer.AddEntry( 74, 0, 0.05); // Fer Probabilizer.AddEntry( 26, 0, 0.1); // Or break; case -2: Probabilizer.AddEntry( 74, 50, 1.0); // Fer Probabilizer.AddEntry(60, 50, 1.0); // Charbon Probabilizer.AddEntry( 26, 0, 0.1); // Or Probabilizer.AddEntry(110, 50, 0.2); // Nickel Probabilizer.AddEntry(121, 50, 0.2); // Chrome break; */ } uint FenceBound = Probabilizer.ComputeProbabilities( 1.0f ); // Layers of ground. for( y = 0, Voxel_y = ( Sector_y << VoxelSector.ZVOXELBLOCSHIFT_Y ) - HeightOffset; y < VoxelSector.ZVOXELBLOCSIZE_Y; y++, Voxel_y++ ) { Type = 0; if( Voxel_y >= 0 ) Type = 0; else if( Voxel_y < -2176 ) { Type = 126; VoxelSector.Flag_Void_Regular = false; } // Bleu else if( Voxel_y < -2043 ) { Type = 3; VoxelSector.Flag_Void_Regular = false; } // Vert else if( Voxel_y < -2038 ) { Type = 52; VoxelSector.Flag_Void_Regular = false; } // Lave else if( Voxel_y < -2028 ) { Type = 0; VoxelSector.Flag_Void_Regular = false; } // Vide else if( Voxel_y < -1984 ) { Type = 3; VoxelSector.Flag_Void_Regular = false; } // Vert else if( Voxel_y < -1856 ) { Type = 5; VoxelSector.Flag_Void_Regular = false; } // Bleu ciel else if( Voxel_y < -1728 ) { Type = 2; VoxelSector.Flag_Void_Regular = false; } // Orange else if( Voxel_y < -1600 ) { Type = 3; VoxelSector.Flag_Void_Regular = false; } // Vert else if( Voxel_y < -1472 ) { Type = 1; VoxelSector.Flag_Void_Regular = false; } // Bleu else if( Voxel_y < -1339 ) { Type = 10; VoxelSector.Flag_Void_Regular = false; } // Blanc else if( Voxel_y < -1334 ) { Type = 86; VoxelSector.Flag_Void_Regular = false; VoxelSector.Flag_IsActiveVoxels = true; } // Acide else if( Voxel_y < -1324 ) { Type = 0; VoxelSector.Flag_Void_Regular = false; } // Vide else if( Voxel_y < -1280 ) { Type = 10; VoxelSector.Flag_Void_Regular = false; } // Blanc else if( Voxel_y < -1152 ) { Type = 5; VoxelSector.Flag_Void_Regular = false; } // Bleu ciel else if( Voxel_y < -1024 ) { Type = 2; VoxelSector.Flag_Void_Regular = false; } // Orange else if( Voxel_y < -896 ) { Type = 1; VoxelSector.Flag_Void_Regular = false; } // Vert else if( Voxel_y < -768 ) { Type = 1; VoxelSector.Flag_Void_Regular = false; } // Bleu else if( Voxel_y < -635 ) { Type = 10; VoxelSector.Flag_Void_Regular = false; } // Blanc else if( Voxel_y < -630 ) { Type = 85; VoxelSector.Flag_Void_Regular = false; VoxelSector.Flag_IsActiveVoxels = true; VoxelSector.Flag_NeedSortedRendering = true; } // Eau else if( Voxel_y < -620 ) { Type = 0; VoxelSector.Flag_Void_Regular = false; } // Vide else if( Voxel_y < -576 ) { Type = 10; VoxelSector.Flag_Void_Regular = false; } // Blanc else if( Voxel_y < -512 ) { Type = 7; VoxelSector.Flag_Void_Regular = false; } // Rose else if( Voxel_y < -448 ) { Type = 9; VoxelSector.Flag_Void_Regular = false; } // Gris else if( Voxel_y < -384 ) { Type = 8; VoxelSector.Flag_Void_Regular = false; } // Vert citron else if( Voxel_y < -320 ) { Type = 4; VoxelSector.Flag_Void_Regular = false; } // Rouge else if( Voxel_y < -256 ) { Type = 6; VoxelSector.Flag_Void_Regular = false; } // Jaune else if( Voxel_y < -192 ) { Type = 5; VoxelSector.Flag_Void_Regular = false; } // Bleu ciel else if( Voxel_y < -128 ) { Type = 2; VoxelSector.Flag_Void_Regular = false; } // Orange else if( Voxel_y < -64 ) { Type = 3; VoxelSector.Flag_Void_Regular = false; } // Vert else if( Voxel_y < 0 ) { Type = 1; VoxelSector.Flag_Void_Regular = false; } // Bleu else Type = 0; /* if (Voxel_y >=0 ) Type = 0; else if (Voxel_y < -960) {Type = 126; VoxelSector.Flag_Void_Regular = false;} else if (Voxel_y < -768) {Type = 1; VoxelSector.Flag_Void_Regular = false;} else if (Voxel_y < -630) {Type = 10; VoxelSector.Flag_Void_Regular = false;} else if (Voxel_y < -625) {Type = 85; VoxelSector.Flag_Void_Regular = false;} else if (Voxel_y < -615) {Type = 0; VoxelSector.Flag_Void_Regular = false;} else if (Voxel_y < -576) {Type = 10; VoxelSector.Flag_Void_Regular = false;} else if (Voxel_y < -512) {Type = 7; VoxelSector.Flag_Void_Regular = false;} else if (Voxel_y < -448) {Type = 9; VoxelSector.Flag_Void_Regular = false;} else if (Voxel_y < -384) {Type = 8; VoxelSector.Flag_Void_Regular = false; } else if (Voxel_y < -320) {Type = 4; VoxelSector.Flag_Void_Regular = false; } else if (Voxel_y < -256) {Type = 6; VoxelSector.Flag_Void_Regular = false; } else if (Voxel_y < -192) {Type = 5; VoxelSector.Flag_Void_Regular = false; } else if (Voxel_y < -128) {Type = 2; VoxelSector.Flag_Void_Regular = false; } // Orange else if (Voxel_y < -64) {Type = 3; VoxelSector.Flag_Void_Regular = false; } // Vert else if (Voxel_y < 0) {Type = 1; VoxelSector.Flag_Void_Regular = false; } // Bleu else Type = 0; */ TypeTable[y] = Type; //TypeTable[y]= 0; // debug MineralInclude[y] = ( ( Voxel_y < -5L ) && ( Type != 0 ) ); } // If sector is void, fill it more quickly if( VoxelSector.Flag_Void_Regular ) { for( i = 0; i < ( VoxelSector.ZVOXELBLOCSIZE_X * VoxelSector.ZVOXELBLOCSIZE_Y * VoxelSector.ZVOXELBLOCSIZE_Z ); i++ ) Data[i] = 0; return; } // Fill zone with inclusions ushort LastMineral = 0; uint Num = 0; for( i = 0; i < ( VoxelSector.ZVOXELBLOCSIZE_X * VoxelSector.ZVOXELBLOCSIZE_Y * VoxelSector.ZVOXELBLOCSIZE_Z ); i++ ) { Data[i] = TypeTable[i & VoxelSector.ZVOXELBLOCMASK_Y]; if( MineralInclude[i & VoxelSector.ZVOXELBLOCMASK_Y] ) { if( Probabilizer.IsBelowFence( RandomGen ) ) { Num = Probabilizer.GetTypeNum( RandomGen ); Data[i] = LastMineral = Probabilizer.GetVoxelType( Num ); } else if( LastMineral != 0 ) { if( Probabilizer.AllowRepeat( Num, RandomGen ) ) Data[i] = LastMineral; else LastMineral = 0; } // LastMineral = 0; } } // if (Pos_y<0) {Cnt=1;Flag_Void_Regular=false;Flag_Void_Transparent=true;} // if (Pos_y>=0){Cnt=0;Flag_Void_Regular=true;Flag_Void_Transparent=true;} /* if( VoxelSector.Pos_x == 0 && VoxelSector.Pos_y == 0 && VoxelSector.Pos_z == -2 && VoxelGlobalSettings.COMPILEOPTION_ALLOWSTARTINGSTORAGE ) { ZVoxelExtension_Storage* StorageExtension; StorageExtension = new ZVoxelExtension_Storage(); StorageExtension.VoxelType[0] = 42; StorageExtension.VoxelQuantity[0] = 1; StorageExtension.VoxelType[1] = 75; StorageExtension.VoxelQuantity[1] = 1; VoxelSector.SetCube_WithExtension( 8, 0, 8, 49, StorageExtension ); } */ }
void AddTreeOn( VoxelSector Sector, VoxelSector[] TemplateTable, uint ModelCount, ushort VoxelType ) { int x, y, z, i; uint Rnd; VoxelSector Template; ZVector3L Pos; i = 0; RandomGen.Reset(); random_seed[0] = i; random_seed[1] = 0; 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++ ) { random_seed[0] = i; Rnd = (uint)RandomGen.GetEntropy( 32, false ); if( Sector.Data.Data[i] == VoxelType && y < 60 && ( Rnd < 200000000 ) ) //100000000 { if( Sector.Data.Data[i + 1] == 0 ) { Template = TemplateTable[Rnd % ModelCount]; Pos.x = x - Template.Handle_x; Pos.y = y + 1 - Template.Handle_y; Pos.z = z - Template.Handle_z; //Sector.SetCube(Pos.x,Pos.y+1,Pos.z,1); Sector.BlitSector( Template, ref Pos ); } } i++; } }
void GenerateZone_DustField( VoxelSector VoxelSector, int Sector_x, int Sector_y, int Sector_z ) { ushort[] Data; RandomGen.Reset(); random_seed[0] = Sector_x; random_seed[1] = Sector_z; random_seed[2] = 0; random_seed[3] = 0; int n; n = 0; Data = VoxelSector.Data.Data; for( n = 0; n < VoxelSector.ZVOXELBLOCSIZE_X* VoxelSector.ZVOXELBLOCSIZE_Y * VoxelSector.ZVOXELBLOCSIZE_Z; n++ ) { Data[n++] = ( RandomGen.GetEntropy( 10, true ) < 10 ) ? (ushort)0 : (ushort)203; // 255 } }
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 ); } } }
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 ); } } } }
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 ); } } }
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; } } } }
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 ); } } }
/* 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 ); } }
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 ); } } }
public void GenerateSector( VoxelSector VoxelSector ) { int x, y, z, HeightOffset; ushort ZoneType, RngNum; x = VoxelSector.Pos_x; y = VoxelSector.Pos_y; z = VoxelSector.Pos_z; VoxelSector.Flag_Void_Regular = true; VoxelSector.Flag_Void_Transparent = true; int XSel = ( ( ( x ) >> 4 ) + 64 ); int ZSel = ( ( ( z ) >> 4 ) + 64 ); if( ( XSel >= 0 && XSel < 128 ) && ( ZSel >= 0 && ZSel < 128 ) ) { ZoneType = ConvCN[ZoneMap_New[XSel][ZSel]]; VoxelSector.ZoneType = ZoneType; RngNum = ConvCN[RingNum[XSel][ZSel]]; VoxelSector.RingNum = RngNum; HeightOffset = ZoneYOffset[RngNum]; VoxelSector.ZoneVersion = 1; // Set the default version num to 1. VoxelSector.GeneratorVersion = 1; // Generator version. Updated at each world change. if( y > 64 ) { GenerateZone_DustField( VoxelSector, x, y, z ); return; } switch( ZoneType ) { default: case 0: GenerateZone_Flat2( VoxelSector, HeightOffset, x, y, z ); GenerateRTFM( VoxelSector ); // GenerateBigTrees(VoxelSector); break; case 1: GenerateZone_NaturalMountains( VoxelSector, x, y, z ); break; case 2: GenerateZone_MathStruct_1( VoxelSector, HeightOffset, x, y, z ); GenerateBigTrees( VoxelSector ); break; case 3: GenerateZone_RandomStickSea( VoxelSector, HeightOffset, x, y, z ); break; case 4: GenerateZone_BlackWoods( VoxelSector, x, y, z ); GenerateBigTrees( VoxelSector ); break; case 5: GenerateZone_BlackWoods( VoxelSector, x, y, z ); GenerateBigTrees( VoxelSector ); GenerateAddBombs( VoxelSector, 0.002, 200, true ); break; case 6: GenerateZone_BigMountains( VoxelSector, HeightOffset, x, y, z ); //GenerateBigTrees(VoxelSector); break; case 7: GenerateZone_LavaRiver( VoxelSector ); GenerateBigTrees( VoxelSector ); break; case 8: GenerateZone_Flat2( VoxelSector, HeightOffset, x, y, z ); GenerateBigTrees( VoxelSector ); break; case 9: GenerateZone_AcidHills( VoxelSector, HeightOffset, x, y, z ); break; case 10: GenerateZone_WaterLands( VoxelSector, HeightOffset, x, y, z ); // GenerateBigTrees(VoxelSector); break; case 11: GenerateZone_WaterMountain( VoxelSector, HeightOffset, x, y, z ); break; case 12: GenerateZone_FlatAcidResistant( VoxelSector, HeightOffset, x, y, z ); break; case 13: GenerateZone_Generic_MappedTerrain( VoxelSector, 10, Canva_3_1, 512 ); // Main Terrain // Generate_Generic_LittleStructs( VoxelSector, &T3dTemplate_2, &Canva_3_2, 512 ); Generate_Generic_PlaceVoxel( VoxelSector, 87, Canva_3_3, 512, 0, true ); // Water Generator Generate_Generic_PlaceVoxel( VoxelSector, 88, Canva_3_2, 512, 1, true ); // Water Absorber VoxelSector.Flag_NeedSortedRendering = true; break; case 14: Generate_Terrain_1536( VoxelSector, HeightOffset, x, y, z ); AddTreeOn( VoxelSector, TreeTable, 3, 232 ); //AddTreeOn(VoxelSector, &Template_Vegetation_1, 232); break; case 15: Generate_Terrain_1537( VoxelSector, HeightOffset, x, y, z ); break; case 16: Generate_Terrain_1538( VoxelSector, HeightOffset, x, y, z ); AddTreeOn( VoxelSector, TreeTable, 3, 232 ); break; } } else { GenerateZone_WaterMountain( VoxelSector, -70, x, y, z ); } }
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 ); } } }
internal void MakeSectorTasks( VoxelSector Sector ) { // Sector Unloading. // // Compute distance of the sector from the player position sector. // If sector is too far, don't process further and send sector to unloading list. int xdist = Sector.Pos_x - Player_Sector.x; int ydist = Sector.Pos_y - Player_Sector.y; int zdist = Sector.Pos_z - Player_Sector.z; int Dist = ( xdist * xdist + ydist * ydist + zdist * zdist ); if( Dist > SectorEjectDistance ) if( Sector.Flag_KeepInMemory ) Log.log( "Prevented eject; is processing in reactor" ); if( Dist > SectorEjectDistance && !Sector.Flag_KeepInMemory ) { if( World.RequestSectorEject( Sector ) ) { Sector.Flag_DeletePending = true; //printf("EjectDemand : %lx L1 Start:%lu End:%lu nEntries:%lu\n",Sector,World.SectorEjectList.debug_getstart(),World.SectorEjectList.debug_GetEnd(),World.SectorEjectList.debug_GetnEntries()); debug_DeleteRequests++; // printf("EjectDemand : %lx %lu\n",Sector,debug_DeleteRequests); } } // 14 // **************************** Sector face culling *********************** // handled during normal culling... //uint64_t CullingResult; /* if( !Sector.Flag_DeletePending && Sector.PartialCulling != 0 ) { //CullingResult = Sector.Culler.CullSector( Sector, false, Sector.PartialCulling ); //Sector.PartialCulling ^= CullingResult & (DRAWFACE_ABOVE | DRAWFACE_BELOW | DRAWFACE_LEFT | DRAWFACE_RIGHT | DRAWFACE_AHEAD | DRAWFACE_BEHIND); //Sector.PartialCulling &= (DRAWFACE_ABOVE | DRAWFACE_BELOW | DRAWFACE_LEFT | DRAWFACE_RIGHT | DRAWFACE_AHEAD | DRAWFACE_BEHIND); //if (CullingResult) Sector.Flag_Render_Dirty = true; // printf("Cull %ld,%ld,%ld :%lx (%lx)\n", Sector.Pos_x, Sector.Pos_y, Sector.Pos_z, CullingResult, (ULong)Sector.PartialCulling); } */ // **************************** Egmy Scattering **************************** #if asdf if( GameEnv.GameEventSequencer.SlotIsActivated( 1 ) ) { EgmyScatter.ScatterEgmys_T1( Sector ); } else { EgmyScatter.ResetWave(); } #endif }
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; } } } }