Author: ArcRiley
Date: 2008-09-08 19:45:36 -0400 (Mon, 08 Sep 2008)
New Revision: 1357

Modified:
   trunk/pysoy/src/models/Liquid.pym
Log:
Ticket #962 :
  * added proper matrix translation code
  * still doesn't work


Modified: trunk/pysoy/src/models/Liquid.pym
===================================================================
--- trunk/pysoy/src/models/Liquid.pym   2008-09-08 19:24:04 UTC (rev 1356)
+++ trunk/pysoy/src/models/Liquid.pym   2008-09-08 23:45:36 UTC (rev 1357)
@@ -84,6 +84,40 @@
     cdef int                _i
     cdef ode.dReal*         _pos
     cdef float              _halfSize[3]
+    cdef gl.GLfloat         _mtx[16]
+    #
+    ######################################
+    #
+    # set model's matrix
+    #
+    _mtx[0]  = _body._rotation[0]
+    _mtx[1]  = _body._rotation[4]
+    _mtx[2]  = _body._rotation[8]
+    _mtx[3]  = 0.0
+    _mtx[4]  = _body._rotation[1]
+    _mtx[5]  = _body._rotation[5]
+    _mtx[6]  = _body._rotation[9]
+    _mtx[7]  = 0.0
+    _mtx[8]  = _body._rotation[2]
+    _mtx[9]  = _body._rotation[6]
+    _mtx[10] = _body._rotation[10]
+    _mtx[11] = 0.0
+    _mtx[12] = _body._position[0]
+    _mtx[13] = _body._position[1]
+    _mtx[14] = _body._position[2]
+    _mtx[15] = 1.0
+    #
+    ######################################
+    #
+    # save current matix before setting it
+    #
+    gl.glPushMatrix()
+    gl.glMultMatrixf(_mtx)
+    #
+    ######################################
+    #
+    # render liquid surface and bottom
+    #
     _pos = _body._position
     _halfSize[0] = self._size[0]/2.0
     _halfSize[1] = self._size[1]/2.0
@@ -100,7 +134,16 @@
     self._renderBottom()
     gl.glEnable(gl.GL_DEPTH_TEST)
     #
-    #RENDER BODIES
+    ######################################
+    #
+    # return to camera matrix
+    #
+    gl.glPopMatrix()
+    #
+    ######################################
+    #
+    # render each body inside the liquid
+    #
     gl.glEnable(gl.GL_FOG)
     gl.glEnableClientState(gl.GL_FOG_COORDINATE_ARRAY_EXT)
     gl.glFogi(gl.GL_FOG_MODE, gl.GL_LINEAR)
@@ -109,8 +152,6 @@
     gl.glFogf(gl.GL_FOG_END, pos[1] - _halfSize[1])
     gl.glHint(gl.GL_FOG_HINT, gl.GL_NICEST)
     gl.glFogi(gl.GL_FOG_COORDINATE_SOURCE_EXT, gl.GL_FOG_COORDINATE_EXT)
-    gl.glPushMatrix()
-    gl.glTranslatef(-pos[0],-pos[1], -pos[2])
     #
     # We need not _iterStart here since _bodies is already iterating via Scene
     for _i from 0 <= _i < _body._scene._bodies._current :
@@ -123,15 +164,27 @@
         (<soy.bodies.Body> 
          _body._scene._bodies._list[_i])._model._render(
           (<soy.bodies.Body> _body._scene._bodies._list[_i]))
-    gl.glPopMatrix()
     gl.glDisableClientState(gl.GL_FOG_COORDINATE_ARRAY_EXT)
     gl.glDisable(gl.GL_FOG)
     #
-    #RENDER SURFACE
+    ######################################
+    #
+    # save current matix before setting it
+    #
+    gl.glPushMatrix()
+    gl.glMultMatrixf(_mtx)
     self._material._coreBind()
     self._renderSurf()
     self._material._coreUnBind()
     gl.glDisable(gl.GL_STENCIL_TEST)
+    #
+    ######################################
+    #
+    # return to camera matrix
+    #
+    gl.glPopMatrix()
+    #
+    ######################################
 
 
   cdef void _renderSurf(self) :

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

Reply via email to