Author: JonNeal
Date: 2008-03-21 23:15:03 -0400 (Fri, 21 Mar 2008)
New Revision: 1197

Added:
   trunk/pysoy/src/scenes/Landscape.pxi
Modified:
   trunk/pysoy/src/scenes/Planar.pxi
   trunk/pysoy/src/scenes/soy.scenes.pxd
   trunk/pysoy/src/scenes/soy.scenes.pyx
Log:
Ticket #929: Started adding soy.scenes.Landscape, I also fixed up some of the 
Planar code to make it look nicer. :-)


Copied: trunk/pysoy/src/scenes/Landscape.pxi (from rev 1193, 
trunk/pysoy/src/stubs/Stub.pxi)
===================================================================
--- trunk/pysoy/src/scenes/Landscape.pxi                                (rev 0)
+++ trunk/pysoy/src/scenes/Landscape.pxi        2008-03-22 03:15:03 UTC (rev 
1197)
@@ -0,0 +1,45 @@
+# PySoy's soy.scenes.Landscape
+#
+# Copyright (C) 2006,2007,2008 PySoy Group
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU Affero General Public License as published
+#  by the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU Affero General Public License for more details.
+#
+#  You should have received a copy of the GNU Affero General Public License
+#  along with this program; if not, see http://www.gnu.org/licenses
+#
+# $Id$
+
+
+cdef class Landscape (Scene) :
+  ''' Landscape Scene
+
+    This is a scene based on a heightmap facing up in 
+    the direction of gravity.
+  '''
+  def __cinit__(self, heightmap, *args, **kw) :
+    if not isinstance(soy.textures.Texture, heightmap) or heightmap._chans != 
1 :
+      raise TypeError('heightmap must be of type soy.textures.Texture and 1 
channel.')
+    
+    self._heightmapID = ode.dGeomHeightfieldDataCreate()
+    ode.dGeomHeightfieldDataBuildByte(self._heightmapID,
+                                      <unsigned char*> heightmap._texels,0, 
heightmap._width,
+                                      heightmap._depth, heightmap._width,
+                                      heightmap._depth, 1, 0, 1,
+                                      0)
+    self._heightmap = ode.dCreateHeightfield(self._spaceID, self._heightmapID, 
0)
+
+
+  def __delalloc__(self) :
+    ode.dGeomHeightfieldDataDestroy(self._heightmapID)
+
+
+  cdef void _render(self) :
+    pass

Modified: trunk/pysoy/src/scenes/Planar.pxi
===================================================================
--- trunk/pysoy/src/scenes/Planar.pxi   2008-03-22 02:08:59 UTC (rev 1196)
+++ trunk/pysoy/src/scenes/Planar.pxi   2008-03-22 03:15:03 UTC (rev 1197)
@@ -96,10 +96,12 @@
       self._material = soy.materials.Material()
     else:
       raise TypeError('Must provide an instance of soy.materials.Material')
-    
+
+
   def __delalloc__(self) :
     ode.dGeomDestroy(self._planeID)
 
+
   cdef void _render(self) :
     #gl.glDisable(gl.GL_DEPTH_BUFFER)
     self._material._coreBind()
@@ -119,6 +121,8 @@
     self._material._coreUnBind()
     Scene._render(self)
     #gl.glEnable(gl.GL_DEPTH_BUFFER)
+
+
   property material :
     def __get__(self) :
       return self._material
@@ -127,6 +131,7 @@
         raise TypeError('Must provide an instance of soy.materials.Material')
       self._material = value
 
+
   property gravity :
     '''Scene gravity
 
@@ -135,6 +140,7 @@
     forces which are often used for gravity in larger scenes.
 
     Takes a (x,y,z) tuple of numbers, defaults to (0.0, 0.0, 0.0)
+    An offset for the Y axis may be provided by a fourth value in the tuple.
     '''
     def __get__(self) :
       cdef ode.dVector3 grav

Modified: trunk/pysoy/src/scenes/soy.scenes.pxd
===================================================================
--- trunk/pysoy/src/scenes/soy.scenes.pxd       2008-03-22 02:08:59 UTC (rev 
1196)
+++ trunk/pysoy/src/scenes/soy.scenes.pxd       2008-03-22 03:15:03 UTC (rev 
1197)
@@ -71,10 +71,14 @@
   cdef int                        _steps          ( self )
   cdef void                       _updateTime     ( self )
   cdef void                       _callback       ( self, ode.dGeomID, 
ode.dGeomID )
+
+cdef class Landscape (Scene) :
+  cdef ode.dHeightfieldDataID     _heightmapID
+  cdef ode.dGeomID                _heightmap
   
 cdef class Planar (Scene) :
   cdef ode.dGeomID                _planeID
-  cdef float                       _offset
+  cdef float                      _offset
   cdef soy.materials.Material     _material
   cdef Vert                       _verts[60]
   cdef Face                       _faces[40]

Modified: trunk/pysoy/src/scenes/soy.scenes.pyx
===================================================================
--- trunk/pysoy/src/scenes/soy.scenes.pyx       2008-03-22 02:08:59 UTC (rev 
1196)
+++ trunk/pysoy/src/scenes/soy.scenes.pyx       2008-03-22 03:15:03 UTC (rev 
1197)
@@ -41,3 +41,4 @@
 include "_runField.pxi"
 include "Scene.pxi"
 include "Planar.pxi"
+include "Landscape.pxi"

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

Reply via email to