Commit cfe998a6 authored by Guillaume Seguin's avatar Guillaume Seguin

Improve drawing of cursor in stlview

parent 81127b31
...@@ -161,7 +161,7 @@ class wxGLPanel(wx.Panel): ...@@ -161,7 +161,7 @@ class wxGLPanel(wx.Panel):
#========================================================================== #==========================================================================
# Utils # Utils
#========================================================================== #==========================================================================
def mouse_to_3d(self, x, y): def mouse_to_3d(self, x, y, z = 1.0):
x = float(x) x = float(x)
y = self.height - float(y) y = self.height - float(y)
# The following could work if we were not initially scaling to zoom on the bed # The following could work if we were not initially scaling to zoom on the bed
...@@ -176,7 +176,7 @@ class wxGLPanel(wx.Panel): ...@@ -176,7 +176,7 @@ class wxGLPanel(wx.Panel):
glGetIntegerv(GL_VIEWPORT, viewport); glGetIntegerv(GL_VIEWPORT, viewport);
glGetDoublev(GL_PROJECTION_MATRIX, pmat) glGetDoublev(GL_PROJECTION_MATRIX, pmat)
glGetDoublev(GL_MODELVIEW_MATRIX, mvmat) glGetDoublev(GL_MODELVIEW_MATRIX, mvmat)
gluUnProject(x, y, 1.0, mvmat, pmat, viewport, px, py, pz) gluUnProject(x, y, z, mvmat, pmat, viewport, px, py, pz)
return (px.value, py.value, pz.value) return (px.value, py.value, pz.value)
def zoom(self, factor, to = None): def zoom(self, factor, to = None):
......
...@@ -342,8 +342,8 @@ class StlViewPanel(wxGLPanel): ...@@ -342,8 +342,8 @@ class StlViewPanel(wxGLPanel):
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
# Draw mouse # Draw mouse
glPushMatrix() glPushMatrix()
x, y, _ = self.mouse_to_3d(*self.mousepos) x, y, z = self.mouse_to_3d(self.mousepos[0], self.mousepos[1], 0.9)
glTranslatef(x, y, 5) glTranslatef(x, y, z)
glBegin(GL_TRIANGLES) glBegin(GL_TRIANGLES)
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, vec(1, 0, 0, 1)) glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, vec(1, 0, 0, 1))
glNormal3f(0, 0, 1) glNormal3f(0, 0, 1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment