Author: ArcRiley
Date: 2008-05-20 01:17:04 -0400 (Tue, 20 May 2008)
New Revision: 1287

Modified:
   trunk/pysoy/src/materials/__init__.pym
   trunk/pysoy/src/materials/_normalisationCubemap.pym
   trunk/pysoy/src/materials/_postinit.pym
   trunk/pysoy/src/materials/soy.materials.pyx
Log:
Ticket #955 :
  * the normalisation cubemap is now completely internal to soy.materials


Modified: trunk/pysoy/src/materials/__init__.pym
===================================================================
--- trunk/pysoy/src/materials/__init__.pym      2008-05-20 04:55:21 UTC (rev 
1286)
+++ trunk/pysoy/src/materials/__init__.pym      2008-05-20 05:17:04 UTC (rev 
1287)
@@ -24,7 +24,7 @@
 # extension-level globals
 #
 cdef int _texunits[8]
-cdef soy.textures.NormalisationCubeMap  _normalisation_cube_map
+cdef soy.textures.Texture _normalisation_cube_map
 #
 ##############################################################################
 #
@@ -40,9 +40,3 @@
 _texunits[7] = gl.GL_TEXTURE7
 #
 ##############################################################################
-#
-# this cubemap is universal to many material effects
-#
-_normalisation_cube_map = soy.textures.NormalisationCubeMap()
-#
-##############################################################################

Modified: trunk/pysoy/src/materials/_normalisationCubemap.pym
===================================================================
--- trunk/pysoy/src/materials/_normalisationCubemap.pym 2008-05-20 04:55:21 UTC 
(rev 1286)
+++ trunk/pysoy/src/materials/_normalisationCubemap.pym 2008-05-20 05:17:04 UTC 
(rev 1287)
@@ -1,143 +1,155 @@
+# PySoy's materials._normalisationCubemap function
+#
+# 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$
+
 cimport stdlib
+cimport soy.textures
 
-cdef class NormalisationCubeMap(Texture):
-  def __cinit__(self, *args, **keywords) :
-    cdef int i, j
-    cdef float _length
-    cdef float _vector[3]
-    cdef unsigned char* _ptr
+cdef void _normalisationCubemap(soy.textures.Texture _cubemap) :
+  cdef int _i, _j
+  cdef float _length
+  cdef float _vector[3]
+  cdef unsigned char* _ptr
 
-    self._resize(1, 3, 32, 32, 6)
-    _ptr = self._texels
+  _cubemap._resize(1, 3, 32, 32, 6)
+  _ptr = _cubemap._texels
 
-    # +X
-    for j from 0 < j <= 32:
-      for i from 0 < i <= 32:
-        _vector[0] =  16.0
-        _vector[1] = -(j + 0.5 - 16.0)
-        _vector[2] = -(i + 0.5 - 16.0)
+  # +X
+  for _j from 0 < _j <= 32:
+    for _i from 0 < _i <= 32:
+      _vector[0] =  16.0
+      _vector[1] = -(_j + 0.5 - 16.0)
+      _vector[2] = -(_i + 0.5 - 16.0)
 
-        _length = stdlib.sqrtf( _vector[0] * _vector[0] + 
-                                _vector[1] * _vector[1] + 
-                                _vector[2] * _vector[2] )
+      _length = stdlib.sqrtf( _vector[0] * _vector[0] + 
+                              _vector[1] * _vector[1] + 
+                              _vector[2] * _vector[2] )
 
-        _vector[0] = 0.5 * (_vector[0] / _length) + 0.5
-        _vector[1] = 0.5 * (_vector[1] / _length) + 0.5
-        _vector[2] = 0.5 * (_vector[2] / _length) + 0.5
+      _vector[0] = 0.5 * (_vector[0] / _length) + 0.5
+      _vector[1] = 0.5 * (_vector[1] / _length) + 0.5
+      _vector[2] = 0.5 * (_vector[2] / _length) + 0.5
 
-        _ptr[0] = <unsigned char> (_vector[0] * 255)
-        _ptr[1] = <unsigned char> (_vector[1] * 255)
-        _ptr[2] = <unsigned char> (_vector[2] * 255)
-        _ptr = _ptr + 3
+      _ptr[0] = <unsigned char> (_vector[0] * 255)
+      _ptr[1] = <unsigned char> (_vector[1] * 255)
+      _ptr[2] = <unsigned char> (_vector[2] * 255)
+      _ptr = _ptr + 3
 
 
-    #-X
-    for j from 0 < j <= 32:
-      for i from 0 < i <= 32:
-        _vector[0] = -16.0
-        _vector[1] = -(j + 0.5 - 16.0)
-        _vector[2] =  (i + 0.5 - 16.0)
+  # -X
+  for _j from 0 < _j <= 32:
+    for _i from 0 < _i <= 32:
+      _vector[0] = -16.0
+      _vector[1] = -(_j + 0.5 - 16.0)
+      _vector[2] =  (_i + 0.5 - 16.0)
 
-        _length = stdlib.sqrtf( _vector[0] * _vector[0] + 
-                                _vector[1] * _vector[1] + 
-                                _vector[2] * _vector[2] )
+      _length = stdlib.sqrtf( _vector[0] * _vector[0] + 
+                              _vector[1] * _vector[1] + 
+                              _vector[2] * _vector[2] )
 
-        _vector[0] = 0.5 * (_vector[0] / _length) + 0.5
-        _vector[1] = 0.5 * (_vector[1] / _length) + 0.5
-        _vector[2] = 0.5 * (_vector[2] / _length) + 0.5
+      _vector[0] = 0.5 * (_vector[0] / _length) + 0.5
+      _vector[1] = 0.5 * (_vector[1] / _length) + 0.5
+      _vector[2] = 0.5 * (_vector[2] / _length) + 0.5
 
-        _ptr[0] = <unsigned char> (_vector[0] * 255)
-        _ptr[1] = <unsigned char> (_vector[1] * 255)
-        _ptr[2] = <unsigned char> (_vector[2] * 255)
-        _ptr = _ptr + 3
-    
-    #+Y
-    for j from 0 < j <= 32:
-      for i from 0 < i <= 32:
-        _vector[0] =  (i + 0.5 - 16.0)
-        _vector[1] =  16.0
-        _vector[2] =  (j + 0.5 - 16.0)
+      _ptr[0] = <unsigned char> (_vector[0] * 255)
+      _ptr[1] = <unsigned char> (_vector[1] * 255)
+      _ptr[2] = <unsigned char> (_vector[2] * 255)
+      _ptr = _ptr + 3
 
-        _length = stdlib.sqrtf( _vector[0] * _vector[0] + 
-                                _vector[1] * _vector[1] + 
-                                _vector[2] * _vector[2] )
 
-        _vector[0] = 0.5 * (_vector[0] / _length) + 0.5
-        _vector[1] = 0.5 * (_vector[1] / _length) + 0.5
-        _vector[2] = 0.5 * (_vector[2] / _length) + 0.5
+  # +Y
+  for _j from 0 < _j <= 32:
+    for _i from 0 < _i <= 32:
+      _vector[0] =  (_i + 0.5 - 16.0)
+      _vector[1] =  16.0
+      _vector[2] =  (_j + 0.5 - 16.0)
 
-        _ptr[0] = <unsigned char> (_vector[0] * 255)
-        _ptr[1] = <unsigned char> (_vector[1] * 255)
-        _ptr[2] = <unsigned char> (_vector[2] * 255)
-        _ptr = _ptr + 3
+      _length = stdlib.sqrtf( _vector[0] * _vector[0] + 
+                              _vector[1] * _vector[1] + 
+                              _vector[2] * _vector[2] )
+
+      _vector[0] = 0.5 * (_vector[0] / _length) + 0.5
+      _vector[1] = 0.5 * (_vector[1] / _length) + 0.5
+      _vector[2] = 0.5 * (_vector[2] / _length) + 0.5
+
+      _ptr[0] = <unsigned char> (_vector[0] * 255)
+      _ptr[1] = <unsigned char> (_vector[1] * 255)
+      _ptr[2] = <unsigned char> (_vector[2] * 255)
+      _ptr = _ptr + 3
     
 
-    #-Y
-    for j from 0 < j <= 32:
-      for i from 0 < i <= 32:
-        _vector[0] =  (i + 0.5 - 16.0)
-        _vector[1] = -16.0
-        _vector[2] = -(j + 0.5 - 16.0)
+  # -Y
+  for _j from 0 < _j <= 32:
+    for _i from 0 < _i <= 32:
+      _vector[0] =  (_i + 0.5 - 16.0)
+      _vector[1] = -16.0
+      _vector[2] = -(_j + 0.5 - 16.0)
 
-        _length = stdlib.sqrtf( _vector[0] * _vector[0] + 
-                                _vector[1] * _vector[1] + 
-                                _vector[2] * _vector[2] )
+      _length = stdlib.sqrtf( _vector[0] * _vector[0] + 
+                              _vector[1] * _vector[1] + 
+                              _vector[2] * _vector[2] )
 
-        _vector[0] = 0.5 * (_vector[0] / _length) + 0.5
-        _vector[1] = 0.5 * (_vector[1] / _length) + 0.5
-        _vector[2] = 0.5 * (_vector[2] / _length) + 0.5
+      _vector[0] = 0.5 * (_vector[0] / _length) + 0.5
+      _vector[1] = 0.5 * (_vector[1] / _length) + 0.5
+      _vector[2] = 0.5 * (_vector[2] / _length) + 0.5
 
-        _ptr[0] = <unsigned char> (_vector[0] * 255)
-        _ptr[1] = <unsigned char> (_vector[1] * 255)
-        _ptr[2] = <unsigned char> (_vector[2] * 255)
-        _ptr = _ptr + 3
-    
+      _ptr[0] = <unsigned char> (_vector[0] * 255)
+      _ptr[1] = <unsigned char> (_vector[1] * 255)
+      _ptr[2] = <unsigned char> (_vector[2] * 255)
+      _ptr = _ptr + 3
 
-    #+Z
-    for j from 0 < j <= 32:
-      for i from 0 < i <= 32:
-        _vector[0] =  (i + 0.5 - 16.0)
-        _vector[1] = -(j + 0.5 - 16.0)
-        _vector[2] =  16.0
 
-        _length = stdlib.sqrtf( _vector[0] * _vector[0] + 
-                                _vector[1] * _vector[1] + 
-                                _vector[2] * _vector[2] )
+  # +Z
+  for _j from 0 < _j <= 32:
+    for _i from 0 < _i <= 32:
+      _vector[0] =  (_i + 0.5 - 16.0)
+      _vector[1] = -(_j + 0.5 - 16.0)
+      _vector[2] =  16.0
 
-        _vector[0] = 0.5 * (_vector[0] / _length) + 0.5
-        _vector[1] = 0.5 * (_vector[1] / _length) + 0.5
-        _vector[2] = 0.5 * (_vector[2] / _length) + 0.5
+      _length = stdlib.sqrtf( _vector[0] * _vector[0] + 
+                              _vector[1] * _vector[1] + 
+                              _vector[2] * _vector[2] )
 
-        _ptr[0] = <unsigned char> (_vector[0] * 255)
-        _ptr[1] = <unsigned char> (_vector[1] * 255)
-        _ptr[2] = <unsigned char> (_vector[2] * 255)
-        _ptr = _ptr + 3
+      _vector[0] = 0.5 * (_vector[0] / _length) + 0.5
+      _vector[1] = 0.5 * (_vector[1] / _length) + 0.5
+      _vector[2] = 0.5 * (_vector[2] / _length) + 0.5
+
+      _ptr[0] = <unsigned char> (_vector[0] * 255)
+      _ptr[1] = <unsigned char> (_vector[1] * 255)
+      _ptr[2] = <unsigned char> (_vector[2] * 255)
+      _ptr = _ptr + 3
     
 
-    #-Z
-    for j from 0 < j <= 32:
-      for i from 0 < i <= 32:
-        _vector[0] = -(i + 0.5 - 16.0)
-        _vector[1] = -(j + 0.5 - 16.0)
-        _vector[2] = -16.0
+  # -Z
+  for _j from 0 < _j <= 32:
+    for _i from 0 < _i <= 32:
+      _vector[0] = -(_i + 0.5 - 16.0)
+      _vector[1] = -(_j + 0.5 - 16.0)
+      _vector[2] = -16.0
 
-        _length = stdlib.sqrtf( _vector[0] * _vector[0] + 
-                                _vector[1] * _vector[1] + 
-                                _vector[2] * _vector[2] )
+      _length = stdlib.sqrtf( _vector[0] * _vector[0] + 
+                              _vector[1] * _vector[1] + 
+                              _vector[2] * _vector[2] )
 
-        _vector[0] = 0.5 * (_vector[0] / _length) + 0.5
-        _vector[1] = 0.5 * (_vector[1] / _length) + 0.5
-        _vector[2] = 0.5 * (_vector[2] / _length) + 0.5
+      _vector[0] = 0.5 * (_vector[0] / _length) + 0.5
+      _vector[1] = 0.5 * (_vector[1] / _length) + 0.5
+      _vector[2] = 0.5 * (_vector[2] / _length) + 0.5
 
-        _ptr[0] = <unsigned char> (_vector[0] * 255)
-        _ptr[1] = <unsigned char> (_vector[1] * 255)
-        _ptr[2] = <unsigned char> (_vector[2] * 255)
-        _ptr = _ptr + 3
-    
-    '''
-    gl.glTexParameteri(self._target, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR)
-    gl.glTexParameteri(self._target, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR)
-    gl.glTexParameteri(self._target, gl.GL_TEXTURE_WRAP_S  , 
gl.GL_CLAMP_TO_EDGE)
-    gl.glTexParameteri(self._target, gl.GL_TEXTURE_WRAP_T  , 
gl.GL_CLAMP_TO_EDGE)
-    gl.glTexParameteri(self._target, gl.GL_TEXTURE_WRAP_R  , 
gl.GL_CLAMP_TO_EDGE)
-    '''
+      _ptr[0] = <unsigned char> (_vector[0] * 255)
+      _ptr[1] = <unsigned char> (_vector[1] * 255)
+      _ptr[2] = <unsigned char> (_vector[2] * 255)
+      _ptr = _ptr + 3

Modified: trunk/pysoy/src/materials/_postinit.pym
===================================================================
--- trunk/pysoy/src/materials/_postinit.pym     2008-05-20 04:55:21 UTC (rev 
1286)
+++ trunk/pysoy/src/materials/_postinit.pym     2008-05-20 05:17:04 UTC (rev 
1287)
@@ -18,7 +18,16 @@
 # $Id$
 
 ##############################################################################
+# 
+# this cubemap is universal to many material effects
 #
+from soy import textures
+_normalisation_cube_map = soy.textures.Texture()
+_normalisationCubemap(_normalisation_cube_map)
+del(textures)
+#
+##############################################################################
+#
 # temporarily import colors and set some default extension-level materials
 #
 from soy import colors
@@ -120,3 +129,4 @@
 del(colors)
 #
 ##############################################################################
+

Modified: trunk/pysoy/src/materials/soy.materials.pyx
===================================================================
--- trunk/pysoy/src/materials/soy.materials.pyx 2008-05-20 04:55:21 UTC (rev 
1286)
+++ trunk/pysoy/src/materials/soy.materials.pyx 2008-05-20 05:17:04 UTC (rev 
1287)
@@ -26,4 +26,5 @@
 include "__init__.pym"
 include "Material.pym"
 include "Textured.pym"
+include "_normalisationCubemap.pym"
 include "_postinit.pym"

_______________________________________________
PySoy-SVN mailing list
PySoy-SVN@pysoy.org
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to