Coordinated terrain texturing

Hi guys,

(It’s my first post so a bit of boring introduction =P)
Tough I met Panda3D some long time ago, I never really started a project with it. But now I did and as all newbies, I’m encountering some design problems.

Short, what I want to create is a game with elements from the civilization series and the stronghold series.
I started with creating the part where the game-map is created. Like in civ, this map consists of hexagonal tiles. First I’ve created a script that returns a python dictionary which represent the randomized map with all the tiles and their ’ tile-data ’ ( such as appearance: desert, grass,…). The other script is the panda-script which takes this dictionary, loops trough it while loading the correct models according to the tiledata.

#### Map Creation ####
import random
#from sys import exc_clear
# Initial map #

class MMap():
    def newWorld(self):
        print 'creating new map' = {}
        self.wsizex = input("World size x : ")
        self.wsizey = input("World size y : ")
        self.wsize = self.wsizex*self.wsizey
        print self.wsize
        self.tiles = []        
        k = 0
        while k < self.wsize:
            k = k + 1
        print self.tiles
        for k in self.tiles:
  [self.tiles[k]] = ["TileData", "More TileData","Even More TileData"]
# Definition of the 'brush'-functions #
    def circle(self,tile):
        targettiles = []
        targettiles.append(tile - self.wsizex)
        targettiles.append(tile - self.wsizex + 1 )
        targettiles.append(tile - 1)
        targettiles.append(tile + 1)        
        targettiles.append(tile + self.wsizex)
        targettiles.append(tile + self.wsizex + 1)
        print targettiles
        for k in targettiles[:]:
            if int(k+0) < 0:
                print k
            if int(k+0) >= self.wsize:
                print k
        return targettiles
# Tile Randomisation #
#Dataformat:[  0   /   1  ,   0    /    1   /     2     /    3   ,  0 /    1   ,   0  /   1  ]
#          [ water / land , desert / plains / grassland / tundra , no / forest , flat / hill ]
    def tilerandom(self):
        print 'customising tiles'
        self.landtiles = self.tiles
#        targettile = self.landtiles[random.randint(0,len(self.landtiles))]
        colorlist = [self.deserttiles,self.plaintiles,self.grasstiles,self.tundratiles]
        while len(self.landtiles) != 0:
            targettile = random.choice(self.landtiles)
            color = random.choice(colorlist)
            affectedtiles = color(targettile)
            for k in affectedtiles:
                except ValueError:
#            print self.landtiles
    def deserttiles(self,deserttile):
        print 'creating desert tiles'
        deserttiles =
        print deserttiles
        for k in deserttiles:
            datalist =[k]
            datalist[1] = 0
            datalist[2] = 0
        return deserttiles

    def plaintiles(self,plaintile):
        print 'creating plain tiles'
        forestchance = [0,0,1]
        plaintiles =
        print plaintiles
        for k in plaintiles:
            datalist =[k]
            datalist[1] = 1
            datalist[2] = random.choice(forestchance)
        return plaintiles

    def grasstiles(self,grasstile):
        print 'creating grass tiles'
        forestchance = [0,1]
        grasstiles =
        print grasstiles
        for k in grasstiles:
            datalist =[k]
            datalist[1] = 2
            datalist[2] = random.choice(forestchance)
        return grasstiles

    def tundratiles(self,tundratile):
        print 'creating tundra tiles'
        forestchance = [0,0,0,1]
        tundratiles =
        print tundratiles
        for k in tundratiles:
            datalist =[k]
            datalist[1] = 3
            datalist[2] = random.choice(forestchance)
        return tundratiles

# Executions #

#Map = MMap()

import direct.directbase.DirectStart
from direct.showbase import DirectObject
import World


Map = World.MMap()

colors = [["Models/deserttile.x"],["Models/plaintile.x","Models/plaintile-forest.x"],

tiles = []

for k in
    print k
    datalist =[k]
    color = datalist[1]
    modellist = colors
    color = datalist[2]
    model = modellist
    tiles[k] = loader.loadModel(model)
    rowchecker = (int(k / Map.wsizex)) % 2 == 0
    print tiles[k].getPos()


This code gives me the randomized map I wanted. But now I want to move on to the next step: graphically enhance the world map. In Civ 5 all the tiles’ textures blend a bit into each other… the grass from a grasstiles continues a bit over to the next tiles… I hope you understand what I mean. (

I don’t really know how to do this. If I just give each tile a separate model and texture, I don’t think I can make the tiles blend. So what do I do? Take a large plane, cover all the tiles and ‘paint’ the plane with the different textures according to the tile coordinates ?

Ps.: Do you want me to somehow post the tile-models I use to represent the different tiles?

As i probabbly should have done before starting a new thread, i searched the forums and found this similar topic, altough i dont really know how to use shaders, as stated in the thread as a possible solution. Also the generated terrain map is totally random each time the game/script runs, so actually i’m looking for way to dynamically create a new terrain texture…

[url]Mapping textures]