Author: ArcRiley
Date: 2008-02-26 13:12:54 -0500 (Tue, 26 Feb 2008)
New Revision: 991

Modified:
   trunk/pysoy/src/_datatypes/VertexList.pxi
   trunk/pysoy/src/bodies._bodies/Body.pxi
Log:
Ticket #934 :
  * commented out broken code in VertexList for tangent space vector calc
  * removed printf debug - collide_blocks.py now works (without light on)


Modified: trunk/pysoy/src/_datatypes/VertexList.pxi
===================================================================
--- trunk/pysoy/src/_datatypes/VertexList.pxi   2008-02-26 17:43:24 UTC (rev 
990)
+++ trunk/pysoy/src/_datatypes/VertexList.pxi   2008-02-26 18:12:54 UTC (rev 
991)
@@ -209,7 +209,7 @@
     cdef float                   _vert_light_pos[3]
     cdef float                   _binormal[3]
     cdef float                   _lgt
-    cdef int                     i
+    cdef int                     _i
 
     _body = <soy.bodies._bodies.Body> __body
     _scene = _body._scene
@@ -217,8 +217,10 @@
     if _scene._lights.current > 0:
       _light = <soy.bodies.lights.Light> _scene._lights.list[0]
       _body._coreGetModelviewInv(_inv_mm)
-
-      #vector by matrix multiplication by hand
+      #
+      # Vector by matrix multiplication by hand
+      # This code needs to average the light color and vector
+      #
       _model_light_pos[0] = _inv_mm[0] * (_light._position[0] + _inv_mm[12]) \
                           + _inv_mm[4] * (_light._position[1] + _inv_mm[13]) \
                           + _inv_mm[8] * (_light._position[2] + _inv_mm[14]) 
@@ -231,10 +233,10 @@
                           + _inv_mm[6] * (_light._position[1] + _inv_mm[13]) \
                           + _inv_mm[10]* (_light._position[2] + _inv_mm[14])
 
-      for i from 0 <= i < self._arraySize:
-        _vert_light_pos[0] = _model_light_pos[0] - self._array[i].px
-        _vert_light_pos[1] = _model_light_pos[1] - self._array[i].py
-        _vert_light_pos[2] = _model_light_pos[2] - self._array[i].pz
+      for _i from 0 <= _i < self._arraySize:
+        _vert_light_pos[0] = _model_light_pos[0] - self._array[_i].px
+        _vert_light_pos[1] = _model_light_pos[1] - self._array[_i].py
+        _vert_light_pos[2] = _model_light_pos[2] - self._array[_i].pz
 
         _lgt = stdlib.sqrtf( _vert_light_pos[0] * _vert_light_pos[0] \
                             +_vert_light_pos[1] * _vert_light_pos[1] \
@@ -244,38 +246,41 @@
         _vert_light_pos[1] = _vert_light_pos[1] / _lgt
         _vert_light_pos[2] = _vert_light_pos[2] / _lgt
 
-        _binormal[0] = self._array[i].tan_y * self._array[i].nz - \
-                       self._array[i].tan_z * self._array[i].ny
+        _binormal[0] = self._array[_i].tan_y * self._array[_i].nz - \
+                       self._array[_i].tan_z * self._array[_i].ny
 
-        _binormal[1] = self._array[i].tan_z * self._array[i].nx - \
-                       self._array[i].tan_x * self._array[i].nz
+        _binormal[1] = self._array[_i].tan_z * self._array[_i].nx - \
+                       self._array[_i].tan_x * self._array[_i].nz
 
-        _binormal[2] = self._array[i].tan_x * self._array[i].ny - \
-                       self._array[i].tan_y * self._array[i].nx
+        _binormal[2] = self._array[_i].tan_x * self._array[_i].ny - \
+                       self._array[_i].tan_y * self._array[_i].nx
               
-        self._tslvArray[3*i+0] = ( _vert_light_pos[0] * self._array[i].tan_x \
-                                  +_vert_light_pos[1] * self._array[i].tan_y \
-                                  +_vert_light_pos[2] * self._array[i].tan_z )
+        self._tslvArray[3*i+0] = ( _vert_light_pos[0] * self._array[_i].tan_x \
+                                  +_vert_light_pos[1] * self._array[_i].tan_y \
+                                  +_vert_light_pos[2] * self._array[_i].tan_z )
 
         self._tslvArray[3*i+1] = ( _vert_light_pos[0] * _binormal[0] \
                                   +_vert_light_pos[1] * _binormal[1] \
                                   +_vert_light_pos[2] * _binormal[2] )
 
-        self._tslvArray[3*i+2] = ( _vert_light_pos[0] * self._array[i].nx \
-                                  +_vert_light_pos[1] * self._array[i].ny \
-                                  +_vert_light_pos[2] * self._array[i].nz )
+        self._tslvArray[3*i+2] = ( _vert_light_pos[0] * self._array[_i].nx \
+                                  +_vert_light_pos[1] * self._array[_i].ny \
+                                  +_vert_light_pos[2] * self._array[_i].nz )
               
-        #self._tslvArray[3*i + 0] = 0
-        #self._tslvArray[3*i + 1] = 0
-        #self._tslvArray[3*i + 2] = 1
+        #self._tslvArray[3*_i + 0] = 0
+        #self._tslvArray[3*_i + 1] = 0
+        #self._tslvArray[3*_i + 2] = 1
         if self._bufferAlloc:
           gl.glBindBufferARB   (gl.GL_ARRAY_BUFFER_ARB, self._buffer)
           gl.glBufferSubDataARB(gl.GL_ARRAY_BUFFER_ARB, 
                                 (sizeof(Vert)+4) * self._bufferAlloc,
                                 12*self._bufferAlloc, self._tslvArray )
-
-    else:
-      self._tslvArray[3*i + 0] = 0
-      self._tslvArray[3*i + 1] = 0
-      self._tslvArray[3*i + 2] = 1
-
+    #
+    # This code is misplaced!
+    #
+    # If no lights exist in the scene this needs to only be done once,
+    # not every render loop.  This is a waste of cpu cycles!
+    #else:
+    #  self._tslvArray[3*_i + 0] = 0
+    #  self._tslvArray[3*_i + 1] = 0
+    #  self._tslvArray[3*_i + 2] = 1

Modified: trunk/pysoy/src/bodies._bodies/Body.pxi
===================================================================
--- trunk/pysoy/src/bodies._bodies/Body.pxi     2008-02-26 17:43:24 UTC (rev 
990)
+++ trunk/pysoy/src/bodies._bodies/Body.pxi     2008-02-26 18:12:54 UTC (rev 
991)
@@ -309,7 +309,6 @@
     cdef gl.GLfloat  mtx[16]
     if not self._mesh :
       return
-    stdio.printf('Rendering..\n')
     self._coreGetModelview(mtx)
     gl.glPushMatrix()
     gl.glMultMatrixf(mtx)

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

Reply via email to