Commit 282c6af4 authored by sumpfralle's avatar sumpfralle

position the light in relation to the current bounding box


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@164 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 871db41b
......@@ -144,8 +144,17 @@ class Camera:
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glLoadIdentity()
v = self.view
# position the light according to the current bounding box
light_pos = range(3)
light_pos[0] = 2 * self.settings.get("maxx") - self.settings.get("minx")
light_pos[1] = 2 * self.settings.get("maxy") - self.settings.get("miny")
light_pos[2] = 2 * self.settings.get("maxz") - self.settings.get("minz")
GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, (light_pos[0], light_pos[1], light_pos[2], 1.0))
# position the camera
camera_position = (v["center"][0] + v["distance"][0],
v["center"][1] + v["distance"][1], v["center"][2] + v["distance"][2])
GLU.gluPerspective(v["fovy"], (0.0 + width) / height, v["znear"], v["zfar"])
GLU.gluLookAt(v["center"][0] + v["distance"][0], v["center"][1] + v["distance"][1], v["center"][2] + v["distance"][2],
GLU.gluLookAt(camera_position[0], camera_position[1], camera_position[2],
v["center"][0], v["center"][1], v["center"][2], v["up"][0], v["up"][1], v["up"][2])
GL.glMatrixMode(prev_mode)
......
#!/usr/bin/env python
import OpenGL.GL as GL
import OpenGL.GLU as GLU
import OpenGL.GLUT as GLUT
import pycam.Importers.STLImporter
import pycam.Exporters.STLExporter
import pycam.Exporters.SimpleGCodeExporter
......@@ -13,12 +10,16 @@ import pycam.PathGenerators
import pycam.PathProcessors
import pycam.Geometry.utils as utils
import pycam.Gui.OpenGLTools as ogl_tools
import threading
import OpenGL.GL as GL
import OpenGL.GLU as GLU
import OpenGL.GLUT as GLUT
# gtk.gtkgl is imported in the constructor of "GLView" below
#import gtk.gtkgl
import pygtk
import gtk
import time
import os
import sys
import time
GTKBUILD_FILE = os.path.join(os.path.dirname(__file__), "gtk-interface", "pycam-project.ui")
......@@ -141,10 +142,9 @@ class GLView:
GL.glLoadIdentity()
GL.glViewport(0, 0, self.area.allocation.width, self.area.allocation.height)
# lightning
GL.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, (0., 0., 0., 1.)) # Setup The Ambient Light
GL.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, (0.3, 0.3, 0.3, 3.)) # Setup The Ambient Light
GL.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, (1., 1., 1., .0)) # Setup The Diffuse Light
GL.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, (.2, .2, .2, 1.0)) # Setup The SpecularLight
GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, (3., -1., 3., 1.)) # Position The Light
GL.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, (.3, .3, .3, 1.0)) # Setup The SpecularLight
GL.glEnable(GL.GL_LIGHT0)
# Enable Light One
GL.glEnable(GL.GL_LIGHTING)
......
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