Author: ArcRiley Date: 2008-07-15 04:39:26 -0400 (Tue, 15 Jul 2008) New Revision: 1317
Modified: trunk/pysoy/examples/AnimBlock.py trunk/pysoy/include/soy.bodies.pxd trunk/pysoy/include/soy.scenes.pxd trunk/pysoy/include/soy.widgets.pxd trunk/pysoy/src/bodies/Camera.pym trunk/pysoy/src/scenes/Landscape.pym trunk/pysoy/src/scenes/Planar.pym trunk/pysoy/src/scenes/Scene.pym trunk/pysoy/src/widgets/Projector.pym Log: Ticket #929 : * rearranged widgets.Projector -> bodies.Camera -> scenes.Scene API * Landscape (and eventually Space, etc) can now set a different zFar * eventually support many other neat tricks, too! Modified: trunk/pysoy/examples/AnimBlock.py =================================================================== --- trunk/pysoy/examples/AnimBlock.py 2008-07-15 07:13:37 UTC (rev 1316) +++ trunk/pysoy/examples/AnimBlock.py 2008-07-15 08:39:26 UTC (rev 1317) @@ -10,8 +10,9 @@ lig.position = (-10.0,10.0,2.0) lava = soy.transports.File('media/lava.soy')['gimp'] -lava.animate=(.5,0,0) +lava.animate=(.125,0,0) dot3 = soy.transports.File('media/fieldstone-dot3.soy')['gimp'] +dot3.animate=(.25,0,0) colors = { 'Marble' : (soy.materials.Textured(colormap=lava, bumpmap=dot3), soy.materials.Material(ambient=soy.colors.black, Modified: trunk/pysoy/include/soy.bodies.pxd =================================================================== --- trunk/pysoy/include/soy.bodies.pxd 2008-07-15 07:13:37 UTC (rev 1316) +++ trunk/pysoy/include/soy.bodies.pxd 2008-07-15 08:39:26 UTC (rev 1317) @@ -17,6 +17,7 @@ # # $Id$ +cimport gl cimport ode cimport soy._internals @@ -85,11 +86,14 @@ cdef class Camera (Body) : cdef int _wire - cdef float _fovy cdef int _rpt cdef double _rtimes[16] + cdef gl.GLdouble _fovy + cdef gl.GLdouble _znear + cdef gl.GLdouble _zfar # WindowLoop functions - cdef void _project ( self ) #nogil + cdef void _project ( self, + gl.GLdouble ) #nogil cdef class Light (Body) : Modified: trunk/pysoy/include/soy.scenes.pxd =================================================================== --- trunk/pysoy/include/soy.scenes.pxd 2008-07-15 07:13:37 UTC (rev 1316) +++ trunk/pysoy/include/soy.scenes.pxd 2008-07-15 08:39:26 UTC (rev 1317) @@ -69,7 +69,9 @@ cdef double _prevTime cdef double _time # _coreloop methods - cdef void _render ( self ) + cdef void _render ( self, + gl.GLdouble, gl.GLdouble, + gl.GLdouble, gl.GLdouble ) cdef int _steps ( self ) nogil cdef void _callback ( self, ode.dGeomID, Modified: trunk/pysoy/include/soy.widgets.pxd =================================================================== --- trunk/pysoy/include/soy.widgets.pxd 2008-07-15 07:13:37 UTC (rev 1316) +++ trunk/pysoy/include/soy.widgets.pxd 2008-07-15 08:39:26 UTC (rev 1317) @@ -67,5 +67,3 @@ cdef class Projector (Widget) : cdef soy.bodies.Camera _camera cdef int _connected - cdef float _znear - cdef float _zfar Modified: trunk/pysoy/src/bodies/Camera.pym =================================================================== --- trunk/pysoy/src/bodies/Camera.pym 2008-07-15 07:13:37 UTC (rev 1316) +++ trunk/pysoy/src/bodies/Camera.pym 2008-07-15 08:39:26 UTC (rev 1317) @@ -37,6 +37,8 @@ *args, **keywords) : cdef int _i self._fovy = 45.0 + self._znear = 1.0 + self._zfar = 100.0 self.mass = 0 self._wire = wireframe self._rpt = 0 @@ -111,7 +113,7 @@ # WindowLoop Functions # - cdef void _project(self) : + cdef void _project(self, gl.GLdouble _aspect) : cdef gl.GLfloat _mtx[16] # # Bail now if in the abyss @@ -135,6 +137,8 @@ gl.glLineWidth (1) # # Now we apply an inverse matrix to translate to the Scene's origin + gl.glMatrixMode(gl.GL_MODELVIEW) + gl.glLoadIdentity() _mtx[0] = self._rotation[0] _mtx[1] = self._rotation[1] _mtx[2] = self._rotation[2] @@ -153,7 +157,7 @@ _mtx[15] = 1.0 gl.glLoadMatrixf(_mtx) gl.glTranslatef(-self._position[0], -self._position[1], -self._position[2]) - self._scene._render() + self._scene._render(self._fovy, _aspect, self._znear, self._zfar) # # Framerate calc self._rpt = (self._rpt + 1) % 16 Modified: trunk/pysoy/src/scenes/Landscape.pym =================================================================== --- trunk/pysoy/src/scenes/Landscape.pym 2008-07-15 07:13:37 UTC (rev 1316) +++ trunk/pysoy/src/scenes/Landscape.pym 2008-07-15 08:39:26 UTC (rev 1317) @@ -150,7 +150,13 @@ self._elementArray, gl.GL_STATIC_DRAW_ARB) - cdef void _render(self) : + cdef void _render(self, gl.GLdouble _fovy, gl.GLdouble _aspect, + gl.GLdouble _znear, gl.GLdouble _zfar) : + # + # Setup projection matrix + gl.glMatrixMode(gl.GL_PROJECTION) + gl.glLoadIdentity() + gl.gluPerspective(_fovy, _aspect, _znear, 1000.0) if self._buffer: py.PyMem_Free(self._elementArray) # The arrays are in Vram so lets free it in system mem py.PyMem_Free(self._vertArray) @@ -170,8 +176,9 @@ (self._heightmapTex._height-1) * 2 * 3, gl.GL_UNSIGNED_SHORT, <Face*> 0) gl.glBindBufferARB(gl.GL_ARRAY_BUFFER_ARB, 0) - - Scene._render(self) + # + # Render the rest of the scene normally + Scene._render(self, _fovy, _aspect, _znear, _zfar) """ TODO : LOD Modified: trunk/pysoy/src/scenes/Planar.pym =================================================================== --- trunk/pysoy/src/scenes/Planar.pym 2008-07-15 07:13:37 UTC (rev 1316) +++ trunk/pysoy/src/scenes/Planar.pym 2008-07-15 08:39:26 UTC (rev 1317) @@ -177,8 +177,14 @@ # General C functions # - cdef void _render(self) : - #gl.glDisable(gl.GL_DEPTH_BUFFER) + cdef void _render(self, gl.GLdouble _fovy, gl.GLdouble _aspect, + gl.GLdouble _znear, gl.GLdouble _zfar) : + # + # Setup projection matrix + gl.glMatrixMode(gl.GL_PROJECTION) + gl.glLoadIdentity() + gl.gluPerspective(_fovy, _aspect, _znear, _zfar) + self._material._coreBind() gl.glVertexPointer (3, gl.GL_FLOAT, 48, &self._verts[0].px) @@ -194,7 +200,7 @@ #gl.glPopMatrix() self._material._coreUnBind() - Scene._render(self) + Scene._render(self, _fovy, _aspect, _znear, _zfar) #gl.glEnable(gl.GL_DEPTH_BUFFER) Modified: trunk/pysoy/src/scenes/Scene.pym =================================================================== --- trunk/pysoy/src/scenes/Scene.pym 2008-07-15 07:13:37 UTC (rev 1316) +++ trunk/pysoy/src/scenes/Scene.pym 2008-07-15 08:39:26 UTC (rev 1317) @@ -123,9 +123,15 @@ return 1 - cdef void _render(self) : + cdef void _render(self, gl.GLdouble _fovy, gl.GLdouble _aspect, + gl.GLdouble _znear, gl.GLdouble _zfar) : cdef int _i # + # Setup projection matrix + gl.glMatrixMode(gl.GL_PROJECTION) + gl.glLoadIdentity() + gl.gluPerspective(_fovy, _aspect, _znear, _zfar) + # # Setup scene-level rendering gl.glClear(gl.GL_DEPTH_BUFFER_BIT) gl.glEnable(gl.GL_DEPTH_TEST) Modified: trunk/pysoy/src/widgets/Projector.pym =================================================================== --- trunk/pysoy/src/widgets/Projector.pym 2008-07-15 07:13:37 UTC (rev 1316) +++ trunk/pysoy/src/widgets/Projector.pym 2008-07-15 08:39:26 UTC (rev 1317) @@ -37,9 +37,8 @@ self._connected = 1 else : self._connected = 0 - self._znear = 1.0 - self._zfar = 100.0 + ############################################################################ # # C functions @@ -54,12 +53,7 @@ else : _aspect = (<float> self._width) / (<float> self._height) gl.glViewport(self._xpos, self._ypos, self._width, self._height) - gl.glMatrixMode(gl.GL_PROJECTION) - gl.glLoadIdentity() - gl.gluPerspective(self._camera._fovy, _aspect, self._znear, self._zfar) - gl.glMatrixMode(gl.GL_MODELVIEW) - gl.glLoadIdentity() - self._camera._project() + self._camera._project(_aspect) ############################################################################ # _______________________________________________ PySoy-SVN mailing list PySoy-SVN@pysoy.org http://www.pysoy.org/mailman/listinfo/pysoy-svn