Advice needed on Terrain

Hi, I need some advice on creating some Terrain.

I want to create a Terrain, with different textures in it.

What would be easiest?

Case 1:
Generating the terrain with GeoMipTerrain + Heightmap, and then assign the textures to the terrain in some way or another.

Case 2:
Creating the terrain and apply textures in Max / Maya, and then export it as egg. and load it into Panda.

A couple of related questions:

Is it harder / easier to do collision detection between models and terrain in the above cases?

Can shaders be applied to the terrain in both cases?

Are there big performance differences between the two cases?

Does someone have a working link to the “Nature Demo”? I was looking for a way to do multitextureing with GeoMipTerrain here in the forums, and as i understand, there should be a code sample on how to achieve this in this demo. Unfortunately the link is dead.

If the techniques I propose here is way off what one would normally do to render the terrain in Panda, please tell me :wink:

Collision detection will be easier with the GeoMipTerrain way, since you can then get elevation info from the terrain directly instead of casting a ray.
Applying shaders is just as easy using both ways.
The performance benefit will probably be when using GeoMipTerrain, since it has LOD. If you don’t like its LOD, you can always configure it to do bruteforce rendering, which will get you the same thing as you would have in Max / Maya (so there’s always a benefit using heightmaps/GeoMipTerrain)

There’s also something similar to Nature Demo, I believe, called Yarr / Yet Another Roaming Ralph (search the forums).

Thankyou for a quick reply.

I found the Yarr application, and had a look at the code. It explains a lot about practical multitexturing that I had wondered how to achieve with the terrain.

I did have a look in the Panda Manual about multitexturing, but I didn’t quite grasp it enough to apply it to the terrain. After having a look at the code, I had a much better picture of how to apply it.

I’ll have a go at coding some GeoMipTerrain now. :smiley:

GeoMipTerrain wins…

I actually tried generating a large egg terrain with collisions and it would crash the egg loader. Really GeoMipTerrain wins hands down when you add the LODing part.

So is there anyway to get collisions with terrain other than just setting a collision mask?

Hey. Ive been playing with geomipterrain for a bit now and have found a couple of “issues”.

  1. get_elevation does not seem to account for any scaling applied
  2. I maybe be doing it wrong, or it may be related to #1 but I can’t seem to get a floor traverser to work on a scaled geomipterrain.

I got around 1 (sort of) by extending the class to behave how I would want it to. (yeah for inheritence). But now i’m having issues with #2. I see more or less nothing but good said about geomipterrain on the forums which makes me feel like I must be using it way wrong.

a bit of code:

class ScalingGeoMipTerrain(GeoMipTerrain):
def init(self, name=None):
GeoMipTerrain.init(self,name)
# these units are all in “Panda” space units. This class takes care of
# scaling GeoMipTerrain data in and out
self.Sx = 1
self.Sy = 1
self.Sz = 1
self.Xoffset = 0.0
self.Yoffset = 0.0
self.Zoffset = 0.0
def getElevation(self,scaledX, scaledY):
rawX = round(scaledX/self.Sx,0) # get into integer of terrain xy grid
rawY = round(scaledY/self.Sy,0)
rawZ = GeoMipTerrain.getElevation(self,rawX,rawY)
return self.Sz*rawZ + self.Zoffset
def setSx(self,val):
self.Sx = val
self.getRoot().setSx(val)
def setSy(self,val):
self.Sy = val
self.getRoot().setSy(val)
def setSz(self,val):
self.Sz = val
self.getRoot().setSz(val)
def setScale(self,valX,valY,valZ):
self.Sx = valX
self.Sy = valY
self.Sz = valZ
self.getRoot().setScale(valX, valY, valZ)

node update task

def updateAvnp(self,task):
dt = globalClock.getDt() self.avnp.setPos(self.avnp,WALKRATEself.Kstrafedt,WALKRATEself.Kwalkdt,0)
self.avnp.setH(self.avnp,TURNRATEself.Kturndt)
x,y,z = self.avnp.getPos()
hdg = self.avnp.getH()

  1. This is intended behaviour. The elevation returned is in the terrain’s coordinate space.
  2. You don’t need to use a collision traverser on the terrain. You can just use the Z value of the terrain at a given point to adjust the Z of your objects or character.

rdb, thanks for the reply. Is it also intended/expected behavior that the terrain Z scale is always in the range [0,1]? Am I doing something wrong setting the height field?
Using the Z component is exactly what I’m doing now. It seemed to make sense to do it that way, but then I started reading about collision detection and thought maybe that was the preferred way. Although it also says to minimize the number of collision handlers, so…confused :slight_smile:

  • I also have issues when I scale X and Y in that the returned Z
    seems to be quantized to the nearest Z…as I write this I’m wondering if thats because I’m imposing the int() on the x,y inputs to terrain…something to try

All Z values in the terrain’s coordinate space are in the 0-1 range. Use getRelativePoint or something like that to transform the values into a different coordinate space.

get_elevation takes floating-point values and interpolates, so the quantisation is probably coming from your use of int().

Can you post where you found this? I can’t seem to find a working link.

edit- the link in the yarr thread worked when I tried it this evening. Nevermind. However, the link to the updated yarr.py is broken. :frowning: