Author: JonNeal
Date: 2008-07-19 00:01:59 -0400 (Sat, 19 Jul 2008)
New Revision: 1339

Modified:
   trunk/pysoy/src/scenes/Scene.pym
Log:
Ticket #900:
  * Attempt at adding fog to the scene


Modified: trunk/pysoy/src/scenes/Scene.pym
===================================================================
--- trunk/pysoy/src/scenes/Scene.pym    2008-07-19 03:46:07 UTC (rev 1338)
+++ trunk/pysoy/src/scenes/Scene.pym    2008-07-19 04:01:59 UTC (rev 1339)
@@ -126,6 +126,12 @@
   cdef void _render(self, gl.GLdouble _fovy,  gl.GLdouble _aspect,
                           gl.GLdouble _znear, gl.GLdouble _zfar) :
     cdef int _i
+    cdef gl.GLfloat _density, _fogColor[4]
+    _density = .3
+    _fogColor[0] = .5
+    _fogColor[1] = .5
+    _fogColor[2] = .5
+    _fogColor[3] = 1.0
     #
     # Setup projection matrix
     gl.glMatrixMode(gl.GL_PROJECTION)
@@ -144,7 +150,16 @@
     for _i from 0 <= _i < self._lights._current :
       # This is a quick hack (gl.GL_LIGHT0 + _i)
       (<soy.bodies.Light> self._lights._list[_i])._on(gl.GL_LIGHT0 + _i)
+    
     #
+    # Turn on some fog!
+    gl.glFogi(gl.GL_FOG_MODE, gl.GL_EXP2)
+    gl.glFogfv(gl.GL_FOG_COLOR, _fogColor)
+    gl.glFogf(gl.GL_FOG_DENSITY, _density)
+    gl.glHint (gl.GL_FOG_HINT, gl.GL_NICEST)
+    gl.glEnable(gl.GL_FOG)
+    
+    #
     # Iterate over bodies
     self._bodies._iterStart()
     for _i from 0 <= _i < self._bodies._current :
@@ -153,6 +168,8 @@
          (<soy.bodies.Body> self._bodies._list[_i])._model)._render(
          (<soy.bodies.Body> self._bodies._list[_i]))
     self._bodies._iterDone()
+    gl.glDisable(gl.GL_FOG)
+    
     #
     # Turn off all lights and finish iteration loop
     for _i from 0 <= _i < self._lights._current :

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

Reply via email to