Finally ready to merge the two tool codebases
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import json
|
||||
import os
|
||||
from dusk.event import Event
|
||||
from editortool.map.mapdefs import CHUNK_WIDTH, CHUNK_HEIGHT, CHUNK_DEPTH, CHUNK_VERTEX_COUNT_MAX
|
||||
from editortool.map.tile import Tile
|
||||
from editortool.map.vertexbuffer import VertexBuffer
|
||||
from OpenGL.GL import *
|
||||
|
||||
class Chunk:
|
||||
def __init__(self, map, x, y, z):
|
||||
@@ -12,6 +16,25 @@ class Chunk:
|
||||
self.original = {}
|
||||
self.onChunkData = Event()
|
||||
|
||||
self.tiles = {}
|
||||
self.vertexBuffer = VertexBuffer()
|
||||
|
||||
tileIndex = 0
|
||||
for tx in range(CHUNK_WIDTH):
|
||||
for ty in range(CHUNK_HEIGHT):
|
||||
for tz in range(CHUNK_DEPTH):
|
||||
self.tiles[tileIndex] = Tile(self, tx, ty, tz, tileIndex)
|
||||
tileIndex += 1
|
||||
|
||||
# Update vertices
|
||||
self.tileUpdateVertices()
|
||||
|
||||
def tileUpdateVertices(self):
|
||||
self.vertexBuffer.clear()
|
||||
for tile in self.tiles.values():
|
||||
tile.buffer(self.vertexBuffer)
|
||||
self.vertexBuffer.buildData()
|
||||
|
||||
def load(self):
|
||||
fname = self.getFilename()
|
||||
if not fname or not os.path.exists(fname):
|
||||
@@ -51,3 +74,7 @@ class Chunk:
|
||||
if dir_path is None:
|
||||
return None
|
||||
return f"{dir_path}/{self.x}_{self.y}_{self.z}.json"
|
||||
|
||||
def draw(self):
|
||||
glColor3f(0.0, 1.0, 1.0)
|
||||
self.vertexBuffer.draw()
|
||||
Reference in New Issue
Block a user