def get_heightmap_tex(self, size, filename=None): """Generate texture of map """ mod = self.world_size / size image = PNMImage(size, size) for x in xrange(size): for y in xrange(size): px = x * mod py = y * mod height = self[px, py] color = height / 50 r = 0 g = 0 b = 0 if color > 255: color = 255 if color < 0: color = abs(color) b = color else: g = color image.setPixel(x, y, (r, g, b)) if filename != None: image.write(filename) #for x in xrange(-1, 2): #for y in xrange(-1, 2): #image.setPixel(int(world.chunks_map.charX)+x, int(world.chunks_map.charY)+y, (255, 0, 0)) texture = Texture() texture.load(image) return texture
def get_heightmap_tex(self, size, filename = None): """Generate texture of map """ mod = self.world_size / size image = PNMImage(size, size) for x in xrange(size): for y in xrange(size): px = x * mod py = y * mod height = self[px, py] color = height / 50 r = 0 g = 0 b = 0 if color > 255: color = 255 if color < 0: color = abs(color) b = color else: g = color image.setPixel(x, y, (r, g, b)) if filename != None: image.write(filename) #for x in xrange(-1, 2): #for y in xrange(-1, 2): #image.setPixel(int(world.chunks_map.charX)+x, int(world.chunks_map.charY)+y, (255, 0, 0)) texture = Texture() texture.load(image) return texture
def get_map_2d_tex(self, map2d, factor=1): """Generate texture for map2d, factor - for size [size / factor] """ size = map2d.size / factor image = PNMImage(size, size) for x in xrange(size): for y in xrange(size): px = x * factor py = y * factor if map2d[(px, py)] <= map2d.water_z: image.setPixel(x, y, (0, 0, 100)) else: image.setPixel(x, y, (0, 100, 0)) texture = Texture() texture.load(image) return texture
def get_map_2d_tex(self, map2d, factor = 1): """Generate texture for map2d, factor - for size [size / factor] """ size = map2d.size / factor image = PNMImage(size, size) for x in xrange(size): for y in xrange(size): px = x * factor py = y * factor if map2d[(px, py)] <= map2d.water_z: image.setPixel(x, y, (0, 0, 100)) else: image.setPixel(x, y, (0, 100, 0)) texture = Texture() texture.load(image) return texture
def generate_map_texture(map_tree, factor): map_world = map_tree.map3d size = map_world.size / factor image = PNMImage(size, size) #image.fill(0,0,0) for x in xrange(size): for y in xrange(size): px = x * factor py = y * factor if map_world[(px, py)] <= map_world.water_z: image.setPixel(x, y, (0, 0, 100)) else: image.setPixel(x, y, (0, 100, 0)) char_x, char_y, char_z = map_tree.coords char_x = char_x / factor char_y = char_y / factor image.setPixel(char_x, char_y, (255, 0, 0)) #if factor>2: #image.setPixel(char_x, char_y, (255, 0, 0)) #else: #for x in xrange(char_x - 1, char_x+2): #cx = x #if cx > size-1: cx = size-1 #if cx < 0: cx = 0 #for y in xrange(char_y - 1, char_y+2): #cy = y #if cy > size-1: cy = size-1 #if cy < 0: cy = 0 #image.setPixel(cx, cy, (255, 0, 0)) texture = Texture() texture.load(image) return texture
def get_map_3d_tex(self, size, filename=None, charPos=None): """Generate texture of map """ mod = self.world_size / size image = PNMImage(size, size) for x in xrange(size): for y in xrange(size): px = x * mod py = y * mod height = self[px, py] if height <= 0: color = (abs(height) / 50) + 50 if color > 255: color = 255 image.setPixel(x, y, (0, 0, 255 - color)) else: if height <= self.config.low_mount_level[1]: color = height / 20 r = 0 g = 50 + color b = 0 image.setPixel(x, y, (r, g, b)) elif height > self.config.low_mount_level[1]: color = height / 50 r = color g = color b = color if r > 255: r = 255 if g > 255: r = 255 if b > 255: b = 255 image.setPixel(x, y, (r, g, b)) if filename != None: image.write(filename) if charPos != None: charX, charY = charPos for x in xrange(-1, 2): for y in xrange(-1, 2): image.setPixel( int(charX / mod) + x, int(charY / mod) + y, (255, 0, 0)) texture = Texture() texture.load(image) return texture
def get_map_3d_tex(self, size, filename = None, charPos = None): """Generate texture of map """ mod = self.world_size / size image = PNMImage(size, size) for x in xrange(size): for y in xrange(size): px = x * mod py = y * mod height = self[px, py] if height <= 0: color = (abs(height) / 50) + 50 if color > 255: color = 255 image.setPixel(x, y, (0, 0, 255-color)) else: if height <= self.config.low_mount_level[1]: color = height / 20 r = 0 g = 50+color b = 0 image.setPixel(x, y, (r, g, b)) elif height > self.config.low_mount_level[1]: color = height / 50 r = color g = color b = color if r > 255: r = 255 if g > 255: r = 255 if b > 255: b = 255 image.setPixel(x, y, (r, g, b)) if filename != None: image.write(filename) if charPos != None: charX, charY = charPos for x in xrange(-1, 2): for y in xrange(-1, 2): image.setPixel(int(charX/mod)+x, int(charY/mod)+y, (255, 0, 0)) texture = Texture() texture.load(image) return texture