Author: ArcRiley
Date: 2007-06-22 17:11:58 -0400 (Fri, 22 Jun 2007)
New Revision: 250

Modified:
   trunk/pysoy/src/bodies._bodies/soy.bodies._bodies.pyx
   trunk/pysoy/src/colors/Color.pxi
   trunk/pysoy/src/materials/Material.pxi
   trunk/pysoy/src/materials/soy.materials.pxd
Log:
more work on material/light model


Modified: trunk/pysoy/src/bodies._bodies/soy.bodies._bodies.pyx
===================================================================
--- trunk/pysoy/src/bodies._bodies/soy.bodies._bodies.pyx       2007-06-22 
21:11:40 UTC (rev 249)
+++ trunk/pysoy/src/bodies._bodies/soy.bodies._bodies.pyx       2007-06-22 
21:11:58 UTC (rev 250)
@@ -28,5 +28,4 @@
 
 include "Body.pxi"
 include "Camera.pxi"
-include "Light.pxi"      
 include "Mesh.pxi"

Modified: trunk/pysoy/src/colors/Color.pxi
===================================================================
--- trunk/pysoy/src/colors/Color.pxi    2007-06-22 21:11:40 UTC (rev 249)
+++ trunk/pysoy/src/colors/Color.pxi    2007-06-22 21:11:58 UTC (rev 250)
@@ -48,19 +48,19 @@
         val = value
       vlen = len(val)
       if vlen == 0 :
-        val = '00000000'
+        val = 'ff000000'
       elif vlen == 1 :
         val = val * 8
       elif vlen == 2 :
         val = val * 4
       elif vlen == 3 :
-        val = '00' + val[0]*2 + val[1]*2 + val[2]*2
+        val = 'ff' + val[0]*2 + val[1]*2 + val[2]*2
       elif vlen == 4 :
         val = val[0]*2 + val[1]*2 + val[2]*2 + val[3]*2
       elif vlen == 5 :
         val = val[0:2] + val[2]*2 + val[3]*2 + val[4]*2
       elif vlen == 6 :
-        val = '00' + val
+        val = 'ff' + val
       elif vlen == 7 :
         val = val[0]*2 + val[1:]
       elif vlen > 8 :

Modified: trunk/pysoy/src/materials/Material.pxi
===================================================================
--- trunk/pysoy/src/materials/Material.pxi      2007-06-22 21:11:40 UTC (rev 
249)
+++ trunk/pysoy/src/materials/Material.pxi      2007-06-22 21:11:58 UTC (rev 
250)
@@ -29,17 +29,22 @@
 
      shared material for many visible objects
   '''
-  def __new__(self, color=None) :
+  def __new__(self, color=None, specular=None) :
+    import soy.colors
     if color :
       self._color = color
     else :
       self._color = soy.colors.White()
+    self._shininess = .5
+    if specular :
+      self._specular = specular
+    else :
+      self._specular = soy.colors.White()
 
   def __repr__(self) :
     return '<Material>'
 
   cdef void _render(self) :
-    #cdef float rgba
     if self._colorTex :
       #gl.glBindTexture(<soy.textures.Texture>self._color._textureTarget,
       #                 <soy.textures.Texture>self._color._textureID)
@@ -49,7 +54,15 @@
       #stdio.printf('%f %f %f %f\n', rgba[0], rgba[1], rgba[2], rgba[3])
       gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT_AND_DIFFUSE, 
                       (<soy.colors.Color> self._color)._getRGBA())
+    if self._shades == 0 :
+      gl.glShadeModel(gl.GL_SMOOTH)
+    else :
+      gl.glShadeModel(gl.GL_FLAT)
+    gl.glMaterialf (gl.GL_FRONT, gl.GL_SHININESS, self._shininess)    
+    gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR,
+                    (<soy.colors.Color> self._specular)._getRGBA())
 
+
   property color :
     def __get__(self) :
       return self._color
@@ -65,3 +78,45 @@
     def __del__(self) :
       self._color=soy.colors.White()
       self._colorTex=0
+
+  property shades :
+    '''Number of Shades
+
+    This property detirmines how many "shades" a face may have:
+      0 == "smooth"
+      1 == "flat"
+
+    In the future 2+ will may be permitted for cartoon shading effects.
+    '''
+    def __get__(self) :
+      return self._shades
+    def __set__(self, int value) :
+      if value<1 or value>1 :
+        self._shades = 0
+      else :
+        self._shades = value
+    def __del__(self) :
+      self._shades = 0
+
+  property shininess :
+    '''Shininess
+
+    This property is how large the specular "dot" is between 0.0 and 1.0
+    '''
+    def __get__(self) :
+      return self._shininess
+    def __set__(self, float value) :
+      self._shininess = value
+    def __del__(self) :        
+      self._shininess = 0.0
+    
+  property specular :
+    def __get__(self) :
+      return self._specular
+    def __set__(self, val) :
+      if isinstance(val, soy.colors.Color) :
+        self._specular=val
+      else :
+        raise TypeError('must be a soy.color')
+    def __del__(self) :
+      self._specular=soy.colors.White()

Modified: trunk/pysoy/src/materials/soy.materials.pxd
===================================================================
--- trunk/pysoy/src/materials/soy.materials.pxd 2007-06-22 21:11:40 UTC (rev 
249)
+++ trunk/pysoy/src/materials/soy.materials.pxd 2007-06-22 21:11:58 UTC (rev 
250)
@@ -24,4 +24,7 @@
 cdef class Material :
   cdef object _color
   cdef int    _colorTex
+  cdef int    _shades
+  cdef float  _shininess
+  cdef object _specular
   cdef void   _render(self)

_______________________________________________
PySoy-SVN mailing list
PySoy-SVN@pysoy.org
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to