Author: ArcRiley
Date: 2008-05-20 01:39:26 -0400 (Tue, 20 May 2008)
New Revision: 1288

Modified:
   trunk/pysoy/src/materials/_normalisationCubemap.pym
Log:
Ticket #955 :
  * added some comments and required New-BSD license header


Modified: trunk/pysoy/src/materials/_normalisationCubemap.pym
===================================================================
--- trunk/pysoy/src/materials/_normalisationCubemap.pym 2008-05-20 05:17:04 UTC 
(rev 1287)
+++ trunk/pysoy/src/materials/_normalisationCubemap.pym 2008-05-20 05:39:26 UTC 
(rev 1288)
@@ -25,11 +25,73 @@
   cdef float _length
   cdef float _vector[3]
   cdef unsigned char* _ptr
-
+  #
+  ########################################
+  #
+  # call the texture's _resize function
+  #
+  # This sets up many of the textures parameters and mallocs _texels
+  # In the future the first array (bytes) should be 4 for float, which should
+  # not only speed this up a bit but provide more accurate normalisation
+  #
   _cubemap._resize(1, 3, 32, 32, 6)
+  #
+  ########################################
+  #
+  # initialize _ptr to the texture's _texels
+  #
+  # we use _ptr to scan over the _texels data as it's generated, which is
+  # slightly faster than using _ptr as an int and adding it many times, ie:
+  #   _ptr[0] = <unsigned char> (_vector[0] * 255)
+  #   _ptr[1] = <unsigned char> (_vector[1] * 255)
+  #   _ptr[2] = <unsigned char> (_vector[2] * 255)
+  #   _ptr = _ptr + 3
+  #
+  #  vs the slower
+  #
+  #   _cubemap._texels[_ptr  ] = <unsigned char> (_vector[0] * 255)
+  #   _cubemap._texels[_ptr+1] = <unsigned char> (_vector[0] * 255)
+  #   _cubemap._texels[_ptr+2] = <unsigned char> (_vector[0] * 255)
+  #   _ptr = _ptr + 3
+  # 
   _ptr = _cubemap._texels
-
+  #
+  ############################################################################
+  #
+  # This following code was derived from "Normalisation Cube Map.cpp"
+  # from http://paulsprojects.net/tutorials/simplebump/simplebump.html
+  #
+  # Copyright (c) 2006, Paul Baker
+  # All rights reserved.
+  #
+  # Redistribution and use in source and binary forms, with or without
+  # modification, are permitted provided that the following conditions are met:
+  #
+  #  * Redistributions of source code must retain the above copyright notice,
+  #    this list of conditions and the following disclaimer.
+  #  * Redistributions in binary form must reproduce the above copyright
+  #    notice, this list of conditions and the following disclaimer in the
+  #    documentation and/or other materials provided with the distribution.
+  #  * Neither the name of paulsprojects.net nor the names of its contributors
+  #    may be used to endorse or promote products derived from this software
+  #    without specific prior written permission.
+  #
+  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+  # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+  # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+  # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+  # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+  # POSSIBILITY OF SUCH DAMAGE.
+  #
+  ########################################
+  #
   # +X
+  # 
   for _j from 0 < _j <= 32:
     for _i from 0 < _i <= 32:
       _vector[0] =  16.0
@@ -48,9 +110,11 @@
       _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
@@ -69,9 +133,11 @@
       _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)
@@ -90,9 +156,11 @@
       _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)
@@ -111,9 +179,11 @@
       _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)
@@ -132,9 +202,11 @@
       _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)
@@ -153,3 +225,5 @@
       _ptr[1] = <unsigned char> (_vector[1] * 255)
       _ptr[2] = <unsigned char> (_vector[2] * 255)
       _ptr = _ptr + 3
+  #
+  ############################################################################

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

Reply via email to