Changeset 1345
- Timestamp:
- 08/09/08 17:20:02 (4 months ago)
- Location:
- trunk/pysoy
- Files:
-
- 3 modified
-
include/soy.scenes.pxd (modified) (2 diffs)
-
src/scenes/Planar.pym (modified) (2 diffs)
-
src/scenes/Scene.pym (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pysoy/include/soy.scenes.pxd
r1340 r1345 68 68 cdef soy._internals.PointerSet _callFields 69 69 cdef soy.colors.Color _ambient 70 cdef float _fogDensity 70 71 cdef void* _stepMutex 71 72 cdef void _stepLock ( self ) nogil … … 98 99 cdef Vert* _vertArray 99 100 cdef gl.GLuint _vertBuffer 101 cdef Vert* _backArray 102 cdef gl.GLuint _backBuffer 100 103 cdef Quad* _faceArray 101 104 cdef gl.GLuint _faceBuffer -
trunk/pysoy/src/scenes/Planar.pym
r1317 r1345 129 129 return self._material 130 130 def __set__(self, value) : 131 if not isinstance(value, soy.materials.Material) :132 raise TypeError('Must provide an instance of soy.materials.Material')131 assert isinstance(value, soy.materials.Material), \ 132 "Must provide an instance of soy.materials.Material" 133 133 self._material = value 134 134 … … 151 151 def __set__(self, value) : 152 152 cdef ode.dVector3 _normal 153 if type(value) != list or type(value) != tuple :154 raise TypeError("A tuple or list must be provided.")153 assert type(value) == list and type(value) == tuple, \ 154 "A tuple or list must be provided." 155 155 _normal[0] = -(value[0]) 156 156 _normal[1] = -(value[1]) -
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)
