Show
Ignore:
Timestamp:
07/19/08 00:01:59 (5 months ago)
Author:
JonNeal
Message:

Ticket #900:

  • Attempt at adding fog to the scene
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pysoy/src/scenes/Scene.pym

    r1321 r1339  
    127127                          gl.GLdouble _znear, gl.GLdouble _zfar) : 
    128128    cdef int _i 
     129    cdef gl.GLfloat _density, _fogColor[4] 
     130    _density = .3 
     131    _fogColor[0] = .5 
     132    _fogColor[1] = .5 
     133    _fogColor[2] = .5 
     134    _fogColor[3] = 1.0 
    129135    # 
    130136    # Setup projection matrix 
     
    145151      # This is a quick hack (gl.GL_LIGHT0 + _i) 
    146152      (<soy.bodies.Light> self._lights._list[_i])._on(gl.GL_LIGHT0 + _i) 
     153     
     154    # 
     155    # Turn on some fog! 
     156    gl.glFogi(gl.GL_FOG_MODE, gl.GL_EXP2) 
     157    gl.glFogfv(gl.GL_FOG_COLOR, _fogColor) 
     158    gl.glFogf(gl.GL_FOG_DENSITY, _density) 
     159    gl.glHint (gl.GL_FOG_HINT, gl.GL_NICEST) 
     160    gl.glEnable(gl.GL_FOG) 
     161     
    147162    # 
    148163    # Iterate over bodies 
     
    154169         (<soy.bodies.Body> self._bodies._list[_i])) 
    155170    self._bodies._iterDone() 
     171    gl.glDisable(gl.GL_FOG) 
     172     
    156173    # 
    157174    # Turn off all lights and finish iteration loop