def makeVCubes(self):
     '''This makes the volume cubes without posturization.'''
     for y in xrange(self.ysize):
         for x in xrange(self.xsize):
             (r,g,b) = self.pixels[x,y]
             avg = int((r + g + b) / 3)
             cubes.makecolumn(caller,x,y,0,avg,self.cubesize)
 def makeVCubesP(self, pixels, base):
     '''This makes the volume cubes with posturization.'''
     #fills in base... someday
     #cubes.makecolumn(caller,x,y,0,self.xsize, self.ysize,base,self.cubesize)
     
     for y in xrange(self.ysize):
         for x in xrange(self.xsize):
             relheight = pixels[x,y]
             if relheight == 0:
                 pass
             else:
                 cubes.makecolumn(caller,x,y,base,relheight+base,self.cubesize)
Example #3
0
def loadimage1(caller,imagename,s=16,maxh=20):
	s=int(s)
	(xsize, ysize, heights)=loadheightmap(imagename,int(maxh))
	
	serverNotice("Loading image %s for blocky heightmaps. %sx%sx%s" % (imagename,xsize,ysize,s))
	
	mapsize=base.newmap(caller,math.ceil(max(math.log(xsize*s,2),math.log(ysize*s,2))))
	middleheight=2**(mapsize-1)/s
	
	for y in xrange(ysize):
		for x in xrange(xsize):
			cubes.makecolumn(caller,x,y,middleheight,heights[x][y],s)
	
	serverNotice("Done filling packet queue with heightmap.")
Example #4
0
def loadimage1(caller,imagename,s=16,maxh=20):
	'''Loads an image and starts the process of converting a heightmap into cube packets for map generation(blocky).'''
	s=int(s)
	(xsize, ysize, heights)=loadheightmap(imagename,int(maxh))
	
	serverNotice("Loading image %s for blocky heightmaps. %sx%sx%s" % (imagename,xsize,ysize,s))
	
	mapsize=base.newmap(caller,math.ceil(max(math.log(xsize*s,2),math.log(ysize*s,2))))
	middleheight=2**(mapsize-1)/s
	
	for y in xrange(ysize):
		for x in xrange(xsize):
			cubes.makecolumn(caller,x,y,middleheight,heights[x][y],s)
	
	serverNotice("Done filling packet queue with heightmap.")
Example #5
0
def loadimage2(caller,imagename,s=16,maxh=20):
	s=int(s)
	(xsize, ysize, heights)=loadheightmap(imagename,int(maxh)*8)
	
	serverNotice("Loading image %s for smooth heightmaps. %sx%sx%s" % (imagename,xsize,ysize,s))
	
	mapsize=base.newmap(caller,math.ceil(max(math.log(xsize*s,2),math.log(ysize*s,2))))
	middleheight=2**(mapsize-1)/s
	
	for y in xrange(ysize-1):
		for x in xrange(xsize-1):
			neighbourheights=(heights[y][x],heights[y][x+1],heights[y+1][x],heights[y+1][x+1])
			cubeheight=(max(neighbourheights)-1)/8+1
			cubes.makecolumn(caller,x,y,middleheight,cubeheight,s)
			cubes.corners(x,y,middleheight+cubeheight-1,(cubeheight*8-h for h in neighbourheights),s)
	
	serverNotice("Done filling packet queue with heightmap.")