def __init__(self): self.minP = Vector3(0,0,0) self.maxP = Vector3(0,0,0) self.boxVertices = math3D.getBoxVertices(self.minP, self.maxP) self.voxelData = None self.verts = None self.norms = None self.txcds = None self.numTrianglesInBatch = 0 # number of triangles in the vertex data self.vbo_verts = GLuint(0) self.vbo_norms = GLuint(0) self.vbo_txcds = GLuint(0) self.pool = None self.dirty = True self.terrainTaskResult = None self.saveTaskResult = None self.setNotDirty = lambda r: setattr(self, 'dirty', False) # Lock to protect terrain data (voxelData, verts, and norms) self.terrainDataLock = multiprocessing.Lock()
def loadFromDisk(cls, folder, chunkID, minP, maxP, pool): chunk = Chunk() chunk.minP = minP # extents of the chunk in world-space chunk.maxP = maxP # " chunk.boxVertices = math3D.getBoxVertices(chunk.minP, chunk.maxP) chunk.dirty = False chunk.pool = pool chunk.folder = folder # Spin off a task to load the terrain. if debugSerializeChunkTasks: r = loadChunkFromDiskWorker(folder, chunkID) chunk._callbackTerrainTaskHasFinished(r) else: callback = lambda r: chunk._callbackTerrainTaskHasFinished(r) chunk.terrainTaskResult = \ pool.apply_async(loadChunkFromDiskWorker, [folder, chunkID], callback=callback) return chunk
def fromProceduralGeneration(cls, minP, maxP, terrainHeight, seed, pool, folder): chunk = Chunk() chunk.minP = minP # extents of the chunk in world-space chunk.maxP = maxP # " chunk.boxVertices = math3D.getBoxVertices(chunk.minP, chunk.maxP) chunk.pool = pool chunk.folder = folder # Spin off a task to generate terrain and geometry. # Chunk will have no terrain or geometry until this has finished. if debugSerializeChunkTasks: r = procedurallyGenerateChunkWorker(seed,terrainHeight,minP,maxP) chunk._callbackTerrainTaskHasFinished(r) else: chunk.terrainTaskResult = \ pool.apply_async(procedurallyGenerateChunkWorker, [seed, terrainHeight, minP, maxP], callback=lambda r:chunk._callbackTerrainTaskHasFinished(r)) return chunk