Author: ArcRiley Date: 2008-05-22 14:31:37 -0400 (Thu, 22 May 2008) New Revision: 1298
Modified: trunk/pysoy/include/soy.materials.pxd trunk/pysoy/src/materials/Animated.pym Log: Ticket #955 : * more work on animated material Modified: trunk/pysoy/include/soy.materials.pxd =================================================================== --- trunk/pysoy/include/soy.materials.pxd 2008-05-21 23:00:50 UTC (rev 1297) +++ trunk/pysoy/include/soy.materials.pxd 2008-05-22 18:31:37 UTC (rev 1298) @@ -41,3 +41,8 @@ cdef soy.textures.Texture _bumpmap cdef soy.textures.Texture _colormap cdef soy.textures.Texture _glowmap + +cdef class Animated (Material) : + cdef float _animateX + cdef float _animateY + cdef float _animateZ Modified: trunk/pysoy/src/materials/Animated.pym =================================================================== --- trunk/pysoy/src/materials/Animated.pym 2008-05-21 23:00:50 UTC (rev 1297) +++ trunk/pysoy/src/materials/Animated.pym 2008-05-22 18:31:37 UTC (rev 1298) @@ -57,21 +57,26 @@ # Properties # - property : - '''soy.materials.Animated. + property animate : + '''soy.materials.Animated.animate - Default is None (disabled). + Default is (0.0, 0.0, 0.0) (disabled). ''' def __get__(self) : - return self._colormap + return (self._animateX, self._animateY, self._animateZ) - def __set__(self, soy.textures.Texture _value) : - self._colormap = _value + def __set__(self, _value) : + if type(value) != tuple and type(value) != list : + raise TypeError('Must provide a tuple or list') + if len(value) != 3 : + raise TypeError('Must provide animation rate as (x,y,z)') def __del__(self) : - self._colormap = None + self._animateX = 0.0 + self._animateY = 0.0 + self._animateZ = 0.0 ############################################################################ @@ -80,13 +85,27 @@ # cdef int _render(self, int _pass, float* _texcoords, float* _tslvs) nogil : - cdef int _i, _bump, _unit + cdef int _i, _anim, _bump, _unit + cdef float _animX, _animY, _animZ + cdef double _t _unit = 0 ###################################### # - # time calc + # time to transform calc # - + _t = _time() + if self._animateX != 0.0 : + _anim = 1 + _animX = _t * self._animateX + _animX -= math.fabsf(_animX) + if self._animateY != 0.0 : + _anim = 1 + _animY = _t * self._animateY + _animY -= math.fabsf(_animY) + if self._animateZ != 0.0 : + _anim = 1 + _animZ = _t * self._animateZ + _animZ -= math.fabsf(_animZ) # ###################################### # @@ -131,10 +150,13 @@ # Texture0 - the dot3 normal map (bumpmap) # gl.glActiveTexture(gl.GL_TEXTURE0) + gl.glEnableClientState(gl.GL_TEXTURE_COORD_ARRAY) gl.glClientActiveTexture(gl.GL_TEXTURE0) - gl.glEnableClientState(gl.GL_TEXTURE_COORD_ARRAY) gl.glTexCoordPointer(3, gl.GL_FLOAT, 48, _texcoords) self._bumpmap._enable() + if _anim : + gl.glMatrixMode(gl.GL_TEXTURE) + gl.glTranslatef(_animX, _animY, _animZ) gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_COMBINE) gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_SOURCE0_RGB, gl.GL_TEXTURE) gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_COMBINE_RGB, gl.GL_REPLACE) @@ -253,3 +275,4 @@ return 0 # ###################################### + \ No newline at end of file _______________________________________________ PySoy-SVN mailing list PySoy-SVN@pysoy.org http://www.pysoy.org/mailman/listinfo/pysoy-svn