Author: ArcRiley Date: 2008-05-19 15:40:00 -0400 (Mon, 19 May 2008) New Revision: 1275
Added: trunk/pysoy/src/materials/Material.pym trunk/pysoy/src/materials/_postinit.pym Removed: trunk/pysoy/src/materials/A.pxi trunk/pysoy/src/materials/B.pxi trunk/pysoy/src/materials/C.pxi trunk/pysoy/src/materials/D.pxi trunk/pysoy/src/materials/Material.pxi trunk/pysoy/src/materials/P.pxi trunk/pysoy/src/materials/R.pxi trunk/pysoy/src/materials/S.pxi trunk/pysoy/src/materials/V.pxi Modified: trunk/pysoy/examples/CollideBlocks.py trunk/pysoy/src/materials/__init__.pym trunk/pysoy/src/materials/soy.materials.pyx Log: '''General cleanup''' : * default materials are now reusable instances, not classes * renamed Material.pxi to Material.pym * updated CollideBlocks.py - have not updated other examples Modified: trunk/pysoy/examples/CollideBlocks.py =================================================================== --- trunk/pysoy/examples/CollideBlocks.py 2008-05-19 18:32:51 UTC (rev 1274) +++ trunk/pysoy/examples/CollideBlocks.py 2008-05-19 19:40:00 UTC (rev 1275) @@ -15,14 +15,14 @@ black.specular= soy.colors.Color('#222') black.shininess = 5.0 colors = { - 'Aventurine' : (soy.materials.Aventurine(), black, ( 0, 0, 0)), - 'Basalt' : (soy.materials.Basalt(), black, ( 4,-1,-4)), - 'Copper' : (soy.materials.Copper(), black, (-3,-2,-2)), - 'CopperSulfate' : (soy.materials.CopperSulfate(), black, ( 0,-2,-1)), - 'DarkWood' : (soy.materials.DarkWood(), black, ( 5, 3,-6)), - 'Pearl' : (soy.materials.Pearl(), black, (-1, 2,-3)), - 'Rhodonite' : (soy.materials.Rhodonite(), black, (-4, 1,-5)), - 'VelvetyRed' : (soy.materials.VelvetyRed(), black, ( 3, 0,-8)), + 'Aventurine' : (soy.materials.aventurine, black, ( 0, 0, 0)), + 'Basalt' : (soy.materials.basalt, black, ( 4,-1,-4)), + 'Copper' : (soy.materials.copper, black, (-3,-2,-2)), + 'CopperSulfate' : (soy.materials.copperSulfate, black, ( 0,-2,-1)), + 'DarkWood' : (soy.materials.darkWood, black, ( 5, 3,-6)), + 'Pearl' : (soy.materials.pearl, black, (-1, 2,-3)), + 'Rhodonite' : (soy.materials.rhodonite, black, (-4, 1,-5)), + 'VelvetyRed' : (soy.materials.velvetyRed, black, ( 3, 0,-8)), } bks = blocks.blocks(sce, colors) Deleted: trunk/pysoy/src/materials/A.pxi =================================================================== --- trunk/pysoy/src/materials/A.pxi 2008-05-19 18:32:51 UTC (rev 1274) +++ trunk/pysoy/src/materials/A.pxi 2008-05-19 19:40:00 UTC (rev 1275) @@ -1,30 +0,0 @@ -# PySoy materials.A* classes -# -# Copyright (C) 2006,2007,2008 PySoy Group -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program; if not, see http://www.gnu.org/licenses -# -# $Id$ - -cdef class Aventurine (Material) : - '''PySoy material.Aventurine - - This default material is intended to look like green aventurine - ''' - def __init__(self) : - import soy.colors - self.ambient = soy.colors.aventurine - self.diffuse = soy.colors.aventurine - self.specular = soy.colors.teal - self.shininess = 10 Deleted: trunk/pysoy/src/materials/B.pxi =================================================================== --- trunk/pysoy/src/materials/B.pxi 2008-05-19 18:32:51 UTC (rev 1274) +++ trunk/pysoy/src/materials/B.pxi 2008-05-19 19:40:00 UTC (rev 1275) @@ -1,30 +0,0 @@ -# PySoy materials.B* classes -# -# Copyright (C) 2006,2007,2008 PySoy Group -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program; if not, see http://www.gnu.org/licenses -# -# $Id$ - -cdef class Basalt (Material) : - '''Pysoy materials.Basalt - - This default material is intended to look like the igneous rock - basalt - ''' - def __init__(self) : - import soy.colors - self.ambient = soy.colors.basalt - self.diffuse = soy.colors.basalt - self.specular = soy.colors.basalt - self.shininess = 4 Deleted: trunk/pysoy/src/materials/C.pxi =================================================================== --- trunk/pysoy/src/materials/C.pxi 2008-05-19 18:32:51 UTC (rev 1274) +++ trunk/pysoy/src/materials/C.pxi 2008-05-19 19:40:00 UTC (rev 1275) @@ -1,43 +0,0 @@ -# PySoy materials.C* classes -# -# Copyright (C) 2006,2007,2008 PySoy Group -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program; if not, see http://www.gnu.org/licenses -# -# $Id$ - -cdef class Copper (Material) : - '''Pysoy materials.Copper - - This default material is intended to look like copper - ''' - def __init__(self) : - import soy.colors - self.ambient = soy.colors.copper - self.diffuse = soy.colors.copper - self.specular = soy.colors.yellow - self.shininess = 5 - - -cdef class CopperSulfate (Material) : - '''Pysoy materials.CopperSulfate - - This default material is intended to look like the crystal of Copper(II) Sulfate - ''' - def __init__(self) : - import soy.colors - self.ambient = soy.colors.copperSulfate - self.diffuse = soy.colors.copperSulfate - self.specular = soy.colors.veryLightBlueGreen - self.shininess = 10 Deleted: trunk/pysoy/src/materials/D.pxi =================================================================== --- trunk/pysoy/src/materials/D.pxi 2008-05-19 18:32:51 UTC (rev 1274) +++ trunk/pysoy/src/materials/D.pxi 2008-05-19 19:40:00 UTC (rev 1275) @@ -1,30 +0,0 @@ -# PySoy materials.D* classes -# -# Copyright (C) 2006,2007,2008 PySoy Group -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program; if not, see http://www.gnu.org/licenses -# -# $Id$ - -cdef class DarkWood (Material) : - '''Pysoy materials.DarkWood - - This default material is intended to look like dark wood - ''' - def __init__(self) : - import soy.colors - self.ambient = soy.colors.darkWood - self.diffuse = soy.colors.darkWood - self.specular = soy.colors.darkWood - self.shininess = 0 Deleted: trunk/pysoy/src/materials/Material.pxi =================================================================== --- trunk/pysoy/src/materials/Material.pxi 2008-05-19 18:32:51 UTC (rev 1274) +++ trunk/pysoy/src/materials/Material.pxi 2008-05-19 19:40:00 UTC (rev 1275) @@ -1,307 +0,0 @@ -# PySoy's materials.Material class -# -# Copyright (C) 2006,2007,2008 PySoy Group -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program; if not, see http://www.gnu.org/licenses -# -# $Id$ - -cdef class Material : - '''PySoy Material - - shared material for many visible objects - ''' - - ############################################################################ - # - # Python functions - # - - def __cinit__(self, color=None, ambient=None, diffuse=None, specular=None, - shininess=0.5, - normal=None, normalisation_cube_map=None) : - import soy.colors - if color : - self._color = color - else : - self._color = None - - if normal : - self._normal = normal - else : - self._normal = None - - if ambient : - self._ambient = ambient - else : - self._ambient = soy.colors.white - - if diffuse : - self._diffuse = diffuse - else : - self._diffuse = soy.colors.white - - if specular : - self._specular = specular - else : - self._specular = soy.colors.white - - self._shininess = shininess - - self._blend_func_src = gl.GL_SRC_ALPHA - self._blend_func_dst = gl.GL_ONE_MINUS_SRC_ALPHA - self._shadeless = 0 - - self._emissive = soy.colors.black - - - def __repr__(self) : - return '<Material>' - - - ############################################################################ - # - # Properties - # - - property color : - def __get__(self) : - return self._color - - def __set__(self, soy.textures.Texture value) : - self._color = value - - def __del__(self) : - self._color = None - - - property normal: - def __get__(self): - return self._normal - - def __set__(self, soy.textures.Texture val): - self._normal = val - - def __del__(self): - self._normal = None - - - property ambient : - def __get__(self) : - return self._ambient - - def __set__(self, soy.colors.Color value) : - self._ambient = value - - def __del__(self) : - self._ambient = soy.colors.gray - - - property diffuse : - def __get__(self) : - return self._diffuse - - def __set__(self, soy.colors.Color value) : - self._diffuse = value - - def __del__(self) : - self._diffuse = soy.colors.white - - - property shades : - '''Number of Shades - - This property detirmines how many "shades" a face may have: - 0 == "smooth" - 1 == "flat" - - In the future 2+ will may be permitted for cartoon shading effects. - ''' - def __get__(self) : - return self._shades - - def __set__(self, int value) : - if value<1 or value>1 : - self._shades = 0 - else : - self._shades = value - - def __del__(self) : - self._shades = 0 - - - property shininess : - '''Shininess - - This property is how large the specular "dot" is between 0.0 and 1.0 - ''' - def __get__(self) : - return self._shininess - - def __set__(self, float value) : - self._shininess = value - - def __del__(self) : - self._shininess = 0.0 - - - property specular : - def __get__(self) : - return self._specular - - def __set__(self, val) : - if isinstance(val, soy.colors.Color) : - self._specular=val - else : - raise TypeError('must be a soy.color') - - def __del__(self) : - self._specular=soy.colors.white - - - property emissive : - def __get__(self) : - return self._emissive - - def __set__(self, val) : - if isinstance(val, soy.colors.Color) : - self._emissive=val - else : - raise TypeError('must be a soy.color') - - def __del__(self) : - self._emissive=soy.colors.black - - - property blend_func_src: - def __get__(self): - return self._blend_func_src - - def __set__(self,val): - self._blend_func_src = val - - - property blend_func_dst: - def __get__(self): - return self._blend_func_dst - - def __set__(self,val): - self._blend_func_dst = val - - - property transparent: - def __get__(self): - return self._isTransparent() - - - property shadeless: - def __get__(self): - return self._shadeless - - def __set__(self,val): - self._shadeless = val - - - ############################################################################ - # - # WindowLoop functions - # - - cdef int _isTransparent(self): - # - # check color texture - if self._color and (<soy.textures.Texture> self._color)._chans %2 == 0 : - return 1 - if (<soy.colors.Color> self._ambient)._rgba[3] != 1.0 : - return 1 - if (<soy.colors.Color> self._diffuse)._rgba[3] != 1.0 : - return 1 - if (<soy.colors.Color> self._specular)._rgba[3] != 1.0 : - return 1 - return 0 - - - cdef void _coreBind(self) : - # - # set _shades value - if self._shades == 0 : - gl.glShadeModel(gl.GL_SMOOTH) - else : - gl.glShadeModel(gl.GL_FLAT) - # - # - if self._shadeless: - gl.glDisable(gl.GL_LIGHTING) - gl.glColor4f(self._diffuse._rgba[0], self._diffuse._rgba[1], - self._diffuse._rgba[2], self._diffuse._rgba[3]) - else: - gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, self._ambient._rgba) - gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, self._diffuse._rgba) - gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, self._specular._rgba) - gl.glMaterialfv(gl.GL_FRONT, gl.GL_EMISSION, self._emissive._rgba) - gl.glMaterialf (gl.GL_FRONT, gl.GL_SHININESS, self._shininess) - - if self._color : - (<soy.textures.Texture> self._color)._enable() - - if self._normal : - gl.glEnable(gl.GL_BLEND) - gl.glBlendFunc(gl.GL_DST_COLOR, gl.GL_ZERO) - gl.glEnable(gl.GL_POLYGON_OFFSET_FILL) - gl.glPolygonOffset(0,-2) - elif self._isTransparent(): - gl.glEnable(gl.GL_BLEND) - gl.glBlendFunc(self._blend_func_src, self._blend_func_dst) - - - cdef void _coreUnBind(self) : - if self._color : - (<soy.textures.Texture> self._color)._disable() - if self._normal : - gl.glDisable(gl.GL_BLEND) - gl.glDisable(gl.GL_POLYGON_OFFSET_FILL) - gl.glPolygonOffset(0,0) - elif self._isTransparent(): - gl.glDisable(gl.GL_BLEND) - - if self._shadeless: - gl.glEnable(gl.GL_LIGHTING) - - cdef void _coreBindBumpPass(self) : - if not self._normal : - return - if not _normalisation_cube_map._was_created : - _normalisation_cube_map._generate(32,32) - gl.glActiveTexture(gl.GL_TEXTURE0) - (<soy.textures.Texture> self._normal)._enable() - 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); - gl.glActiveTexture(gl.GL_TEXTURE1) - _normalisation_cube_map._enable() - 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_DOT3_RGB); - gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_SOURCE1_RGB, gl.GL_PREVIOUS); - gl.glActiveTexture(gl.GL_TEXTURE0) - - cdef void _coreUnBindBumpPass(self) : - if not self._normal : - return - gl.glActiveTexture(gl.GL_TEXTURE0) - (<soy.textures.Texture> self._normal)._disable() - gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_MODULATE) - gl.glActiveTexture(gl.GL_TEXTURE1) - _normalisation_cube_map._disable() - gl.glActiveTexture(gl.GL_TEXTURE0) Copied: trunk/pysoy/src/materials/Material.pym (from rev 1274, trunk/pysoy/src/materials/Material.pxi) =================================================================== --- trunk/pysoy/src/materials/Material.pym (rev 0) +++ trunk/pysoy/src/materials/Material.pym 2008-05-19 19:40:00 UTC (rev 1275) @@ -0,0 +1,307 @@ +# PySoy's materials.Material class +# +# Copyright (C) 2006,2007,2008 PySoy Group +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program; if not, see http://www.gnu.org/licenses +# +# $Id$ + +cdef class Material : + '''PySoy Material + + shared material for many visible objects + ''' + + ############################################################################ + # + # Python functions + # + + def __cinit__(self, color=None, ambient=None, diffuse=None, specular=None, + shininess=0.5, + normal=None, normalisation_cube_map=None) : + import soy.colors + if color : + self._color = color + else : + self._color = None + + if normal : + self._normal = normal + else : + self._normal = None + + if ambient : + self._ambient = ambient + else : + self._ambient = soy.colors.white + + if diffuse : + self._diffuse = diffuse + else : + self._diffuse = soy.colors.white + + if specular : + self._specular = specular + else : + self._specular = soy.colors.white + + self._shininess = shininess + + self._blend_func_src = gl.GL_SRC_ALPHA + self._blend_func_dst = gl.GL_ONE_MINUS_SRC_ALPHA + self._shadeless = 0 + + self._emissive = soy.colors.black + + + def __repr__(self) : + return '<Material>' + + + ############################################################################ + # + # Properties + # + + property color : + def __get__(self) : + return self._color + + def __set__(self, soy.textures.Texture value) : + self._color = value + + def __del__(self) : + self._color = None + + + property normal: + def __get__(self): + return self._normal + + def __set__(self, soy.textures.Texture val): + self._normal = val + + def __del__(self): + self._normal = None + + + property ambient : + def __get__(self) : + return self._ambient + + def __set__(self, soy.colors.Color value) : + self._ambient = value + + def __del__(self) : + self._ambient = soy.colors.gray + + + property diffuse : + def __get__(self) : + return self._diffuse + + def __set__(self, soy.colors.Color value) : + self._diffuse = value + + def __del__(self) : + self._diffuse = soy.colors.white + + + property shades : + '''Number of Shades + + This property detirmines how many "shades" a face may have: + 0 == "smooth" + 1 == "flat" + + In the future 2+ will may be permitted for cartoon shading effects. + ''' + def __get__(self) : + return self._shades + + def __set__(self, int value) : + if value<1 or value>1 : + self._shades = 0 + else : + self._shades = value + + def __del__(self) : + self._shades = 0 + + + property shininess : + '''Shininess + + This property is how large the specular "dot" is between 0.0 and 1.0 + ''' + def __get__(self) : + return self._shininess + + def __set__(self, float value) : + self._shininess = value + + def __del__(self) : + self._shininess = 0.0 + + + property specular : + def __get__(self) : + return self._specular + + def __set__(self, val) : + if isinstance(val, soy.colors.Color) : + self._specular=val + else : + raise TypeError('must be a soy.color') + + def __del__(self) : + self._specular=soy.colors.white + + + property emissive : + def __get__(self) : + return self._emissive + + def __set__(self, val) : + if isinstance(val, soy.colors.Color) : + self._emissive=val + else : + raise TypeError('must be a soy.color') + + def __del__(self) : + self._emissive=soy.colors.black + + + property blend_func_src: + def __get__(self): + return self._blend_func_src + + def __set__(self,val): + self._blend_func_src = val + + + property blend_func_dst: + def __get__(self): + return self._blend_func_dst + + def __set__(self,val): + self._blend_func_dst = val + + + property transparent: + def __get__(self): + return self._isTransparent() + + + property shadeless: + def __get__(self): + return self._shadeless + + def __set__(self,val): + self._shadeless = val + + + ############################################################################ + # + # WindowLoop functions + # + + cdef int _isTransparent(self): + # + # check color texture + if self._color and (<soy.textures.Texture> self._color)._chans %2 == 0 : + return 1 + if (<soy.colors.Color> self._ambient)._rgba[3] != 1.0 : + return 1 + if (<soy.colors.Color> self._diffuse)._rgba[3] != 1.0 : + return 1 + if (<soy.colors.Color> self._specular)._rgba[3] != 1.0 : + return 1 + return 0 + + + cdef void _coreBind(self) : + # + # set _shades value + if self._shades == 0 : + gl.glShadeModel(gl.GL_SMOOTH) + else : + gl.glShadeModel(gl.GL_FLAT) + # + # + if self._shadeless: + gl.glDisable(gl.GL_LIGHTING) + gl.glColor4f(self._diffuse._rgba[0], self._diffuse._rgba[1], + self._diffuse._rgba[2], self._diffuse._rgba[3]) + else: + gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, self._ambient._rgba) + gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, self._diffuse._rgba) + gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, self._specular._rgba) + gl.glMaterialfv(gl.GL_FRONT, gl.GL_EMISSION, self._emissive._rgba) + gl.glMaterialf (gl.GL_FRONT, gl.GL_SHININESS, self._shininess) + + if self._color : + (<soy.textures.Texture> self._color)._enable() + + if self._normal : + gl.glEnable(gl.GL_BLEND) + gl.glBlendFunc(gl.GL_DST_COLOR, gl.GL_ZERO) + gl.glEnable(gl.GL_POLYGON_OFFSET_FILL) + gl.glPolygonOffset(0,-2) + elif self._isTransparent(): + gl.glEnable(gl.GL_BLEND) + gl.glBlendFunc(self._blend_func_src, self._blend_func_dst) + + + cdef void _coreUnBind(self) : + if self._color : + (<soy.textures.Texture> self._color)._disable() + if self._normal : + gl.glDisable(gl.GL_BLEND) + gl.glDisable(gl.GL_POLYGON_OFFSET_FILL) + gl.glPolygonOffset(0,0) + elif self._isTransparent(): + gl.glDisable(gl.GL_BLEND) + + if self._shadeless: + gl.glEnable(gl.GL_LIGHTING) + + cdef void _coreBindBumpPass(self) : + if not self._normal : + return + if not _normalisation_cube_map._was_created : + _normalisation_cube_map._generate(32,32) + gl.glActiveTexture(gl.GL_TEXTURE0) + (<soy.textures.Texture> self._normal)._enable() + 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); + gl.glActiveTexture(gl.GL_TEXTURE1) + _normalisation_cube_map._enable() + 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_DOT3_RGB); + gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_SOURCE1_RGB, gl.GL_PREVIOUS); + gl.glActiveTexture(gl.GL_TEXTURE0) + + cdef void _coreUnBindBumpPass(self) : + if not self._normal : + return + gl.glActiveTexture(gl.GL_TEXTURE0) + (<soy.textures.Texture> self._normal)._disable() + gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_MODULATE) + gl.glActiveTexture(gl.GL_TEXTURE1) + _normalisation_cube_map._disable() + gl.glActiveTexture(gl.GL_TEXTURE0) Property changes on: trunk/pysoy/src/materials/Material.pym ___________________________________________________________________ Added: svn:keywords + Id Added: svn:mergeinfo + Deleted: trunk/pysoy/src/materials/P.pxi =================================================================== --- trunk/pysoy/src/materials/P.pxi 2008-05-19 18:32:51 UTC (rev 1274) +++ trunk/pysoy/src/materials/P.pxi 2008-05-19 19:40:00 UTC (rev 1275) @@ -1,30 +0,0 @@ -# PySoy materials.P* classes -# -# Copyright (C) 2006,2007,2008 PySoy Group -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program; if not, see http://www.gnu.org/licenses -# -# $Id$ - -cdef class Pearl (Material) : - '''Pysoy materials.Pearl - - This material is intended to look like Yule Marble - ''' - def __init__(self): - import soy.colors - self.ambient = soy.colors.white - self.diffuse = soy.colors.white - self.specular = soy.colors.lightPink - self.shininess = 10 Deleted: trunk/pysoy/src/materials/R.pxi =================================================================== --- trunk/pysoy/src/materials/R.pxi 2008-05-19 18:32:51 UTC (rev 1274) +++ trunk/pysoy/src/materials/R.pxi 2008-05-19 19:40:00 UTC (rev 1275) @@ -1,30 +0,0 @@ -# PySoy materials.R* classes -# -# Copyright (C) 2006,2007,2008 PySoy Group -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program; if not, see http://www.gnu.org/licenses -# -# $Id$ - -cdef class Rhodonite (Material) : - '''PySoy materials.Rhodonite - - This default material is intended to look like rhodonite, a pink gem. - ''' - def __init__(self): - import soy.colors - self.ambient = soy.colors.deepPink - self.diffuse = soy.colors.pink - self.specular = soy.colors.lightPink - self.shininess = 8 Deleted: trunk/pysoy/src/materials/S.pxi =================================================================== --- trunk/pysoy/src/materials/S.pxi 2008-05-19 18:32:51 UTC (rev 1274) +++ trunk/pysoy/src/materials/S.pxi 2008-05-19 19:40:00 UTC (rev 1275) @@ -1,30 +0,0 @@ -# PySoy materials.S* classes -# -# Copyright (C) 2006,2007,2008 PySoy Group -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program; if not, see http://www.gnu.org/licenses -# -# $Id$ - -cdef class StainlessSteel (Material) : - '''PySoy materials.Steel - - This default material is intended to look like stainless steel. - ''' - def __init__(self) : - import soy.colors - self.ambient = soy.colors.stainlessSteel - self.diffuse = soy.colors.stainlessSteel - self.specular = soy.colors.white - self.shininess = 9 Deleted: trunk/pysoy/src/materials/V.pxi =================================================================== --- trunk/pysoy/src/materials/V.pxi 2008-05-19 18:32:51 UTC (rev 1274) +++ trunk/pysoy/src/materials/V.pxi 2008-05-19 19:40:00 UTC (rev 1275) @@ -1,30 +0,0 @@ -# PySoy materials.V* classes -# -# Copyright (C) 2006,2007,2008 PySoy Group -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program; if not, see http://www.gnu.org/licenses -# -# $Id$ - -cdef class VelvetyRed (Material) : - '''Pysoy materials.VelvetyRed - - This class is intended to look like Red Velvet - ''' - def __init__(self) : - import soy.colors - self.ambient = soy.colors.red - self.diffuse = soy.colors.red - self.specular = soy.colors.red - self.shininess = 0 Modified: trunk/pysoy/src/materials/__init__.pym =================================================================== --- trunk/pysoy/src/materials/__init__.pym 2008-05-19 18:32:51 UTC (rev 1274) +++ trunk/pysoy/src/materials/__init__.pym 2008-05-19 19:40:00 UTC (rev 1275) @@ -18,10 +18,18 @@ # $Id: Material.pxi 1206 2008-03-22 18:42:26Z ArcRiley $ cimport soy.textures - +# +############################################################################## +# +# extension-level globals +# cdef int _texunits[8] cdef soy.textures.NormalisationCubeMap _normalisation_cube_map - +# +############################################################################## +# +# _texunits array allows for cleaner code through the Materials extension +# _texunits[0] = gl.GL_TEXTURE0 _texunits[1] = gl.GL_TEXTURE1 _texunits[2] = gl.GL_TEXTURE2 @@ -30,5 +38,11 @@ _texunits[5] = gl.GL_TEXTURE5 _texunits[6] = gl.GL_TEXTURE6 _texunits[7] = gl.GL_TEXTURE7 - +# +############################################################################## +# +# this cubemap is universal to many material effects +# _normalisation_cube_map = soy.textures.NormalisationCubeMap() +# +############################################################################## Added: trunk/pysoy/src/materials/_postinit.pym =================================================================== --- trunk/pysoy/src/materials/_postinit.pym (rev 0) +++ trunk/pysoy/src/materials/_postinit.pym 2008-05-19 19:40:00 UTC (rev 1275) @@ -0,0 +1,122 @@ +# PySoy's materials postinit +# +# Copyright (C) 2006,2007,2008 PySoy Group +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program; if not, see http://www.gnu.org/licenses +# +# $Id: Material.pxi 1206 2008-03-22 18:42:26Z ArcRiley $ + +############################################################################## +# +# temporarily import colors and set some default extension-level materials +# +from soy import colors +# +####################################### +# +# green aventurine +# +aventurine = \ + Material(ambient = colors.aventurine, + diffuse = colors.aventurine, + specular = colors.teal, + shininess = 10) +# +####################################### +# +# a dark grey matte material +# +basalt = \ + Material(ambient = colors.basalt, + diffuse = colors.basalt, + specular = colors.basalt, + shininess = 4) +# +####################################### +# +# this should use a metalic material +# +copper = \ + Material(ambient = colors.copper, + diffuse = colors.copper, + specular = colors.yellow, + shininess = 5) +# +####################################### +# +# copper(II) sulfate crystal +# +copperSulfate = \ + Material(ambient = colors.copperSulfate, + diffuse = colors.copperSulfate, + specular = colors.veryLightBlueGreen, + shininess = 10) +# +####################################### +# +# basic dark brown +# +darkWood = \ + Material(ambient = colors.darkWood, + diffuse = colors.darkWood, + specular = colors.darkWood, + shininess = 0) +# +####################################### +# +# this should probably use a metalic material +# +pearl = \ + Material(ambient = colors.white, + diffuse = colors.white, + specular = colors.lightPink, + shininess = 10) +# +####################################### +# +# a pink crystal +# +rhodonite = \ + Material(ambient = colors.deepPink, + diffuse = colors.pink, + specular = colors.lightPink, + shininess = 8) +# +####################################### +# +# this needs to use a metalic material instead +# +stainlessSteel = \ + Material(ambient = colors.stainlessSteel, + diffuse = colors.stainlessSteel, + specular = colors.white, + shininess = 9) +# +####################################### +# +# a very sharp red material with no specularity +# +velvetyRed = \ + Material(ambient = colors.red, + diffuse = colors.red, + specular = colors.red, + shininess = 0) +# +####################################### +# +# delete this so it's not hanging around in soy.materials namespace +# +del(colors) +# +############################################################################## Modified: trunk/pysoy/src/materials/soy.materials.pyx =================================================================== --- trunk/pysoy/src/materials/soy.materials.pyx 2008-05-19 18:32:51 UTC (rev 1274) +++ trunk/pysoy/src/materials/soy.materials.pyx 2008-05-19 19:40:00 UTC (rev 1275) @@ -24,12 +24,5 @@ __version__ = 'Trunk (r'+'$Rev$'[6:-2]+')' include "__init__.pym" -include "Material.pxi" -include "A.pxi" -include "B.pxi" -include "C.pxi" -include "D.pxi" -include "P.pxi" -include "R.pxi" -include "S.pxi" -include "V.pxi" +include "Material.pym" +include "_postinit.pym" _______________________________________________ PySoy-SVN mailing list PySoy-SVN@pysoy.org http://www.pysoy.org/mailman/listinfo/pysoy-svn