I have a blend map along with a heightmap that I am using to generate terrain in my game, but my terrain looks terrible because its being stretched across the entire terrain instead of being tiled so I was wondering how I could implement this behaviour.
Here is the relevant code:
class TerrainManager(object):
def init(self, app):
(self.world_sizex, self.world_sizey) = (10, 10)
(self.terrain_sizex, self.terrain_sizey) = (256, 256)
self.terrains = [[None for x in xrange(self.world_sizex)] for y in xrange(self.world_sizey)]
self.terrainposz = -5
def load_terrain(self, app, (x, y)):
heightmap_loc = "res/terrain/heightmap_%s_%s.png" % (x, y)
colormap_loc = "res/terrain/colormap_%s_%s.png" % (x, y)
if not os.path.isfile(heightmap_loc):
shutil.copy2("res/terrain/heightmap_default.png", heightmap_loc)
if not os.path.isfile(colormap_loc):
shutil.copy2("res/terrain/colormap_default.png", colormap_loc)
self.terrains[x][y] = GeoMipTerrain("worldTerrain")
self.terrains[x][y].setHeightfield(heightmap_loc)
self.terrains[x][y].setColorMap(colormap_loc)
root = self.terrains[x][y].getRoot()
root.setSz(1)
root.setPos(x * self.terrain_sizex, y * self.terrain_sizey, self.terrainposz)
self.terrains[x][y].generate()
root.reparentTo(app.render)
def unload_terrain(self, app, (x, y)):
self.terrains[x][y].getRoot().removeNode()
del self.terrains[x][y]
self.terrains[x][y] = None
, And here is Images to represent current and desired behaviour.