chiark / gitweb /
Merge branch 'master' into SteamEngine
[cura.git] / Cura / gui / util / previewTools.py
1 from __future__ import absolute_import
2
3 import math
4 import wx
5 import numpy
6
7 import OpenGL
8 OpenGL.ERROR_CHECKING = False
9 from OpenGL.GLU import *
10 from OpenGL.GL import *
11
12 from Cura.gui.util import opengl
13
14 class toolNone(object):
15         def __init__(self, parent):
16                 self.parent = parent
17
18         def OnMouseMove(self, p0, p1):
19                 pass
20
21         def OnDragStart(self, p0, p1):
22                 return False
23
24         def OnDrag(self, p0, p1):
25                 pass
26
27         def OnDragEnd(self):
28                 pass
29
30         def OnDraw(self):
31                 pass
32
33 class toolInfo(object):
34         def __init__(self, parent):
35                 self.parent = parent
36
37         def OnMouseMove(self, p0, p1):
38                 pass
39
40         def OnDragStart(self, p0, p1):
41                 return False
42
43         def OnDrag(self, p0, p1):
44                 pass
45
46         def OnDragEnd(self):
47                 pass
48
49         def OnDraw(self):
50                 glDisable(GL_LIGHTING)
51                 glDisable(GL_BLEND)
52                 glDisable(GL_DEPTH_TEST)
53                 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
54                 glColor3ub(0,0,0)
55                 size = self.parent.getObjectSize()
56                 radius = self.parent.getObjectBoundaryCircle()
57                 glPushMatrix()
58                 glTranslate(0,0,size[2]/2 + 5)
59                 glRotate(-self.parent.yaw, 0,0,1)
60                 if self.parent.pitch < 80:
61                         glTranslate(0, radius + 5,0)
62                 elif self.parent.pitch < 100:
63                         glTranslate(0, (radius + 5) * (90 - self.parent.pitch) / 10,0)
64                 else:
65                         glTranslate(0,-(radius + 5),0)
66                 opengl.glDrawStringCenter("%dx%dx%d" % (size[0], size[1], size[2]))
67                 glPopMatrix()
68
69                 glColor(255,255,255)
70                 size = size / 2
71                 glLineWidth(1)
72                 glBegin(GL_LINES)
73                 glVertex3f(size[0], size[1], size[2])
74                 glVertex3f(size[0], size[1], size[2]/4*3)
75                 glVertex3f(size[0], size[1], size[2])
76                 glVertex3f(size[0], size[1]/4*3, size[2])
77                 glVertex3f(size[0], size[1], size[2])
78                 glVertex3f(size[0]/4*3, size[1], size[2])
79
80                 glVertex3f(-size[0], -size[1], size[2])
81                 glVertex3f(-size[0], -size[1], size[2]/4*3)
82                 glVertex3f(-size[0], -size[1], size[2])
83                 glVertex3f(-size[0], -size[1]/4*3, size[2])
84                 glVertex3f(-size[0], -size[1], size[2])
85                 glVertex3f(-size[0]/4*3, -size[1], size[2])
86
87                 glVertex3f(size[0], -size[1], -size[2])
88                 glVertex3f(size[0], -size[1], -size[2]/4*3)
89                 glVertex3f(size[0], -size[1], -size[2])
90                 glVertex3f(size[0], -size[1]/4*3, -size[2])
91                 glVertex3f(size[0], -size[1], -size[2])
92                 glVertex3f(size[0]/4*3, -size[1], -size[2])
93
94                 glVertex3f(-size[0], size[1], -size[2])
95                 glVertex3f(-size[0], size[1], -size[2]/4*3)
96                 glVertex3f(-size[0], size[1], -size[2])
97                 glVertex3f(-size[0], size[1]/4*3, -size[2])
98                 glVertex3f(-size[0], size[1], -size[2])
99                 glVertex3f(-size[0]/4*3, size[1], -size[2])
100                 glEnd()
101
102 class toolRotate(object):
103         def __init__(self, parent):
104                 self.parent = parent
105                 self.rotateRingDist = 1.5
106                 self.rotateRingDistMin = 1.3
107                 self.rotateRingDistMax = 1.7
108                 self.dragPlane = None
109                 self.dragStartAngle = None
110                 self.dragEndAngle = None
111
112         def _ProjectToPlanes(self, p0, p1):
113                 cursorX0 = p0 - (p1 - p0) * (p0[0] / (p1[0] - p0[0]))
114                 cursorY0 = p0 - (p1 - p0) * (p0[1] / (p1[1] - p0[1]))
115                 cursorZ0 = p0 - (p1 - p0) * (p0[2] / (p1[2] - p0[2]))
116                 cursorYZ = math.sqrt((cursorX0[1] * cursorX0[1]) + (cursorX0[2] * cursorX0[2]))
117                 cursorXZ = math.sqrt((cursorY0[0] * cursorY0[0]) + (cursorY0[2] * cursorY0[2]))
118                 cursorXY = math.sqrt((cursorZ0[0] * cursorZ0[0]) + (cursorZ0[1] * cursorZ0[1]))
119                 return cursorX0, cursorY0, cursorZ0, cursorYZ, cursorXZ, cursorXY
120
121         def OnMouseMove(self, p0, p1):
122                 radius = self.parent.getObjectBoundaryCircle()
123                 cursorX0, cursorY0, cursorZ0, cursorYZ, cursorXZ, cursorXY = self._ProjectToPlanes(p0, p1)
124                 oldDragPlane = self.dragPlane
125                 if radius * self.rotateRingDistMin <= cursorXY <= radius * self.rotateRingDistMax or radius * self.rotateRingDistMin <= cursorYZ <= radius * self.rotateRingDistMax or radius * self.rotateRingDistMin <= cursorXZ <= radius * self.rotateRingDistMax:
126                         #self.parent.SetCursor(wx.StockCursor(wx.CURSOR_SIZING))
127                         if self.dragStartAngle is None:
128                                 if radius * self.rotateRingDistMin <= cursorXY <= radius * self.rotateRingDistMax:
129                                         self.dragPlane = 'XY'
130                                 elif radius * self.rotateRingDistMin <= cursorXZ <= radius * self.rotateRingDistMax:
131                                         self.dragPlane = 'XZ'
132                                 else:
133                                         self.dragPlane = 'YZ'
134                 else:
135                         if self.dragStartAngle is None:
136                                 self.dragPlane = ''
137                         #self.parent.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT))
138
139         def OnDragStart(self, p0, p1):
140                 radius = self.parent.getObjectBoundaryCircle()
141                 cursorX0, cursorY0, cursorZ0, cursorYZ, cursorXZ, cursorXY = self._ProjectToPlanes(p0, p1)
142                 if radius * self.rotateRingDistMin <= cursorXY <= radius * self.rotateRingDistMax or radius * self.rotateRingDistMin <= cursorYZ <= radius * self.rotateRingDistMax or radius * self.rotateRingDistMin <= cursorXZ <= radius * self.rotateRingDistMax:
143                         if radius * self.rotateRingDistMin <= cursorXY <= radius * self.rotateRingDistMax:
144                                 self.dragPlane = 'XY'
145                                 self.dragStartAngle = math.atan2(cursorZ0[1], cursorZ0[0]) * 180 / math.pi
146                         elif radius * self.rotateRingDistMin <= cursorXZ <= radius * self.rotateRingDistMax:
147                                 self.dragPlane = 'XZ'
148                                 self.dragStartAngle = math.atan2(cursorY0[2], cursorY0[0]) * 180 / math.pi
149                         else:
150                                 self.dragPlane = 'YZ'
151                                 self.dragStartAngle = math.atan2(cursorX0[2], cursorX0[1]) * 180 / math.pi
152                         self.dragEndAngle = self.dragStartAngle
153                         return True
154                 return False
155
156         def OnDrag(self, p0, p1):
157                 cursorX0, cursorY0, cursorZ0, cursorYZ, cursorXZ, cursorXY = self._ProjectToPlanes(p0, p1)
158                 if self.dragPlane == 'XY':
159                         angle = math.atan2(cursorZ0[1], cursorZ0[0]) * 180 / math.pi
160                 elif self.dragPlane == 'XZ':
161                         angle = math.atan2(cursorY0[2], cursorY0[0]) * 180 / math.pi
162                 else:
163                         angle = math.atan2(cursorX0[2], cursorX0[1]) * 180 / math.pi
164                 diff = angle - self.dragStartAngle
165                 if wx.GetKeyState(wx.WXK_SHIFT):
166                         diff = round(diff / 1) * 1
167                 else:
168                         diff = round(diff / 15) * 15
169                 if diff > 180:
170                         diff -= 360
171                 if diff < -180:
172                         diff += 360
173                 rad = diff / 180.0 * math.pi
174                 self.dragEndAngle = self.dragStartAngle + diff
175                 if self.dragPlane == 'XY':
176                         self.parent.tempMatrix = numpy.matrix([[math.cos(rad), math.sin(rad), 0], [-math.sin(rad), math.cos(rad), 0], [0,0,1]], numpy.float64)
177                 elif self.dragPlane == 'XZ':
178                         self.parent.tempMatrix = numpy.matrix([[math.cos(rad), 0, math.sin(rad)], [0,1,0], [-math.sin(rad), 0, math.cos(rad)]], numpy.float64)
179                 else:
180                         self.parent.tempMatrix = numpy.matrix([[1,0,0], [0, math.cos(rad), math.sin(rad)], [0, -math.sin(rad), math.cos(rad)]], numpy.float64)
181
182         def OnDragEnd(self):
183                 self.dragStartAngle = None
184
185         def OnDraw(self):
186                 glDisable(GL_LIGHTING)
187                 glDisable(GL_BLEND)
188                 glDisable(GL_DEPTH_TEST)
189                 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
190                 radius = self.parent.getObjectBoundaryCircle()
191                 glScalef(self.rotateRingDist * radius, self.rotateRingDist * radius, self.rotateRingDist * radius)
192                 if self.dragPlane == 'XY':
193                         glLineWidth(3)
194                         glColor4ub(255,64,64,255)
195                         if self.dragStartAngle is not None:
196                                 glPushMatrix()
197                                 glRotate(self.dragStartAngle, 0,0,1)
198                                 glBegin(GL_LINES)
199                                 glVertex3f(0,0,0)
200                                 glVertex3f(1,0,0)
201                                 glEnd()
202                                 glPopMatrix()
203                                 glPushMatrix()
204                                 glRotate(self.dragEndAngle, 0,0,1)
205                                 glBegin(GL_LINES)
206                                 glVertex3f(0,0,0)
207                                 glVertex3f(1,0,0)
208                                 glEnd()
209                                 glTranslatef(1.1,0,0)
210                                 glColor4ub(0,0,0,255)
211                                 opengl.glDrawStringCenter("%d" % (abs(self.dragEndAngle - self.dragStartAngle)))
212                                 glColor4ub(255,64,64,255)
213                                 glPopMatrix()
214                 else:
215                         glLineWidth(1)
216                         glColor4ub(128,0,0,255)
217                 glBegin(GL_LINE_LOOP)
218                 for i in xrange(0, 64):
219                         glVertex3f(math.cos(i/32.0*math.pi), math.sin(i/32.0*math.pi),0)
220                 glEnd()
221                 if self.dragPlane == 'YZ':
222                         glColor4ub(64,255,64,255)
223                         glLineWidth(3)
224                         if self.dragStartAngle is not None:
225                                 glPushMatrix()
226                                 glRotate(self.dragStartAngle, 1,0,0)
227                                 glBegin(GL_LINES)
228                                 glVertex3f(0,0,0)
229                                 glVertex3f(0,1,0)
230                                 glEnd()
231                                 glPopMatrix()
232                                 glPushMatrix()
233                                 glRotate(self.dragEndAngle, 1,0,0)
234                                 glBegin(GL_LINES)
235                                 glVertex3f(0,0,0)
236                                 glVertex3f(0,1,0)
237                                 glEnd()
238                                 glTranslatef(0,1.1,0)
239                                 glColor4ub(0,0,0,255)
240                                 opengl.glDrawStringCenter("%d" % (abs(self.dragEndAngle - self.dragStartAngle)))
241                                 glColor4ub(64,255,64,255)
242                                 glPopMatrix()
243                 else:
244                         glColor4ub(0,128,0,255)
245                         glLineWidth(1)
246                 glBegin(GL_LINE_LOOP)
247                 for i in xrange(0, 64):
248                         glVertex3f(0, math.cos(i/32.0*math.pi), math.sin(i/32.0*math.pi))
249                 glEnd()
250                 if self.dragPlane == 'XZ':
251                         glLineWidth(3)
252                         glColor4ub(255,255,0,255)
253                         if self.dragStartAngle is not None:
254                                 glPushMatrix()
255                                 glRotate(self.dragStartAngle, 0,-1,0)
256                                 glBegin(GL_LINES)
257                                 glVertex3f(0,0,0)
258                                 glVertex3f(1,0,0)
259                                 glEnd()
260                                 glPopMatrix()
261                                 glPushMatrix()
262                                 glRotate(self.dragEndAngle, 0,-1,0)
263                                 glBegin(GL_LINES)
264                                 glVertex3f(0,0,0)
265                                 glVertex3f(1,0,0)
266                                 glEnd()
267                                 glTranslatef(1.1,0,0)
268                                 glColor4ub(0,0,0,255)
269                                 opengl.glDrawStringCenter("%d" % (abs(self.dragEndAngle - self.dragStartAngle)))
270                                 glColor4ub(255,255,0,255)
271                                 glPopMatrix()
272                 else:
273                         glColor4ub(128,128,0,255)
274                         glLineWidth(1)
275                 glBegin(GL_LINE_LOOP)
276                 for i in xrange(0, 64):
277                         glVertex3f(math.cos(i/32.0*math.pi), 0, math.sin(i/32.0*math.pi))
278                 glEnd()
279                 glEnable(GL_DEPTH_TEST)
280
281 class toolScale(object):
282         def __init__(self, parent):
283                 self.parent = parent
284                 self.node = None
285                 self.scale = None
286
287         def _pointDist(self, p0, p1, p2):
288                 return numpy.linalg.norm(numpy.cross((p0 - p1), (p0 - p2))) / numpy.linalg.norm(p2 - p1)
289
290         def _traceNodes(self, p0, p1):
291                 s = self._nodeSize()
292                 if self._pointDist(numpy.array([0,0,0],numpy.float32), p0, p1) < s * 2:
293                         return 1
294                 if self._pointDist(numpy.array([s*15,0,0],numpy.float32), p0, p1) < s * 2:
295                         return 2
296                 if self._pointDist(numpy.array([0,s*15,0],numpy.float32), p0, p1) < s * 2:
297                         return 3
298                 if self._pointDist(numpy.array([0,0,s*15],numpy.float32), p0, p1) < s * 2:
299                         return 4
300                 return None
301
302         def _lineLineCrossingDistOnLine(self, s0, e0, s1, e1):
303                 d0 = e0 - s0
304                 d1 = e1 - s1
305                 a = numpy.dot(d0, d0)
306                 b = numpy.dot(d0, d1)
307                 e = numpy.dot(d1, d1)
308                 d = a*e - b*b
309
310                 r = s0 - s1
311                 c = numpy.dot(d0, r)
312                 f = numpy.dot(d1, r)
313
314                 s = (b*f - c*e) / d
315                 t = (a*f - b*c) / d
316                 return t
317
318         def _nodeSize(self):
319                 return float(self.parent._zoom) / float(self.parent.GetSize().GetWidth()) * 6.0
320
321         def OnMouseMove(self, p0, p1):
322                 self.node = self._traceNodes(p0, p1)
323
324         def OnDragStart(self, p0, p1):
325                 if self.node is None:
326                         return False
327                 return True
328
329         def OnDrag(self, p0, p1):
330                 s = self._nodeSize()
331                 endPoint = [1,1,1]
332                 if self.node == 2:
333                         endPoint = [1,0,0]
334                 elif self.node == 3:
335                         endPoint = [0,1,0]
336                 elif self.node == 4:
337                         endPoint = [0,0,1]
338                 scale = self._lineLineCrossingDistOnLine(p0, p1, numpy.array([0,0,0], numpy.float32), numpy.array(endPoint, numpy.float32)) / 15.0 / s
339                 if not wx.GetKeyState(wx.WXK_SHIFT):
340                         objMatrix = self.parent.getObjectMatrix()
341                         scaleX = numpy.linalg.norm(objMatrix[::,0].getA().flatten())
342                         scaleY = numpy.linalg.norm(objMatrix[::,1].getA().flatten())
343                         scaleZ = numpy.linalg.norm(objMatrix[::,2].getA().flatten())
344                         if self.node == 1 or not wx.GetKeyState(wx.WXK_CONTROL):
345                                 matrixScale = (scaleX + scaleY + scaleZ) / 3
346                         elif self.node == 2:
347                                 matrixScale = scaleX
348                         elif self.node == 3:
349                                 matrixScale = scaleY
350                         elif self.node == 4:
351                                 matrixScale = scaleZ
352                         scale = (round((matrixScale * scale) * 10) / 10) / matrixScale
353                 if scale < 0:
354                         scale = -scale
355                 if scale < 0.1:
356                         scale = 0.1
357                 self.scale = scale
358                 if self.node == 1 or not wx.GetKeyState(wx.WXK_CONTROL):
359                         self.parent.tempMatrix = numpy.matrix([[scale,0,0], [0, scale, 0], [0, 0, scale]], numpy.float64)
360                 elif self.node == 2:
361                         self.parent.tempMatrix = numpy.matrix([[scale,0,0], [0, 1, 0], [0, 0, 1]], numpy.float64)
362                 elif self.node == 3:
363                         self.parent.tempMatrix = numpy.matrix([[1,0,0], [0, scale, 0], [0, 0, 1]], numpy.float64)
364                 elif self.node == 4:
365                         self.parent.tempMatrix = numpy.matrix([[1,0,0], [0, 1, 0], [0, 0, scale]], numpy.float64)
366
367         def OnDragEnd(self):
368                 self.scale = None
369
370         def OnDraw(self):
371                 s = self._nodeSize()
372                 sx = s*15
373                 sy = s*15
374                 sz = s*15
375                 if self.node == 2 and self.scale is not None:
376                         sx *= self.scale
377                 if self.node == 3 and self.scale is not None:
378                         sy *= self.scale
379                 if self.node == 4 and self.scale is not None:
380                         sz *= self.scale
381                 objMatrix = self.parent.getObjectMatrix()
382                 scaleX = numpy.linalg.norm(objMatrix[::,0].getA().flatten())
383                 scaleY = numpy.linalg.norm(objMatrix[::,1].getA().flatten())
384                 scaleZ = numpy.linalg.norm(objMatrix[::,2].getA().flatten())
385                 if self.scale is not None:
386                         scaleX *= self.scale
387                         scaleY *= self.scale
388                         scaleZ *= self.scale
389
390                 glDisable(GL_LIGHTING)
391                 glDisable(GL_DEPTH_TEST)
392                 glEnable(GL_BLEND)
393                 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
394
395                 glColor3ub(0,0,0)
396                 size = self.parent.getObjectSize()
397                 radius = self.parent.getObjectBoundaryCircle()
398                 if self.scale is not None:
399                         radius *= self.scale
400                 glPushMatrix()
401                 glTranslate(0,0,size[2]/2 + 5)
402                 glRotate(-self.parent._yaw, 0,0,1)
403                 if self.parent._pitch < 80:
404                         glTranslate(0, radius + 5,0)
405                 elif self.parent._pitch < 100:
406                         glTranslate(0, (radius + 5) * (90 - self.parent._pitch) / 10,0)
407                 else:
408                         glTranslate(0,-(radius + 5),0)
409                 if self.parent.tempMatrix is not None:
410                         size = (numpy.matrix([size]) * self.parent.tempMatrix).getA().flatten()
411                 opengl.glDrawStringCenter("W, D, H: %0.1f, %0.1f, %0.1f mm" % (size[0], size[1], size[2]))
412                 glPopMatrix()
413
414                 glLineWidth(1)
415                 glBegin(GL_LINES)
416                 glColor3ub(128,0,0)
417                 glVertex3f(0, 0, 0)
418                 glVertex3f(sx, 0, 0)
419                 glColor3ub(0,128,0)
420                 glVertex3f(0, 0, 0)
421                 glVertex3f(0, sy, 0)
422                 glColor3ub(0,0,128)
423                 glVertex3f(0, 0, 0)
424                 glVertex3f(0, 0, sz)
425                 glEnd()
426
427                 glLineWidth(2)
428                 if self.node == 1:
429                         glColor3ub(255,255,255)
430                 else:
431                         glColor3ub(192,192,192)
432                 opengl.DrawBox([-s,-s,-s], [s,s,s])
433                 if self.node == 1:
434                         glColor3ub(0,0,0)
435                         opengl.glDrawStringCenter("%0.2f" % ((scaleX + scaleY + scaleZ) / 3.0))
436
437                 if self.node == 2:
438                         glColor3ub(255,64,64)
439                 else:
440                         glColor3ub(128,0,0)
441                 glPushMatrix()
442                 glTranslatef(sx,0,0)
443                 opengl.DrawBox([-s,-s,-s], [s,s,s])
444                 if self.node == 2:
445                         glColor3ub(0,0,0)
446                         opengl.glDrawStringCenter("%0.2f" % (scaleX))
447                 glPopMatrix()
448                 if self.node == 3:
449                         glColor3ub(64,255,64)
450                 else:
451                         glColor3ub(0,128,0)
452                 glPushMatrix()
453                 glTranslatef(0,sy,0)
454                 opengl.DrawBox([-s,-s,-s], [s,s,s])
455                 if self.node == 3:
456                         glColor3ub(0,0,0)
457                         opengl.glDrawStringCenter("%0.2f" % (scaleY))
458                 glPopMatrix()
459                 if self.node == 4:
460                         glColor3ub(64,64,255)
461                 else:
462                         glColor3ub(0,0,128)
463                 glPushMatrix()
464                 glTranslatef(0,0,sz)
465                 opengl.DrawBox([-s,-s,-s], [s,s,s])
466                 if self.node == 4:
467                         glColor3ub(0,0,0)
468                         opengl.glDrawStringCenter("%0.2f" % (scaleZ))
469                 glPopMatrix()
470
471                 glEnable(GL_DEPTH_TEST)
472                 glColor(255,255,255)
473                 size = size / 2
474                 size += 0.01
475                 glLineWidth(1)
476                 glBegin(GL_LINES)
477                 glVertex3f(size[0], size[1], size[2])
478                 glVertex3f(size[0], size[1], size[2]/4*3)
479                 glVertex3f(size[0], size[1], size[2])
480                 glVertex3f(size[0], size[1]/4*3, size[2])
481                 glVertex3f(size[0], size[1], size[2])
482                 glVertex3f(size[0]/4*3, size[1], size[2])
483
484                 glVertex3f(-size[0], size[1], size[2])
485                 glVertex3f(-size[0], size[1], size[2]/4*3)
486                 glVertex3f(-size[0], size[1], size[2])
487                 glVertex3f(-size[0], size[1]/4*3, size[2])
488                 glVertex3f(-size[0], size[1], size[2])
489                 glVertex3f(-size[0]/4*3, size[1], size[2])
490
491                 glVertex3f(size[0], -size[1], size[2])
492                 glVertex3f(size[0], -size[1], size[2]/4*3)
493                 glVertex3f(size[0], -size[1], size[2])
494                 glVertex3f(size[0], -size[1]/4*3, size[2])
495                 glVertex3f(size[0], -size[1], size[2])
496                 glVertex3f(size[0]/4*3, -size[1], size[2])
497
498                 glVertex3f(-size[0], -size[1], size[2])
499                 glVertex3f(-size[0], -size[1], size[2]/4*3)
500                 glVertex3f(-size[0], -size[1], size[2])
501                 glVertex3f(-size[0], -size[1]/4*3, size[2])
502                 glVertex3f(-size[0], -size[1], size[2])
503                 glVertex3f(-size[0]/4*3, -size[1], size[2])
504
505                 glVertex3f(size[0], size[1], -size[2])
506                 glVertex3f(size[0], size[1], -size[2]/4*3)
507                 glVertex3f(size[0], size[1], -size[2])
508                 glVertex3f(size[0], size[1]/4*3, -size[2])
509                 glVertex3f(size[0], size[1], -size[2])
510                 glVertex3f(size[0]/4*3, size[1], -size[2])
511
512                 glVertex3f(-size[0], size[1], -size[2])
513                 glVertex3f(-size[0], size[1], -size[2]/4*3)
514                 glVertex3f(-size[0], size[1], -size[2])
515                 glVertex3f(-size[0], size[1]/4*3, -size[2])
516                 glVertex3f(-size[0], size[1], -size[2])
517                 glVertex3f(-size[0]/4*3, size[1], -size[2])
518
519                 glVertex3f(size[0], -size[1], -size[2])
520                 glVertex3f(size[0], -size[1], -size[2]/4*3)
521                 glVertex3f(size[0], -size[1], -size[2])
522                 glVertex3f(size[0], -size[1]/4*3, -size[2])
523                 glVertex3f(size[0], -size[1], -size[2])
524                 glVertex3f(size[0]/4*3, -size[1], -size[2])
525
526                 glVertex3f(-size[0], -size[1], -size[2])
527                 glVertex3f(-size[0], -size[1], -size[2]/4*3)
528                 glVertex3f(-size[0], -size[1], -size[2])
529                 glVertex3f(-size[0], -size[1]/4*3, -size[2])
530                 glVertex3f(-size[0], -size[1], -size[2])
531                 glVertex3f(-size[0]/4*3, -size[1], -size[2])
532                 glEnd()
533
534                 glEnable(GL_DEPTH_TEST)