More slices in glutSolidSphere + enabled LIGHT0
authorDmitriy Morozov <dmitriy@mrzv.org>
Wed, 27 Jul 2011 14:00:04 -0700
changeset 21 063f99363534
parent 20 0b7b52941b22
child 22 d4f4fe389914
More slices in glutSolidSphere + enabled LIGHT0
PyVEFViewer.py
spheres.py
--- a/PyVEFViewer.py	Wed Jul 27 13:41:40 2011 -0700
+++ b/PyVEFViewer.py	Wed Jul 27 14:00:04 2011 -0700
@@ -9,6 +9,7 @@
 from    spheres         import Spheres
 import  povray
 
+from qgllogo import *
 
 class VEFViewer(QGLViewer):
     def __init__(self, parent = None):
@@ -62,22 +63,35 @@
 
     def init(self):
         # Light setup
-        ogl.glDisable(ogl.GL_LIGHT0);
-        ogl.glEnable(ogl.GL_LIGHT1);
+        #ogl.glDisable(ogl.GL_LIGHT0);
+        #ogl.glEnable(ogl.GL_LIGHT1);
 
         # Light default parameters
-        light_ambient  = [1.0, 1.0, 1.0, 1.0]
-        light_specular = [1.0, 1.0, 1.0, 1.0]
-        light_diffuse  = [1.0, 1.0, 1.0, 1.0]
+        #light_ambient  = [.3, .3, .3, .3]
+        #light_specular = [.3, .3, .3, .3]
+        #light_diffuse  = [.3, .3, .3, .3]
+
+        #ogl.glLightf( ogl.GL_LIGHT1, ogl.GL_SPOT_EXPONENT, 3.0)
+        #ogl.glLightf( ogl.GL_LIGHT1, ogl.GL_SPOT_CUTOFF,   50.0)
+        #ogl.glLightf( ogl.GL_LIGHT1, ogl.GL_CONSTANT_ATTENUATION,  0.1)
+        #ogl.glLightf( ogl.GL_LIGHT1, ogl.GL_LINEAR_ATTENUATION,    0.3)
+        #ogl.glLightf( ogl.GL_LIGHT1, ogl.GL_QUADRATIC_ATTENUATION, 0.3)
+        #ogl.glLightfv(ogl.GL_LIGHT1, ogl.GL_AMBIENT,  light_ambient)
+        #ogl.glLightfv(ogl.GL_LIGHT1, ogl.GL_SPECULAR, light_specular)
+        #ogl.glLightfv(ogl.GL_LIGHT1, ogl.GL_DIFFUSE,  light_diffuse)
 
-        ogl.glLightf( ogl.GL_LIGHT1, ogl.GL_SPOT_EXPONENT, 3.0)
-        ogl.glLightf( ogl.GL_LIGHT1, ogl.GL_SPOT_CUTOFF,   10.0)
-        ogl.glLightf( ogl.GL_LIGHT1, ogl.GL_CONSTANT_ATTENUATION,  0.1)
-        ogl.glLightf( ogl.GL_LIGHT1, ogl.GL_LINEAR_ATTENUATION,    0.3)
-        ogl.glLightf( ogl.GL_LIGHT1, ogl.GL_QUADRATIC_ATTENUATION, 0.3)
-        ogl.glLightfv(ogl.GL_LIGHT1, ogl.GL_AMBIENT,  light_ambient)
-        ogl.glLightfv(ogl.GL_LIGHT1, ogl.GL_SPECULAR, light_specular)
-        ogl.glLightfv(ogl.GL_LIGHT1, ogl.GL_DIFFUSE,  light_diffuse)
+        mat_specular = [1.0, 1.0, 1.0, 1.0]
+        mat_shininess = [50.0]
+        light_position = [1.0, 1.0, 1.0, 0.0]
+        ogl.glShadeModel (ogl.GL_SMOOTH)
+
+        ogl.glMaterialfv(ogl.GL_FRONT, ogl.GL_SPECULAR, mat_specular)
+        ogl.glMaterialfv(ogl.GL_FRONT, ogl.GL_SHININESS, mat_shininess)
+        ogl.glLightfv(ogl.GL_LIGHT0, ogl.GL_POSITION, light_position)
+
+        #ogl.glEnable(ogl.GL_LIGHTING)
+        ogl.glEnable(ogl.GL_LIGHT0)
+        ogl.glEnable(ogl.GL_DEPTH_TEST)
 
 
     #def helpString(self):
--- a/spheres.py	Wed Jul 27 13:41:40 2011 -0700
+++ b/spheres.py	Wed Jul 27 14:00:04 2011 -0700
@@ -52,7 +52,7 @@
             if wireframe:
                 glutWireSphere(r, 20, 20)
             else:
-                glutSolidSphere(r, 20, 20)
+                glutSolidSphere(r, 50, 50)
             glTranslatef(-c.x,-c.y,-c.z)
 
     def draw(self):