Author: ArcRiley Date: 2008-07-16 00:40:54 -0400 (Wed, 16 Jul 2008) New Revision: 1323
Modified: trunk/pysoy/examples/LandScape.py trunk/pysoy/src/scenes/Landscape.pym Log: Ticket #929 : * fixed dGeomHeightfieldDataBuildByte call * changed default height to 16 * removed example setting non-default scales Modified: trunk/pysoy/examples/LandScape.py =================================================================== --- trunk/pysoy/examples/LandScape.py 2008-07-16 03:11:40 UTC (rev 1322) +++ trunk/pysoy/examples/LandScape.py 2008-07-16 04:40:54 UTC (rev 1323) @@ -6,7 +6,7 @@ ### Start Heightmap Code heightTex = soy.transports.File('media/Heightmap.soy')['gimp'] sleep(2) # HACK: this will wait while transportloop does his stuff -heightScene = soy.scenes.Landscape(heightTex,soy.materials.Material(),height=100, width=heightTex.size[0], depth=heightTex.size[1]) +heightScene = soy.scenes.Landscape(heightTex,soy.materials.Material(),height=16) #heightScene = soy.scenes.Scene();# with normal scene, everything is peachy ### Start PySoy Code (Excerpt from pysoy-primer.py) # Initialize a window Modified: trunk/pysoy/src/scenes/Landscape.pym =================================================================== --- trunk/pysoy/src/scenes/Landscape.pym 2008-07-16 03:11:40 UTC (rev 1322) +++ trunk/pysoy/src/scenes/Landscape.pym 2008-07-16 04:40:54 UTC (rev 1323) @@ -30,8 +30,12 @@ # Python functions # - def __cinit__(self, soy.textures.Texture heightmap,soy.materials.Material mat, \ - detail = 1, width=1024, depth=1024, height=1024, position=(0, 0, 0), *args, **kw) : + def __cinit__(self, + soy.textures.Texture heightmap, + soy.materials.Material mat, + detail = 1, width=1024, depth=1024, height=16, + position=(0, 0, 0), + *args, **kw) : assert isinstance(heightmap, soy.textures.Texture) or heightmap._chans != 1, \ "Heightmap must be of type soy.textures.Texture and 1 channel, not "+str(heightmap._chans) assert type(position[0]) == int or type(position[1]) == int or \ @@ -47,11 +51,16 @@ self._vertArray = <Vert *> py.PyMem_Malloc(heightmap._width*heightmap._height*16*4) self._elementArray = <Face *> py.PyMem_Malloc(sizeof(Face)*(heightmap._width-1)*(heightmap._height-1)*2) ode.dGeomHeightfieldDataBuildByte(self._heightmapID, - <unsigned char*> heightmap._texels, 0, - self._width, self._width, - <int> self._width, - <int> self._depth, - 1, 0, 1, 0) + <unsigned char*> heightmap._texels, + 0, # copy data? + self._width, + self._depth, + self._heightmapTex._width, + self._heightmapTex._height, + 1.0, # scale + 0.0, # offset + 1.0, # thickness + 0) # wrapped self._heightmap = ode.dCreateHeightfield(self._spaceID, self._heightmapID, 1) #the ode heightmap self._heightmapTex = heightmap self._createArrays() @@ -96,13 +105,13 @@ self._vertArray[_offset].px = <float> _j / \ self._heightmapTex._width * self._width self._vertArray[_offset].py = self._heightmapTex._texels[_offset] \ - /255.0 * self._height + / 255.0 * self._height self._vertArray[_offset].pz = <float> _i / \ self._heightmapTex._height * self._depth #all below need to be calculated CORRECTLY! - self._vertArray[_offset].tx = 0 # _j * texture scale - self._vertArray[_offset].ty = 0 # _i * texture scale - self._vertArray[_offset].tz = 0 # obtained from another texture map + self._vertArray[_offset].tx = _j # * texture scale + self._vertArray[_offset].ty = _i # * texture scale + self._vertArray[_offset].tz = self._heightmapTex._texels[_offset]/255.0 # # Normals and tangents calculated second because they depend on position for _i from 0 <= _i < self._heightmapTex._height : @@ -232,20 +241,20 @@ # # Setup projection matrix cdef int _i - stdio.printf("_render\n"); + #stdio.printf("_render\n"); gl.glEnable(gl.GL_DEPTH_TEST) gl.glEnable(gl.GL_LIGHTING) gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, self._ambient._rgba) # # Turn on each light, keep it's iteration locked against mod until done self._lights._iterStart() - stdio.printf("_render1a\n"); + #stdio.printf("_render1a\n"); for _i from 0 <= _i < self._lights._current : - stdio.printf("_render1b Index: %d\n",_i); + #stdio.printf("_render1b Index: %d\n",_i); # This is a quick hack (gl.GL_LIGHT0 + _i) (<soy.bodies.Light> self._lights._list[_i])._on(gl.GL_LIGHT0 + _i) - stdio.printf("_render1c\n"); + #stdio.printf("_render1c\n"); gl.glMatrixMode(gl.GL_PROJECTION) gl.glLoadIdentity() gl.gluPerspective(_fovy, _aspect, _znear, 1000.0) _______________________________________________ PySoy-SVN mailing list PySoy-SVN@pysoy.org http://www.pysoy.org/mailman/listinfo/pysoy-svn