Author: JaroslawTworek
Date: 2008-02-01 14:51:35 -0500 (Fri, 01 Feb 2008)
New Revision: 809
Modified:
trunk/pysoy/examples/bumpmap_example.py
trunk/pysoy/src/materials/Material.pxi
trunk/pysoy/src/materials/soy.materials.pxd
trunk/pysoy/src/textures/NormalisationCubeMap.pxi
trunk/pysoy/src/textures/soy.textures.pxd
Log:
Bumpmap bugfix
Modified: trunk/pysoy/examples/bumpmap_example.py
===================================================================
--- trunk/pysoy/examples/bumpmap_example.py 2008-02-01 18:45:51 UTC (rev
808)
+++ trunk/pysoy/examples/bumpmap_example.py 2008-02-01 19:51:35 UTC (rev
809)
@@ -19,11 +19,13 @@
def create_quad_mesh(mat):
mesh = soy.meshes.Mesh(material=mat)
+ scale=1
+
quad_vertices = [
- ( 1, 1, 0),
- ( 1,-1, 0),
- (-1,-1, 0),
- (-1, 1, 0)
+ ( 1*scale, 1*scale, 0),
+ ( 1*scale,-1*scale, 0),
+ (-1*scale,-1*scale, 0),
+ (-1*scale, 1*scale, 0)
]
quad_faces = [
(0,1,2),
@@ -60,12 +62,8 @@
decal_tex = soy.transports.File('media/decal.soy')['gimp']
normal_tex = soy.transports.File('media/normal_map.soy')['gimp']
- normalisation_cube = soy.textures.NormalisationCubeMap()
- normalisation_cube.generate(32,32)
-
decal_mat = soy.materials.Material(decal_tex)
decal_mat.normal = normal_tex
- decal_mat.normalisation_cube_map = normalisation_cube
test_mesh = create_quad_mesh(decal_mat)
test_mesh_b = soy.bodies.Body(sce, mesh=test_mesh)
Modified: trunk/pysoy/src/materials/Material.pxi
===================================================================
--- trunk/pysoy/src/materials/Material.pxi 2008-02-01 18:45:51 UTC (rev
808)
+++ trunk/pysoy/src/materials/Material.pxi 2008-02-01 19:51:35 UTC (rev
809)
@@ -17,6 +17,12 @@
#
# $Id$
+cimport soy.textures
+
+cdef soy.textures.NormalisationCubeMap _normalisation_cube_map
+_normalisation_cube_map = soy.textures.NormalisationCubeMap()
+
+
cdef class Material :
'''PySoy Material
@@ -30,7 +36,6 @@
self._color = None
self._normal = normal
- self._normalisation_cube_map = normalisation_cube_map
if ambient :
self._ambient = ambient
@@ -56,6 +61,7 @@
self._emissive = soy.colors.Black()
+
def __repr__(self) :
return '<Material>'
@@ -83,7 +89,7 @@
return 0
cdef int _has_bumpmap(self):
- if self._normal and self._normalisation_cube_map:
+ if self._normal:
return 1
return 0
@@ -143,6 +149,9 @@
cdef void _bindBumpPass(self) :
if self._has_bumpmap():
+ if not _normalisation_cube_map._was_created:
+ _normalisation_cube_map._generate(32,32)
+
gl.glActiveTexture(gl.GL_TEXTURE0)
(<soy.textures.Texture> self._normal)._bind()
@@ -151,7 +160,7 @@
gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_COMBINE_RGB, gl.GL_REPLACE);
gl.glActiveTexture(gl.GL_TEXTURE1)
- (<soy.textures.NormalisationCubeMap>
self._normalisation_cube_map)._bind()
+ _normalisation_cube_map._bind()
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);
@@ -167,7 +176,7 @@
gl.glTexEnvi(gl.GL_TEXTURE_ENV, gl.GL_TEXTURE_ENV_MODE, gl.GL_MODULATE)
gl.glActiveTexture(gl.GL_TEXTURE1)
- (<soy.textures.NormalisationCubeMap>
self._normalisation_cube_map)._unbind()
+ _normalisation_cube_map._unbind()
gl.glActiveTexture(gl.GL_TEXTURE0)
@@ -187,15 +196,6 @@
def __del__(self):
self._normal = None
- property normalisation_cube_map:
- def __get__(self):
- return self._normalisation_cube_map
- def __set__(self, soy.textures.NormalisationCubeMap val):
- self._normalisation_cube_map = val
- def __del__(self):
- self._normal = None
-
-
property ambient :
def __get__(self) :
return self._ambient
Modified: trunk/pysoy/src/materials/soy.materials.pxd
===================================================================
--- trunk/pysoy/src/materials/soy.materials.pxd 2008-02-01 18:45:51 UTC (rev
808)
+++ trunk/pysoy/src/materials/soy.materials.pxd 2008-02-01 19:51:35 UTC (rev
809)
@@ -25,7 +25,6 @@
cdef class Material :
cdef object _color
cdef object _normal
- cdef object _normalisation_cube_map
cdef soy.colors.Color _ambient
cdef soy.colors.Color _diffuse
Modified: trunk/pysoy/src/textures/NormalisationCubeMap.pxi
===================================================================
--- trunk/pysoy/src/textures/NormalisationCubeMap.pxi 2008-02-01 18:45:51 UTC
(rev 808)
+++ trunk/pysoy/src/textures/NormalisationCubeMap.pxi 2008-02-01 19:51:35 UTC
(rev 809)
@@ -3,12 +3,14 @@
cdef class NormalisationCubeMap(Texture):
def __cinit__(self):
self._mutex = py.PyThread_allocate_lock()
+ self._was_created = 0
def generate(self,x,y):
self._generate(x,y)
cdef void _generate(self, int x_size, int y_size):
+ self._was_created = 1
self._textureTarget = gl.GL_TEXTURE_CUBE_MAP
self._chans = 3
gl.glGenTextures(1, &self._textureID)
Modified: trunk/pysoy/src/textures/soy.textures.pxd
===================================================================
--- trunk/pysoy/src/textures/soy.textures.pxd 2008-02-01 18:45:51 UTC (rev
808)
+++ trunk/pysoy/src/textures/soy.textures.pxd 2008-02-01 19:51:35 UTC (rev
809)
@@ -74,6 +74,7 @@
cdef double _frameTime
cdef class NormalisationCubeMap(Texture):
+ cdef int _was_created
cdef void _generate(self,int,int)
cdef void _bind(self)
cdef void _unbind(self)
_______________________________________________
PySoy-SVN mailing list
[email protected]
http://www.pysoy.org/mailman/listinfo/pysoy-svn