Changeset 1345 for trunk/pysoy/src/scenes/Scene.pym
- Timestamp:
- 08/09/08 17:20:02 (4 months ago)
- Files:
-
- 1 modified
-
trunk/pysoy/src/scenes/Scene.pym (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pysoy/src/scenes/Scene.pym
r1339 r1345 45 45 self._lights = soy._internals.Children() 46 46 self._ambient = gray 47 self._fogDensity = 0.0 47 48 self._stepSize = 0.01 48 49 self._friction = 0 … … 78 79 79 80 return '<Scene with %s>' % ', '.join(report) 81 82 ############################################################################ 83 # 84 # Properties 85 # 86 87 property fog : 88 '''Scene fog 89 90 This is a scene-wide layer of fog of which the density is set by you 91 92 Takes a float for fog density from 0-2, fog is disabled when at 0. 93 ''' 94 def __get__(self) : 95 return self._fogDensity 96 97 def __set__(self, value) : 98 assert type(value) == float and value <= 2 and value >= 0, \ 99 "Fog density must be a float in the range of 0-2." 100 self._fogDensity = value 80 101 81 102 ############################################################################ … … 127 148 gl.GLdouble _znear, gl.GLdouble _zfar) : 128 149 cdef int _i 129 cdef gl.GLfloat _density, _fogColor[4] 130 _density = .3 150 cdef gl.GLfloat _fogColor[4] 131 151 _fogColor[0] = .5 132 152 _fogColor[1] = .5 … … 145 165 gl.glEnable(gl.GL_LIGHTING) 146 166 gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, self._ambient._rgba) 167 168 if self._fogDensity > 0 : 169 # 170 # Turn on some fog! 171 gl.glClearColor(0.5,0.5,0.5,1.0) # We'll Clear To The Color Of The Fog ( Modified ) 172 gl.glEnable(gl.GL_FOG) #Enables GL_FOG 173 gl.glFogi(gl.GL_FOG_MODE, gl.GL_EXP2) #Fog Mode 174 gl.glFogfv(gl.GL_FOG_COLOR, _fogColor) #Set Fog Color 175 gl.glFogf(gl.GL_FOG_DENSITY, self._fogDensity/10) #How Dense Will The Fog Be 176 gl.glHint(gl.GL_FOG_HINT, gl.GL_NICEST) #Fog Hint Value 177 gl.glFogf(gl.GL_FOG_START, 1.0) #Fog Start Depth 178 gl.glFogf(gl.GL_FOG_END, 50.0) #Fog End Depth 179 147 180 # 148 181 # Turn on each light, keep it's iteration locked against mod until done … … 151 184 # This is a quick hack (gl.GL_LIGHT0 + _i) 152 185 (<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) 186 187 161 188 162 189 # … … 169 196 (<soy.bodies.Body> self._bodies._list[_i])) 170 197 self._bodies._iterDone() 171 gl.glDisable(gl.GL_FOG)172 198 173 199 # … … 177 203 (<soy.bodies.Light> self._lights._list[_i])._off(gl.GL_LIGHT0 + _i) 178 204 self._lights._iterDone() 205 206 if self._fogDensity > 0 : 207 gl.glDisable(gl.GL_FOG) 179 208 gl.glDisable(gl.GL_LIGHTING) 180 209 gl.glDisable(gl.GL_DEPTH_TEST)
