Author: DavidCzech
Date: 2008-07-17 15:00:48 -0400 (Thu, 17 Jul 2008)
New Revision: 1326

Modified:
   trunk/pysoy/src/scenes/Landscape.pym
Log:
Ticket 929 : * Fixed Tangent Calculation


Modified: trunk/pysoy/src/scenes/Landscape.pym
===================================================================
--- trunk/pysoy/src/scenes/Landscape.pym        2008-07-16 04:59:17 UTC (rev 
1325)
+++ trunk/pysoy/src/scenes/Landscape.pym        2008-07-17 19:00:48 UTC (rev 
1326)
@@ -16,7 +16,7 @@
 #  along with this program; if not, see http://www.gnu.org/licenses
 #
 # $Id$
-
+cimport stdlib
 cdef class Landscape (Scene) :
   ''' Landscape Scene
 
@@ -97,6 +97,7 @@
     cdef int _i, _j, _currentLoop, _offset
     cdef unsigned short _a, _b, _c, _d
     cdef double _v1[3], _v2[3], _normal[3], _normal2[3], _length
+    cdef double _u[3]
     #
     # Calculate positions and texcoords first
     for _i from 0 <= _i < self._heightmapTex._height :
@@ -189,9 +190,18 @@
         self._vertArray[_offset].nx = _normal[0]
         self._vertArray[_offset].ny = _normal[1]
         self._vertArray[_offset].nz = _normal[2]
-        self._vertArray[_offset].ux = 1 # Up
-        self._vertArray[_offset].uy = 0
-        self._vertArray[_offset].uz = 0
+        # q = 90 degrees in the x direction
+        # y' = y*cos q - z*sin q
+        # z' = y*sin q + z*cos q
+        # x' = x
+        #Rotate the whole normal, returns tangent
+        
+        _u[0] = self._vertArray[_offset].nx
+        _u[1] = (_normal[1]-self._vertArray[_offset].py) * stdlib.cosf(90) - 
(_normal[2]-self._vertArray[_offset].pz) * stdlib.sinf(90) + 
self._vertArray[_offset].py
+        _u[2] = (_normal[1]-self._vertArray[_offset].py) * stdlib.cosf(90) + 
(_normal[2]-self._vertArray[_offset].pz) * stdlib.sinf(90) + 
self._vertArray[_offset].pz
+        self._vertArray[_offset].ux = _u[0]
+        self._vertArray[_offset].uy = _u[1]
+        self._vertArray[_offset].uz = _u[2]
     
     #and finally, set up the face array to make all of the triangles
     _currentLoop = 0
@@ -313,4 +323,4 @@
  in each group give the most radical angles the highest priority - so a steep 
angled triangle would be D in the above 
  example
  er, sorry, the steepest would be A
-"""
+"""
\ No newline at end of file

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

Reply via email to