Various n00b questions

Hi All,

I’m trying to get to grips with panda3d. I’m using it in Ubuntu 64bit and scripting with python (of course). I have a number of questions/issues that I can’t seem to easily find answers for.

I’m loading terrains using heightfields from png files, which I generated using L3DT. Doing one piece of terrain and texturing it with one texture works fine. Now, if I want to make a large terrain, it will require either, using multiple heightmaps, each with their own texture OR using an enormous heightmap but with multiple textures (in order for decent detail). I’m assuming trying to use very large heightmaps / textures is bad in general.

  1. So my first question is, how do I stitch them together? Can GeoMipMap do this? Do I have to specify the coordinates in 3D space manually for each terrain block?

  2. Say I have a terrain made up of grass/water/rock/sand. Can I use small textures and use a sort of masked array to only texture some areas with a given texture?

  3. I made a terrain using a 1024x1024 heighmap. I didn’t scale it in the code, hence the coordinates in the X-Y plane goes from 0-1024 right? (or maybe not?) I also loaded another model and I make it move at 100 units per second. This all works fine but my model jumps back and forth rapidly. I can’t figure out why this is happening. I’m updating the model’s coordinates directly using self.myModel.setPos() at every frame.

Any help will be greatly appreciated. I’m having some other issues too but I suppose these are teething issues due to my lack of Panda knowledge.

Sounds something like the way I’m rendering terrain for my RTS.

Here’s what I have:

    def setMultiTexture(self, alpha, texfile, alphaPriority=0, texfilePriority=0):
        self.it += 1
        
        colortex = loader.loadTexture(texfile)
        alphatex = loader.loadTexture(alpha)
        
        ts = TextureStage('ts_' + str(self.it))
        ts.setSavedResult(True)
        ts.setMode(TextureStage.MReplace)
        ts.setSort(texfilePriority)
        self.terrainRoot.setTexture(ts, colortex)

        
        ts2 = TextureStage('ts2_' + str(self.it))
        ts2.setSort(alphaPriority)


        ts2.setCombineRgb(TextureStage.CMInterpolate,
          TextureStage.CSLastSavedResult,TextureStage.COSrcColor,
          TextureStage.CSPrevious,TextureStage.COSrcColor,
          TextureStage.CSTexture,TextureStage.COSrcAlpha,
          ) 
        

        self.terrainRoot.setTexture(ts2, alphatex)

        self.terrainRoot.setTexScale(ts, 30, 30)

OK, so I figured out why the camera was jumping like that. It was due to the fact that my camera update task wasn’t called directly after my model update task. I now call them one after the other so camera doesn’t jump anymore.

That out of the way, I’m still at a loss about the geomipmap terrain coordinates. How does its coordinate system work? Does it run from 0-1 or is it 0 to number of pixels in the png image or something else? How does the scale affect this? I can’t seem to find these answers in the documentation.