Panda Bullet

Here is my code, which will take a height map of any size, and set Pandas terrain to match that of Bullet.

#Set some var's:
        self.height = 250
        self.heightMap = "gfx/terrain/height.png"

        self.heightSize = PNMImage(self.heightMap).getXSize()

        self.terrain = GeoMipTerrain("terrain")
        self.terrain.setHeightfield(self.heightMap)

        self.terrain.setBlockSize(128)
        self.terrain.setNear(0)
        self.terrain.setFar(1024)
        self.terrain.setFocalPoint(base.camera)

        self.root = self.terrain.getRoot()
        self.root.reparentTo(render)
        self.root.setScale(1,1,self.height)
        self.root.setH(90)
        self.root.setPos(self.heightSize/2,-(self.heightSize/2),0)

        #Texture:
        self.textureStage = TextureStage("Texture Stage")
        self.texture = loader.loadTexture('gfx/terrain/texture.jpg')
        self.detailMap = loader.loadTexture('gfx/terrain/detailmap.jpg')

        self.root.setTexture(self.texture)
        self.root.setTexture(self.textureStage,self.detailMap)
        self.root.setTexScale(self.textureStage,300,300)

        self.terrain.generate()

        #Heightfield
        self.xform = TransformState.makePos((0,0,self.height/2))

        self.shape = BulletHeightfieldTerrainShape(self.heightMap,self.height,BulletHeightfieldTerrainShape.ZUp)
        self.shape.setUseDiamondSubdivision(True)

        self.body = BulletRigidBody(0,self.xform,self.shape)

        physics.world.addRigidBody(self.body)