Looking for simple example with ground collision from height

Dear all,

I’m new to panda3d and I’m trying to build a simple cart moving on a terrain generated from a height field.
In the forum I found nice snippets to generate a terrain from a height field, and also how to use collider with terrain. However, the latter example uses a premade .egg file and I just don’t understand how to adapt it to my own terrain.
Here’s my code:

from panda3d.core import GeoMipTerrain
terrain = GeoMipTerrain("terrain")           # create a terrain
terrain.setHeightfield("height.png")   # set the height map
terrain.setColorMap("grass.jpg")          # set the colour map
terrain.setBruteforce(True)                    # level of detail
root = terrain.getRoot()                       # capture root
root.reparentTo(render)                        # render from root
root.setSz(1)                                 # maximum height
terrain.generate()                             # generate

Now the collision tutorial does the following:

floorcollider=terrain.find("**/floor_collide")
floorcollider.node().setIntoCollideMask(FLOOR_MASK)

Now I want to generate my own terrain and I’d like to set the floor collsion to my generated terrain “terrain”.
Could someone please tell me how? Probably I’m missing something trivial…

Thanks a lot,
Mathias

Collision example from here: [url]Panda3d Collisions made simple]

You probably shouldn’t use the collision system for terrains; that’d be rather inefficient. Instead, you could manually get the height at a certain location using terrain.getElevation(x, y), and adjust your player Z accordingly.