public TerrainDualContourer(IFactory <int, INoise3D> noiseFactory) { Contracts.Requires.That(noiseFactory != null); var materialPropertiesTable = CreateMaterialPropertiesTable(noiseFactory); var materialTexturer = new TerrainMaterialSurfaceGenerator <TSurfaceData>(materialPropertiesTable); this.dualContourer = new FlatQuadContourer <TerrainVoxel, TSurfaceData>( new TerrainContourDeterminer <TSurfaceData>(materialPropertiesTable), new VertexSurfaceWriter <TerrainVoxel, TSurfaceData>(new AverageDensitySurfaceGenerator <TSurfaceData>()), materialTexturer, materialTexturer); }
public ContourPhase( IStageIdentity stageIdentity, IStageBounds stageBounds, IRasterChunkConfig <Index3D> voxelChunkConfig, IAsyncFactory <ChunkKey, IDisposableValue <IReadOnlyVoxelGridChunk> > voxelChunkFactory, IDualContourer <TerrainVoxel, TSurfaceData, NormalColorTextureVertex> contourer, IChunkStore <ChunkKey, SerializedMeshChunk> meshChunkStore, int maxBufferedChunks, BatchSerializeGenerationOptions options = null) { Contracts.Requires.That(stageIdentity != null); Contracts.Requires.That(stageBounds != null); Contracts.Requires.That(voxelChunkConfig != null); Contracts.Requires.That(voxelChunkFactory != null); Contracts.Requires.That(contourer != null); Contracts.Requires.That(meshChunkStore != null); Contracts.Requires.That(maxBufferedChunks > 0); var phaseIdentity = new GenerationPhaseIdentity(nameof(ContourPhase <TSurfaceData>)); var chunkKeys = new ChunkKeyCollection(stageBounds); var poolOptions = new PoolOptions <IMutableDivisibleMesh <NormalColorTextureVertex> >() { ResetAction = mesh => mesh.Clear(), }; this.pool = Pool.WithFactory.New( Factory.From <IMutableDivisibleMesh <NormalColorTextureVertex> >( () => new MutableDivisibleMesh <NormalColorTextureVertex>()), poolOptions); var chunkFactory = new ContourMeshFactory <TSurfaceData>( voxelChunkConfig, voxelChunkFactory, this.pool, contourer); var serializer = DivisibleMeshSerializer.NormalColorTextureVertices.WithColorAlpha[ options?.SerializationEndianness ?? DefaultSerializationEndianness]; var persistableFactory = new SerializeMeshChunkFactory(chunkFactory, serializer); this.Phase = new ChunkedBatchingPhase <ChunkKey, SerializedMeshChunk>( stageIdentity, phaseIdentity, chunkKeys, persistableFactory, meshChunkStore, maxBufferedChunks, options); this.Completion = this.CompleteAsync(); }
public ContourMeshFactory( IRasterChunkConfig <Index3D> voxelChunkConfig, IAsyncFactory <ChunkKey, IDisposableValue <IReadOnlyVoxelGridChunk> > voxelChunkFactory, IPool <IMutableDivisibleMesh <NormalColorTextureVertex> > meshBuilderPool, IDualContourer <TerrainVoxel, TSurfaceData, NormalColorTextureVertex> contourer) { Contracts.Requires.That(voxelChunkConfig != null); Contracts.Requires.That(voxelChunkFactory != null); Contracts.Requires.That(meshBuilderPool != null); Contracts.Requires.That(contourer != null); this.voxelChunkDimensionsInVoxels = voxelChunkConfig.Bounds.Dimensions; this.meshBuilderPool = meshBuilderPool; this.contourer = contourer; this.chunkConglomerator = new ChunkConglomerator <IReadOnlyVoxelGridChunk>( async index => await voxelChunkFactory.CreateAsync( new ChunkKey(index - new Index3D(1))).DontMarshallContext(), new Index3D(3)); }