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