About to draw chunk
This commit is contained in:
48
tools/editortool/map/selectbox.py
Normal file
48
tools/editortool/map/selectbox.py
Normal file
@@ -0,0 +1,48 @@
|
||||
import OpenGL.GL as gl
|
||||
from dusk.defs import defs
|
||||
import colorsys
|
||||
|
||||
hue = [0.0] # Mutable container for static hue
|
||||
|
||||
def drawSelectBox(x, y, z):
|
||||
w = float(defs.get('TILE_WIDTH'))
|
||||
h = float(defs.get('TILE_HEIGHT'))
|
||||
d = float(defs.get('TILE_DEPTH'))
|
||||
|
||||
x = x * w
|
||||
y = y * h
|
||||
z = z * d
|
||||
|
||||
# Center box.
|
||||
x -= w / 2.0
|
||||
y -= h / 2.0
|
||||
z -= d / 2.0
|
||||
|
||||
# Define the 8 vertices of the cube with w=h=d=1
|
||||
vertices = [
|
||||
(x, y, z), # 0: min corner
|
||||
(x+w, y, z), # 1
|
||||
(x+w, y+h, z), # 2
|
||||
(x, y+h, z), # 3
|
||||
(x, y, z+d), # 4
|
||||
(x+w, y, z+d), # 5
|
||||
(x+w, y+h, z+d), # 6
|
||||
(x, y+h, z+d) # 7
|
||||
]
|
||||
# List of edges as pairs of vertex indices
|
||||
edges = [
|
||||
(0, 1), (1, 2), (2, 3), (3, 0), # bottom face
|
||||
(4, 5), (5, 6), (6, 7), (7, 4), # top face
|
||||
(0, 4), (1, 5), (2, 6), (3, 7) # vertical edges
|
||||
]
|
||||
|
||||
# Cycle hue
|
||||
hue[0] = (hue[0] + 0.01) % 1.0
|
||||
r, g, b = colorsys.hsv_to_rgb(hue[0], 1.0, 1.0)
|
||||
gl.glColor3f(r, g, b)
|
||||
gl.glLineWidth(2.0)
|
||||
gl.glBegin(gl.GL_LINES)
|
||||
for edge in edges:
|
||||
for vertex in edge:
|
||||
gl.glVertex3f(*vertices[vertex])
|
||||
gl.glEnd()
|
||||
Reference in New Issue
Block a user