Finally ready to merge the two tool codebases
This commit is contained in:
@@ -1,29 +1,39 @@
|
||||
from OpenGL.GL import *
|
||||
from editortool.map.mapdefs import TILE_WIDTH, TILE_HEIGHT, TILE_DEPTH
|
||||
from editortool.map.mapdefs import TILE_WIDTH, TILE_HEIGHT, TILE_DEPTH, CHUNK_WIDTH, CHUNK_HEIGHT, CHUNK_DEPTH
|
||||
|
||||
class Tile:
|
||||
def __init__(self):
|
||||
self.tile_id = 0
|
||||
def __init__(self, chunk, x, y, z, tileIndex):
|
||||
self.tileId = 0
|
||||
self.chunk = chunk
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.z = z
|
||||
|
||||
self.posX = x * TILE_WIDTH + chunk.x * CHUNK_WIDTH * TILE_WIDTH
|
||||
self.posY = y * TILE_HEIGHT + chunk.y * CHUNK_HEIGHT * TILE_HEIGHT
|
||||
self.posZ = z * TILE_DEPTH + chunk.z * CHUNK_DEPTH * TILE_DEPTH
|
||||
|
||||
def draw(self, x, y, z):
|
||||
def buffer(self, vertexBuffer):
|
||||
if self.z != 0:
|
||||
return
|
||||
# if self.x != 0 or self.y != 0 or self.z != 0:
|
||||
# return # Only buffer the tile at (0,0,0)
|
||||
|
||||
# Center tile.
|
||||
x = self.posX - TILE_WIDTH / 2.0
|
||||
y = self.posY - TILE_HEIGHT / 2.0
|
||||
z = self.posZ - TILE_DEPTH / 2.0
|
||||
w = TILE_WIDTH
|
||||
h = TILE_HEIGHT
|
||||
d = TILE_DEPTH
|
||||
|
||||
x = x * w
|
||||
y = y * h
|
||||
z = z * d
|
||||
# Quad on the XY plane at z
|
||||
vertexBuffer.vertices.extend([
|
||||
x, y, z, # bottom left
|
||||
x + w, y, z, # bottom right
|
||||
x + w, y + h, z, # top right
|
||||
|
||||
# Center tile.
|
||||
x -= w / 2.0
|
||||
y -= h / 2.0
|
||||
z -= d / 2.0
|
||||
|
||||
# Draw the tile as a flat square on the X-Y plane at depth z.
|
||||
glColor3f(1.0, 0.0, 0.0) # Red color
|
||||
glBegin(GL_QUADS)
|
||||
glVertex3f(x, y, z) # Bottom-left
|
||||
glVertex3f(x + w, y, z) # Bottom-right
|
||||
glVertex3f(x + w, y + h, z) # Top-right
|
||||
glVertex3f(x, y + h, z) # Top-left
|
||||
glEnd()
|
||||
x, y, z, # bottom left
|
||||
x + w, y + h, z, # top right
|
||||
x, y + h, z # top left
|
||||
])
|
||||
Reference in New Issue
Block a user