Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
5684c83e
Commit
5684c83e
authored
Mar 30, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move lighting to panel to create lights at a fixed position
parent
f5a722d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
24 deletions
+25
-24
actors.py
printrun/gl/libtatlin/actors.py
+2
-24
panel.py
printrun/gl/panel.py
+23
-0
No files found.
printrun/gl/libtatlin/actors.py
View file @
5684c83e
...
...
@@ -517,30 +517,10 @@ class GcodeModel(Model):
glTranslatef
(
self
.
offset_x
,
self
.
offset_y
,
0
)
glEnableClientState
(
GL_VERTEX_ARRAY
)
glDisable
(
GL_LIGHTING
)
glEnable
(
GL_RESCALE_NORMAL
)
glShadeModel
(
GL_SMOOTH
)
glEnable
(
GL_LIGHTING
)
glEnable
(
GL_LIGHT0
)
glLightModeli
(
GL_LIGHT_MODEL_LOCAL_VIEWER
,
1
)
glLightfv
(
GL_LIGHT0
,
GL_AMBIENT
,
vec
(
0.2
,
0.2
,
0.2
,
1.0
))
glLightfv
(
GL_LIGHT0
,
GL_SPECULAR
,
vec
(
0
,
0
,
0
,
0
))
glLightfv
(
GL_LIGHT0
,
GL_DIFFUSE
,
vec
(
0
,
0
,
0
,
0
))
glEnable
(
GL_LIGHT1
)
glLightfv
(
GL_LIGHT1
,
GL_AMBIENT
,
vec
(
0
,
0
,
0
,
1.0
))
glLightfv
(
GL_LIGHT1
,
GL_SPECULAR
,
vec
(
1.
,
1.
,
1.
,
1.
))
glLightfv
(
GL_LIGHT1
,
GL_DIFFUSE
,
vec
(
0.72
,
0.72
,
0.72
,
1
))
glLightfv
(
GL_LIGHT1
,
GL_POSITION
,
vec
(
1
,
2
,
3
,
0
))
glLightfv
(
GL_LIGHT1
,
GL_SPOT_EXPONENT
,
vec
(
1.
,
1.
,
1.
,
1.
))
glEnable
(
GL_LIGHT2
)
glLightfv
(
GL_LIGHT2
,
GL_AMBIENT
,
vec
(
0
,
0
,
0
,
1.0
))
glLightfv
(
GL_LIGHT2
,
GL_SPECULAR
,
vec
(
1.
,
1.
,
1.
,
1.
))
glLightfv
(
GL_LIGHT2
,
GL_DIFFUSE
,
vec
(
0.8
,
0.8
,
0.8
,
1
))
glLightfv
(
GL_LIGHT2
,
GL_POSITION
,
vec
(
-
1
,
-
1
,
2
,
0
))
has_vbo
=
isinstance
(
self
.
vertex_buffer
,
VertexBufferObject
)
self
.
_display_travels
(
has_vbo
)
glEnable
(
GL_LIGHTING
)
glEnableClientState
(
GL_COLOR_ARRAY
)
glMaterialfv
(
GL_FRONT
,
GL_SPECULAR
,
vec
(
1
,
1
,
1
,
1
))
glMaterialfv
(
GL_FRONT_AND_BACK
,
GL_EMISSION
,
vec
(
0
,
0
,
0
,
0
))
...
...
@@ -549,10 +529,8 @@ class GcodeModel(Model):
glColorMaterial
(
GL_FRONT_AND_BACK
,
GL_AMBIENT_AND_DIFFUSE
)
self
.
_display_movements
(
has_vbo
)
glDisable
(
GL_LIGHT0
)
glDisable
(
GL_LIGHT1
)
glDisable
(
GL_LIGHT2
)
glDisable
(
GL_LIGHTING
)
glDisableClientState
(
GL_COLOR_ARRAY
)
glDisableClientState
(
GL_VERTEX_ARRAY
)
...
...
printrun/gl/panel.py
View file @
5684c83e
...
...
@@ -26,6 +26,7 @@ pyglet.options['debug_gl'] = True
from
pyglet.gl
import
*
from
pyglet
import
gl
from
.trackball
import
trackball
,
mulquat
,
build_rotmatrix
from
.libtatlin.actors
import
vec
class
wxGLPanel
(
wx
.
Panel
):
'''A simple class for using OpenGL with wxPython.'''
...
...
@@ -153,9 +154,31 @@ class wxGLPanel(wx.Panel):
self
.
pygletcontext
.
set_current
()
self
.
update_object_resize
()
def
setup_lights
(
self
):
glEnable
(
GL_LIGHTING
)
glEnable
(
GL_LIGHT0
)
glLightModeli
(
GL_LIGHT_MODEL_LOCAL_VIEWER
,
1
)
glLightfv
(
GL_LIGHT0
,
GL_AMBIENT
,
vec
(
0.2
,
0.2
,
0.2
,
1.0
))
glLightfv
(
GL_LIGHT0
,
GL_SPECULAR
,
vec
(
0
,
0
,
0
,
0
))
glLightfv
(
GL_LIGHT0
,
GL_DIFFUSE
,
vec
(
0
,
0
,
0
,
0
))
glEnable
(
GL_LIGHT1
)
glLightfv
(
GL_LIGHT1
,
GL_AMBIENT
,
vec
(
0
,
0
,
0
,
1.0
))
glLightfv
(
GL_LIGHT1
,
GL_SPECULAR
,
vec
(
1.
,
1.
,
1.
,
1.
))
glLightfv
(
GL_LIGHT1
,
GL_DIFFUSE
,
vec
(
0.72
,
0.72
,
0.72
,
1
))
glLightfv
(
GL_LIGHT1
,
GL_POSITION
,
vec
(
1
,
2
,
3
,
0
))
glLightfv
(
GL_LIGHT1
,
GL_SPOT_EXPONENT
,
vec
(
1.
,
1.
,
1.
,
1.
))
glEnable
(
GL_LIGHT2
)
glLightfv
(
GL_LIGHT2
,
GL_AMBIENT
,
vec
(
0
,
0
,
0
,
1.0
))
glLightfv
(
GL_LIGHT2
,
GL_SPECULAR
,
vec
(
1.
,
1.
,
1.
,
1.
))
glLightfv
(
GL_LIGHT2
,
GL_DIFFUSE
,
vec
(
0.8
,
0.8
,
0.8
,
1
))
glLightfv
(
GL_LIGHT2
,
GL_POSITION
,
vec
(
-
1
,
-
1
,
2
,
0
))
glEnable
(
GL_RESCALE_NORMAL
)
glShadeModel
(
GL_SMOOTH
)
def
reset_mview
(
self
,
factor
):
glMatrixMode
(
GL_MODELVIEW
)
glLoadIdentity
()
self
.
setup_lights
()
if
self
.
orthographic
:
ratio
=
factor
*
float
(
min
(
self
.
width
,
self
.
height
))
/
self
.
dist
self
.
zoom_factor
=
1.0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment