for ix in xrange(xSize//4):
     for iy in xrange(ySize//4):
         
         
         blob = Blockgroups.addBlob(ix, iy)
         
         for iix in xrange(4):
             newX = (ix*4)+iix
             for iiy in xrange(4):
                 newY = (iy*4)+iiy
                 
                 if newX >= data.mapInfo["width"] or newY >= data.mapInfo["height"]:
                     break
                 else:
                     currentHeight = heightmap.getVal(newX, newY)
                     
                     # Is the ramp flag set? If so, we will try to draw a transition between two layers
                     if rampMap.getVal(newX, newY) == 1 and False: # for the moment disabled because of issues
                         upperTile = heightmap.getVal(newX, newY+1)
                         lowerTile = heightmap.getVal(newX, newY-1)
                         leftTile = heightmap.getVal(newX-1, newY)
                         rightTile = heightmap.getVal(newX+1, newY)
                         
                         # The startX and startY variables are coordinates for the points
                         # that are closest to the highest tile
                         startX = 0
                         startY = 0
                         
                         if upperTile < lowerTile: 
                             startY = 3
예제 #2
0
    def create_vmf(self):
        wc3map_xSize = self.base.WC3map_xSize
        wc3map_ySize = self.base.WC3map_ySize

        wc3_tileSize = self.base.wc3_tileSize
        wc3_tileHeight = self.base.wc3_tileHeight
        blobAffinity = Bytemap(wc3map_xSize, wc3map_xSize)
        bloblist = []

        # We iterate a second time to group tiles of similar height together.
        # rectangularCheck uses a brute force approach.
        for x in xrange(wc3map_xSize):
            for y in xrange(wc3map_ySize):

                localHeight = self.base.WC3map_heightmap.getVal(x, y)

                # We check if the tile already belongs to a group.
                # -1 means no. If not equal to -1, we skip it.
                if blobAffinity.getVal(x, y) == -1:
                    endX, endY = self.rectangularCheck(x, y, wc3map_xSize,
                                                       wc3map_ySize,
                                                       localHeight,
                                                       blobAffinity)

                    for ix in xrange(x, endX):
                        for iy in xrange(y, endY):
                            # We set the value for the coordinates to 1 to signal that
                            # they belong to a "blob", i.e. a group of planes
                            blobAffinity.setVal(ix, iy, 1)

                    bloblist.append(((x, y), (endX, endY), localHeight))

        print "Preparations are done, now creating the planes..."

        for index, plane in enumerate(bloblist):
            startCoords, endCoords, height = plane

            startX, startY = startCoords
            endX, endY = endCoords

            boxWidth = endX - startX
            boxLength = endY - startY

            height = (
                height
            ) * wc3_tileHeight  # Each layer of the map has a height of 64 units

            # midX and midY: middle of box that spans from startX;startY to endX;endY
            midX = startX + boxWidth / 2.0  # Very important, DO NOT ROUND: causes issues with random overlapping
            midY = startY + boxLength / 2.0

            # A little bit of optimization, only draw the block if it has a non-zero height
            # (Hammer only likes blocks with non-zero dimensions, for good reason)
            if height > 0:
                vert = vmflib.types.Vertex(
                    (midX * wc3_tileSize) - self.base.vmfmap_xMidOffset,
                    (midY * wc3_tileSize) - self.base.vmfmap_yMidOffset,
                    0 + (height // 2))
                block = tools.Block(origin=vert,
                                    dimensions=(boxWidth * wc3_tileSize,
                                                boxLength * wc3_tileSize,
                                                height))

                if self.texture == "dota2":
                    block.set_material("nature/dirt_grass_00")
                else:
                    block.set_material("brick/brick_ext_08")

                self.base.m.world.children.append(block)

        print "Building map finished."
예제 #3
0
    def create_vmf(self):
        wc3map_xSize = self.base.WC3map_xSize
        wc3map_ySize = self.base.WC3map_ySize
        
        wc3_tileSize = self.base.wc3_tileSize
        wc3_tileHeight = self.base.wc3_tileHeight
        blobAffinity = Bytemap(wc3map_xSize, wc3map_xSize)
        bloblist = []
        
        # We iterate a second time to group tiles of similar height together.
        # rectangularCheck uses a brute force approach.
        for x in xrange(wc3map_xSize):
            for y in xrange(wc3map_ySize):
                
                localHeight = self.base.WC3map_heightmap.getVal(x,y)
                
                # We check if the tile already belongs to a group.
                # -1 means no. If not equal to -1, we skip it.
                if blobAffinity.getVal(x, y) == -1:
                    endX, endY = self.rectangularCheck(x, y,
                                                       wc3map_xSize, wc3map_ySize,
                                                       localHeight, blobAffinity)
                    
                    for ix in xrange(x, endX):
                        for iy in xrange(y, endY):
                            # We set the value for the coordinates to 1 to signal that
                            # they belong to a "blob", i.e. a group of planes
                            blobAffinity.setVal(ix, iy, 1) 
                    
                    bloblist.append( ((x,y), (endX, endY), localHeight) )
        
        
        print "Preparations are done, now creating the planes..."

        for index, plane in enumerate(bloblist):
            startCoords, endCoords, height = plane
            
            startX, startY = startCoords
            endX, endY = endCoords
            
            boxWidth = endX-startX
            boxLength = endY-startY
            
            height = (height)*wc3_tileHeight # Each layer of the map has a height of 64 units
            
            # midX and midY: middle of box that spans from startX;startY to endX;endY
            midX = startX + boxWidth/2.0 # Very important, DO NOT ROUND: causes issues with random overlapping
            midY = startY + boxLength/2.0
            
            # A little bit of optimization, only draw the block if it has a non-zero height
            # (Hammer only likes blocks with non-zero dimensions, for good reason)
            if height > 0:
                vert = vmflib.types.Vertex((midX*wc3_tileSize)-self.base.vmfmap_xMidOffset, 
                                           (midY*wc3_tileSize)-self.base.vmfmap_yMidOffset, 
                                           0+(height//2))
                block = tools.Block(origin = vert, dimensions=(boxWidth*wc3_tileSize, boxLength*wc3_tileSize, height))
                
                if self.texture == "dota2":
                    block.set_material("nature/dirt_grass_00")
                else:
                    block.set_material("brick/brick_ext_08")
                
                self.base.m.world.children.append(block)
    

        print "Building map finished."