コード例 #1
0
 def __init__(self, origin, extent, rtype=None, props=None):
     if type(origin) != type(Point(0,0,0)) \
     or type(extent) != type(Point(0,0,0)) \
     or type(rtype) == type(Point(0,0,0)):
         raise TypeError
     self.origin = origin
     self.extent = extent
     self.end = self.origin + self.extent
     checkType(rtype)
     self.type = rtype
     self.props = props
コード例 #2
0
    def getLightingStyleId(self, stylename, size):
        # FIXME assumes 2 ids -- one with and one w/o size
        sizes = []
        largest = None
        if self.lightingSets.has_key(stylename):
            # FIXME do a proper sort!
            not_sorted_list = []
            for key in self.lightingSets[stylename].keys():
                not_sorted_list.insert(0, key)

            for lighting in not_sorted_list:
                maxs = self.lightingSets[stylename][lighting]['maxs']
                if not maxs:
                    maxs = Point(0, 0, 0)
                    largest = lighting
                else:
                    maxs = getPoint(maxs)

                #uprint('getLightingStyle: size: ' + str(size) + '; maxs: ' + str(maxs) + '; ', True)
                if size.x <= maxs.x or size.y <= maxs.y:
                    #uprint('return ' + lighting)
                    return lighting
                else:
                    #uprint('try next...')
                    pass
            # if nothing returned here, use the largest one
            #uprint('return largest')
            return largest
        else:
            error('StyleFetcher: unkown lighting set name \'' + stylename +
                  '\'.')
コード例 #3
0
ファイル: utils.py プロジェクト: goderdzi/agrip
	def __init__(self, origin, extent, rtype=None, props=None):
		if not isinstance(origin, Point):
			if isinstance(origin, Point2D):
				origin = Point(origin.x, origin.y, 0)  # FIXME fix callers :-)
			else:
				raise TypeError('origin is not a 3D Point')
		if not isinstance(extent, Point):
			if isinstance(extent, Point2D):
				extent = Point(extent.x, extent.y, 0)  # FIXME fix callers :-)
			else:
				raise TypeError('extent is not a 3D Point')
		self.origin = origin
		self.extent = extent
		self.end = self.origin + self.extent
		checkType(rtype)
		self.type = rtype
		self.props = props
コード例 #4
0
def processMap(doc):
    map = doc.documentElement
    worldspawn = processInfo(doc, map)
    # Go through each successive element and process it accordingly.
    # (Yes, this is very SAX-like but we don't use SAX because by using DOM we
    # get to manipulate the tree as we go, which we do need to do.)
    for node in map.childNodes[1:]:
        processNode(doc, map, worldspawn, s, Point(0, 0, 0), node)
コード例 #5
0
def getPoint(cstr):
    list = cstr.split()
    if len(list) == 3:
        return Point(float(list[0]), float(list[1]), float(list[2]))
    else:
        error(
            'getPoint: received input without 3 parts to make 3D point from -- \''
            + str(cstr) + '\'.')
コード例 #6
0
ファイル: utils.py プロジェクト: goderdzi/agrip
def addDim(region, dim, d, e=None):
	'''Convert a Region2D into a Region3D by adding an extra dminsion, that was
	taken away by the splitting algorithm.

	e is only passed when making holes in solids as we need to know the depth
	then.'''
	o = 0  # offset: used for insetting doors
	if not e:
		e = prog.lip
	if region.type == connector.DOOR:
		o = prog.lip_small_margin
		e = prog.lip_small
	if dim == dims.X:
		return Region3D(
			Point(d + o, region.origin.x, region.origin.y),
			Point(e, region.extent.x, region.extent.y),
			region.type,
			region.props)
	elif dim == dims.Y:
		return Region3D(
			Point(region.origin.x, d + o, region.origin.y),
			Point(region.extent.x, e, region.extent.y),
			region.type,
			region.props)
	elif dim == dims.Z:
		return Region3D(
			Point(region.origin.x, region.origin.y, d + o),
			Point(region.extent.x, region.extent.y, e),
			region.type,
			region.props)
	else:
		error('Invalid dimension specified for addDim().')
コード例 #7
0
ファイル: utils.py プロジェクト: goderdzi/agrip
	def getLightingStyleId(self, stylename, size):
		# FIXME assumes 2 ids -- one with and one w/o size
		largest = None
		if stylename in self.lightingSets:
			# FIXME do a proper sort!
			not_sorted_list = []
			for key in list(self.lightingSets[stylename].keys()):
				not_sorted_list.insert(0, key)

			for lighting in not_sorted_list:
				maxs = self.lightingSets[stylename][lighting]['maxs']
				if not maxs:
					maxs = Point(0, 0, 0)
					largest = lighting
				else:
					maxs = getPoint(maxs)

				if size.x <= maxs.x or size.y <= maxs.y:
					return lighting
			# if nothing returned here, use the largest one
			return largest
		else:
			error('StyleFetcher: unkown lighting set name \'' + stylename + '\'.')
コード例 #8
0
    def simulate(self, init_position, fuel, ground_points):
        """From each chromosome in population we create object
        of Lander class and compute trajectory
        """
        x, y = init_position[0], init_position[1]
        lander_init_state = State(fuel, 0, 0,
                                  Particle(Point(x, y), Speed(Vector(0, 0))))
        ground_line = ground_inputs_to_line(ground_points)
        self.ground_points = ground_line
        self.simulations = []
        for member in self.population:
            commands = []
            previous_gene = CMD_TUPLE(0, 0)
            for gene in member.genes:
                angle = previous_gene.angle + coerce_range(
                    gene.angle - previous_gene.angle, -15, 15)
                power = previous_gene.power + coerce_range(
                    gene.power - previous_gene.power, -15, 15)
                commands.append(ControlCommands(angle, power))
                previous_gene = gene

            new_lander = Lander(lander_init_state, commands, ground_line)
            self.simulations.append(new_lander)
        self.all_simulations.append(deepcopy(self.simulations))
コード例 #9
0
ファイル: 04-d-buildermac.py プロジェクト: philogus/agrip
	def macro_stairs(self, bi, si):
		'''Make some stairs
		we see this as a 2D problem then add the missing dimension later (width/depth)
		dir tells us in which dir the steps go up
		length is the distance from start of lowest to end of heighest step
		height is the height of the highest step'''
		# FIXME cope with being able to make a hole through (under) the stairs
		origin = ldl.getPoint(bi['origin'])
		size = ldl.getPoint(bi['extent'])
		dir = si['dir']
		texture = ''
		if bi.has_key('texture'): texture = bi['texture']
		#slength = float(si['steplength'])
		slength = 0
		sheight = float(si['stepheight'])
		parts = []
		parts3d = []

		# FIXME repeated code: n/e == s/w -- collapse into 2?

		# Work out which dimension is which
		if dir == ldl.DCP_NORTH:
			# use X and Y; Z rising with increasing Y
			length = size.y
			height = size.z
			width = size.x
			flip = False
			parts = self._macro_stairs_core(length, height, width, flip, slength, sheight, texture)
			for part in parts:
				part3d = ldl.Region3D(
					Point(0,part.origin.x,part.origin.y) + origin,
					Point(width, part.extent.x, part.extent.y)
				)
				parts3d.append(part3d)
		elif dir == ldl.DCP_SOUTH:
			# use X and Y; Z falling with increasing Y
			length = size.y
			height = size.z
			width = size.x
			flip = True
			parts = self._macro_stairs_core(length, height, width, flip, slength, sheight, texture)
			for part in parts:
				part3d = ldl.Region3D(
					Point(0,part.origin.x,part.origin.y) + origin,
					Point(width, part.extent.x, part.extent.y)
				)
				parts3d.append(part3d)
		elif dir == ldl.DCP_EAST:
			# use X and Y; Z rising with increasing X
			length = size.x
			height = size.z
			width = size.y
			flip = False
			parts = self._macro_stairs_core(length, height, width, flip, slength, sheight, texture)
			for part in parts:
				part3d = ldl.Region3D(
					Point(part.origin.x, 0, part.origin.y) + origin,
					Point(part.extent.x, width, part.extent.y)
				)
				parts3d.append(part3d)
		elif dir == ldl.DCP_WEST:
			# use X and y; Z falling with increasing X
			length = size.x
			height = size.z
			width = size.y
			flip = True
			parts = self._macro_stairs_core(length, height, width, flip, slength, sheight, texture)
			for part in parts:
				part3d = ldl.Region3D(
					Point(part.origin.x, 0, part.origin.y) + origin,
					Point(part.extent.x, width, part.extent.y)
				)
				parts3d.append(part3d)
		else:
			ldl.error('invalid direction specified for stairs (up and down are currently unsupported)')

		for part3d in parts3d:
			#ldl.uprint(str(part3d))
			print "<solid origin='" + str(part3d.origin) + "' extent='" + str(part3d.extent) + "' texture='" + texture + "' type='step' />"
コード例 #10
0
def processSolid(doc, parent, worldspawn, sf, offset, solid):
    '''Note: uses style set in parent hollow.'''
    global style
    o = utils.getPoint(solid.getAttribute('origin')) + offset
    e = utils.getPoint(solid.getAttribute('extent'))
    t = solid.getAttribute('texture')
    type = solid.getAttribute('type')
    if not t:
        if not type:
            utils.error('solid with no type also has no texture attribute set')
    f = solid.getAttribute('holeface')
    # Get holes info...
    # FIXME this is repeated code from the hollow one -- any way we can
    # refactor it?
    props = {}
    holes = []
    # Check if the solid has children (holes).
    # If so, split it up.
    # If not, just add it.
    if solid.hasChildNodes():
        for hole in solid.childNodes:
            ho_x, ho_y = hole.getAttribute('origin').split()
            he_x, he_y = hole.getAttribute('extent').split()
            type = hole.getAttribute('type')
            if not type:
                pass
            elif type == connector.DOOR:
                props['key'] = hole.getAttribute('key')
            else:
                utils.warning(
                    'only doors allowed as hole types; not plats or others.')
            # FIXME deal with other types
            holes.append(
                utils.Hole2D(utils.Point2D(float(ho_x), float(ho_y)),
                             utils.Point2D(float(he_x), float(he_y)), type,
                             props))
        # Built split (2D) parts into 3D brushes; mapping of coords to 3D
        # depends on which direction/face the hole was constructed in.
        if f == dcp.NORTH:
            parts = split.splitWall(
                utils.Region2D(utils.Point2D(o.x, o.z),
                               utils.Point2D(e.x, e.z)), holes)
            for part in parts:
                part3d = utils.addDim(part, dims.Y, o.y, e.y)
                utils.makeBrush(doc, worldspawn, sf, style, part3d, f, t)
        elif f == dcp.UP:
            parts = split.splitWall(
                utils.Region2D(utils.Point2D(o.x, o.y),
                               utils.Point2D(e.x, e.y)), holes)
            for part in parts:
                part3d = utils.addDim(part, dims.Z, o.z + prog.lip_small,
                                      e.z - prog.lip_small * 2)
                utils.makeBrush(doc, worldspawn, sf, style, part3d, f, t)
            else:
                utils.error('Unsupported holeface ' + f +
                            ' requested for hole in solid.')
    else:
        # Doesn't have child nodes...
        if not type or type == connector.STEP:
            pass  # no properties to set
        elif type == connector.DOOR:
            props['key'] = solid.getAttribute('key')
        elif type == connector.PLAT:
            props['position'] = solid.getAttribute('position')
        else:
            utils.warning('unknown type ' + type + ' specifed.')

        brush = utils.Region3D(Point(o.x, o.y, o.z), Point(e.x, e.y, e.z),
                               type, props)
        utils.makeBrush(doc, worldspawn, sf, style, brush, type, t)
    # We can't remove the child or we screw over tree traversal (urgh)...
    utils.insertPlaceholder(doc, parent, solid)
コード例 #11
0
    def macro_stairs(self, bi, si):
        '''Make some stairs

		we see this as a 2D problem then add the missing dimension later
		(width/depth) dir tells us in which dir the steps go up length is the
		distance from start of lowest to end of heighest step height is the
		height of the highest step'''
        # FIXME cope with being able to make a hole through (under) the stairs
        origin = utils.getPoint(bi['origin'])
        size = utils.getPoint(bi['extent'])
        dir = si['dir']
        texture = ''
        if 'texture' in bi:
            texture = bi['texture']
        slength = 0
        sheight = float(si['stepheight'])
        parts = []
        parts3d = []

        # FIXME repeated code: n/e == s/w -- collapse into 2?

        # Work out which dimension is which
        if dir == dcp.NORTH:
            # use X and Y; Z rising with increasing Y
            length = size.y
            height = size.z
            width = size.x
            flip = False
            parts = self._macro_stairs_core(length, height, width, flip,
                                            slength, sheight, texture)
            for part in parts:
                part3d = utils.Region3D(
                    Point(0, part.origin.x, part.origin.y) + origin,
                    Point(width, part.extent.x, part.extent.y))
                parts3d.append(part3d)
        elif dir == dcp.SOUTH:
            # use X and Y; Z falling with increasing Y
            length = size.y
            height = size.z
            width = size.x
            flip = True
            parts = self._macro_stairs_core(length, height, width, flip,
                                            slength, sheight, texture)
            for part in parts:
                part3d = utils.Region3D(
                    Point(0, part.origin.x, part.origin.y) + origin,
                    Point(width, part.extent.x, part.extent.y))
                parts3d.append(part3d)
        elif dir == dcp.EAST:
            # use X and Y; Z rising with increasing X
            length = size.x
            height = size.z
            width = size.y
            flip = False
            parts = self._macro_stairs_core(length, height, width, flip,
                                            slength, sheight, texture)
            for part in parts:
                part3d = utils.Region3D(
                    Point(part.origin.x, 0, part.origin.y) + origin,
                    Point(part.extent.x, width, part.extent.y))
                parts3d.append(part3d)
        elif dir == dcp.WEST:
            # use X and y; Z falling with increasing X
            length = size.x
            height = size.z
            width = size.y
            flip = True
            parts = self._macro_stairs_core(length, height, width, flip,
                                            slength, sheight, texture)
            for part in parts:
                part3d = utils.Region3D(
                    Point(part.origin.x, 0, part.origin.y) + origin,
                    Point(part.extent.x, width, part.extent.y))
                parts3d.append(part3d)
        else:
            utils.error(
                'invalid direction specified for stairs (up and down are currently '
                'unsupported)')

        for part3d in parts3d:
            super().startElement(
                'solid', {
                    'origin': str(part3d.origin),
                    'extent': str(part3d.extent),
                    'texture': texture,
                    'type': 'step'
                })
            super().endElement('solid')
コード例 #12
0
ファイル: 01-u-brushsizes.py プロジェクト: philogus/agrip
def listBrushes(map):
    brush_planes = []  # stores the (6) planes that make up one brush
    plane_points = []  # stores the (3) points in the current plane
    psa = []  # store one set of non-parallel planes
    psb = []  # store another set of non-parallel planes
    textureSpec = ''
    
    # Process all brushes...
    for brush in map.getElementsByTagName('brush'):
        ldl.uprint('Brush...')
        # Get all planes...
        for plane in brush.getElementsByTagName('plane'):
            ldl.uprint('    Plane...')
            # Get texture spec...
            textureSpec = getText(plane.getElementsByTagName('texture')[0].childNodes)
            ldl.uprint('        Texture: ' + textureSpec)
            # Get all points...
            for point in plane.getElementsByTagName('point'):
                point_match = r_planepoints.match(getText(point.childNodes))
                plane_points.append(Point(
                    float(point_match.group(1)),
                    float(point_match.group(2)),
                    float(point_match.group(3))))
                # NB: We use floats above so that later calculations are still accurate.
                ldl.uprint('        ' + str(plane_points[len(plane_points)-1]))
            # Put points into a plane object...
            brush_planes.append(
                Plane3D(
                    plane_points[0],
                    plane_points[1],
                    plane_points[2]))
            plane_points = []
            # Grab texture and remove this plane...
            brush.removeChild(plane)
        
        # Got all planes; work out brush origin and size...
        for plane in brush_planes:
            ldl.uprint('   ' + str(plane))
        
        # Get and solve parallel planes...
        while len(brush_planes) > 0:
            t = brush_planes.pop(0)
            s = t.N.x + t.N.y + t.N.z
            if s > 0:
                psa.append(t)
            else:
                psb.append(t)
        i1 = intersect(psa[0], psa[1], psa[2])
        i2 = intersect(psb[0], psb[1], psb[2])

        # Work out size (from smallest/lowest coord) and extent...
        i1s = i1.x + i1.y + i1.z
        i2s = i2.x + i2.y + i2.z
        if i1s < i2s:
            origin = i1
            extent = i2 - i1
        else:
            origin = i2
            extent = i2 - i1

        # Update brush info...
        brush.setAttribute('origin', str(origin))
        brush.setAttribute('extent', str(extent))
        brush.setAttribute('texture', textureSpec)
        # Tidy up...
        #brush_planes = []
        psa = []
        psb = []
コード例 #13
0
def makeHollow(doc, worldspawn, sf, origin, extent, absentwalls, holes, style):
    '''Makes a hollow object (room/corridor) with the given paramaters.
	Works out the brushes, textures.
	Returns the origin and extent of the inner area.
	The north and south walls cover the entire width of the hollow.  The east and west ones fit inbetween the north and south ones.  However...
	To avoid leaks, when some walls are absent, the others must be made longer to cover the possible holes.  For example, if there is no north wall, the east and west ones need to be ldl.lip units longer in case them not being so would cause a leak.'''
    inner_origin = origin + lip
    inner_abslut_extent = (origin + extent) - lip

    # down (floor)
    if not DCP_DOWN in absentwalls:
        brush_start = origin
        brush_extent = Point(extent.x, extent.y, lip)
    parts = split.splitWall(
        Region2D(Point2D(brush_start.x, brush_start.y),
                 Point2D(brush_extent.x, brush_extent.y)),
        getHoles(holes, DCP_DOWN))
    for part in parts:
        part3d = addDim(part, DIM_Z, brush_start.z)
        #uprint('Part:   ' + str(part) + '\nPart3D: ' + str(part3d))
        makeBrush(doc, worldspawn, sf, style, part3d, DCP_DOWN)
    # up (ceiling)
    if not DCP_UP in absentwalls:
        brush_start = origin + Point(0, 0, extent.z - lip)
        brush_extent = Point(extent.x, extent.y, lip)
    parts = split.splitWall(
        Region2D(Point2D(brush_start.x, brush_start.y),
                 Point2D(brush_extent.x, brush_extent.y)),
        getHoles(holes, DCP_UP))
    for part in parts:
        part3d = addDim(part, DIM_Z, brush_start.z)
        #uprint('Part:   ' + str(part) + '\nPart3D: ' + str(part3d))
        makeBrush(doc, worldspawn, sf, style, part3d, DCP_UP)
    # north wall; y represents depth
    if not DCP_NORTH in absentwalls:
        brush_start = origin + Point(0, extent.y - lip, lip)
        brush_extent = Point(extent.x, lip, extent.z - lip * 2)
        wall_holes = getHoles(holes, DCP_NORTH)
        parts = split.splitWall(
            Region2D(Point2D(brush_start.x, brush_start.z),
                     Point2D(brush_extent.x, brush_extent.z)),
            getHoles(holes, DCP_NORTH))
        for part in parts:
            part3d = addDim(part, DIM_Y, brush_start.y)
            #uprint('Part:   ' + str(part) + '\nPart3D: ' + str(part3d))
            makeBrush(doc, worldspawn, sf, style, part3d, DCP_NORTH)
    # south wall
    # FIXME holes need to be expressed the other way 'round (i.e. 0 is at RHS not LHS)?
    if not DCP_SOUTH in absentwalls:
        brush_start = origin + Point(0, 0, lip)
        brush_extent = Point(extent.x, lip, extent.z - lip * 2)
        wall_holes = getHoles(holes, DCP_SOUTH)
        parts = split.splitWall(
            Region2D(Point2D(brush_start.x, brush_start.z),
                     Point2D(brush_extent.x, brush_extent.z)),
            getHoles(holes, DCP_SOUTH))
        for part in parts:
            part3d = addDim(part, DIM_Y, brush_start.y)
            #uprint('Part:   ' + str(part) + '\nPart3D: ' + str(part3d))
            makeBrush(doc, worldspawn, sf, style, part3d, DCP_SOUTH)
    # west wall
    if not DCP_WEST in absentwalls:
        if DCP_NORTH not in absentwalls and DCP_SOUTH not in absentwalls:
            brush_start = origin + Point(0, lip, lip)
            brush_extent = Point(lip, extent.y - lip * 2, extent.z - lip * 2)
        elif DCP_NORTH in absentwalls and DCP_SOUTH in absentwalls:
            brush_start = origin + Point(0, lip, lip)
            brush_extent = Point(lip, extent.y - lip * 2, extent.z - lip * 2)
        elif DCP_NORTH in absentwalls:
            brush_start = origin + Point(0, lip, lip)
            brush_extent = Point(lip, extent.y - lip, extent.z - lip * 2)
        elif DCP_SOUTH in absentwalls:
            brush_start = origin + Point(0, 0, lip)
            brush_extent = Point(lip, extent.y - lip, extent.z - lip * 2)
        else:
            error('absentwalls')
        wall_holes = getHoles(holes, DCP_WEST)
        parts = split.splitWall(
            Region2D(Point2D(brush_start.y, brush_start.z),
                     Point2D(brush_extent.y, brush_extent.z)),
            getHoles(holes, DCP_WEST))
        for part in parts:
            part3d = addDim(part, DIM_X, brush_start.x)
            #uprint('Part:   ' + str(part) + '\nPart3D: ' + str(part3d))
            makeBrush(doc, worldspawn, sf, style, part3d, DCP_WEST)
    # east wall
    if not DCP_EAST in absentwalls:
        if DCP_NORTH not in absentwalls and DCP_SOUTH not in absentwalls:
            brush_start = origin + Point(extent.x - lip, lip, lip)
            brush_extent = Point(lip, extent.y - lip * 2, extent.z - lip * 2)
        elif DCP_NORTH in absentwalls and DCP_SOUTH in absentwalls:
            brush_start = origin + Point(extent.x - lip, 0, lip)
            brush_extent = Point(lip, extent.y, extent.z - lip * 2)
        elif DCP_NORTH in absentwalls:
            brush_start = origin + Point(extent.x - lip, lip, lip)
            brush_extent = Point(lip, extent.y - lip, extent.z - lip * 2)
        elif DCP_SOUTH in absentwalls:
            brush_start = origin + Point(extent.x - lip, 0, lip)
            brush_extent = Point(lip, extent.y - lip, extent.z - lip * 2)
        else:
            error('absentwalls')
        parts = split.splitWall(
            Region2D(Point2D(brush_start.y, brush_start.z),
                     Point2D(brush_extent.y, brush_extent.z)),
            getHoles(holes, DCP_EAST))
        for part in parts:
            part3d = addDim(part, DIM_X, brush_start.x)
            #uprint('Part:   ' + str(part) + '\nPart3D: ' + str(part3d))
            makeBrush(doc, worldspawn, sf, style, part3d, DCP_EAST)
    # Return inner extents...
    return inner_origin, inner_abslut_extent
コード例 #14
0
def PointFromString(str):
    point_match = r_planepoints.match(str)
    return Point(float(point_match.group(1)), float(point_match.group(2)),
                 float(point_match.group(3)))
コード例 #15
0
# MCS 275 Spring 2021 - David Dumas
# Used in Lecture 5 and Lecture 6

from plane import Vector, Point
import bots
import random
import time

width = 60
height = 30

current_bots = []

# Make some wander bots
for i in range(5):
    P = Point(random.randint(0, width - 1), random.randint(0, height - 1))
    current_bots.append(bots.WanderBot(position=P))

# Make some patrol bots
patrol_directions = [Vector(1, 0), Vector(0, 1), Vector(1, 1)]
for i in range(10):
    P = Point(random.randint(0, width - 1), random.randint(0, height - 1))
    D = random.choice(patrol_directions)
    current_bots.append(bots.PatrolBot(position=P, direction=D, nstep=8))

# Make two destruct bots
current_bots.append(bots.DestructBot(position=Point(4, 4), lifetime=5))
current_bots.append(bots.DestructBot(position=Point(4, 10), lifetime=15))

# Symbols for the different kinds of bots
botsymbols = {
コード例 #16
0
def ground_inputs_to_line(ground_points):
    points = []
    for point in ground_points:
        points.append(Point(*map(int, point.split())))
    return Line(points)
コード例 #17
0
ファイル: utils.py プロジェクト: goderdzi/agrip
def makeHollow(doc, worldspawn, sf, origin, extent, absentwalls, holes, style):
	'''Makes a hollow object (room/corridor) with the given paramaters.

	Works out the brushes, textures.

	Returns the origin and extent of the inner area.

	The north and south walls cover the entire width of the hollow. The east
	and west ones fit inbetween the north and south ones. However...

	To avoid leaks, when some walls are absent, the others must be made longer
	to cover the possible holes. For example, if there is no north wall, the
	east and west ones need to be utils.prog.lip units longer in case them not
	being so would cause a leak.'''
	inner_origin = origin + prog.lip
	inner_abslut_extent = (origin + extent) - prog.lip

	# down (floor)
	if dcp.DOWN not in absentwalls:
		brush_start = origin
		brush_extent = Point(extent.x, extent.y, prog.lip)
	parts = split.splitWall(
		Region2D(
			Point2D(brush_start.x, brush_start.y),
			Point2D(brush_extent.x, brush_extent.y)
		),
		getHoles(holes, dcp.DOWN))
	for part in parts:
		part3d = addDim(part, dims.Z, brush_start.z)
		makeBrush(doc, worldspawn, sf, style, part3d, dcp.DOWN)
	# up (ceiling)
	if dcp.UP not in absentwalls:
		brush_start = origin + Point(0, 0, extent.z - prog.lip)
		brush_extent = Point(extent.x, extent.y, prog.lip)
	parts = split.splitWall(
		Region2D(
			Point2D(brush_start.x, brush_start.y),
			Point2D(brush_extent.x, brush_extent.y)
		),
		getHoles(holes, dcp.UP))
	for part in parts:
		part3d = addDim(part, dims.Z, brush_start.z)
		makeBrush(doc, worldspawn, sf, style, part3d, dcp.UP)
	# north wall; y represents depth
	if dcp.NORTH not in absentwalls:
		brush_start = origin + Point(0, extent.y - prog.lip, prog.lip)
		brush_extent = Point(extent.x, prog.lip, extent.z - prog.lip * 2)
		parts = split.splitWall(
			Region2D(
				Point2D(brush_start.x, brush_start.z),
				Point2D(brush_extent.x, brush_extent.z)
			),
			getHoles(holes, dcp.NORTH))
		for part in parts:
			part3d = addDim(part, dims.Y, brush_start.y)
			makeBrush(doc, worldspawn, sf, style, part3d, dcp.NORTH)
	# south wall
	# FIXME holes need to be expressed the other way 'round (i.e. 0 is at RHS
	# not LHS)?
	if dcp.SOUTH not in absentwalls:
		brush_start = origin + Point(0, 0, prog.lip)
		brush_extent = Point(extent.x, prog.lip, extent.z - prog.lip * 2)
		parts = split.splitWall(
			Region2D(
				Point2D(brush_start.x, brush_start.z),
				Point2D(brush_extent.x, brush_extent.z)
			),
			getHoles(holes, dcp.SOUTH))
		for part in parts:
			part3d = addDim(part, dims.Y, brush_start.y)
			makeBrush(doc, worldspawn, sf, style, part3d, dcp.SOUTH)
	# west wall
	if dcp.WEST not in absentwalls:
		if dcp.NORTH not in absentwalls and dcp.SOUTH not in absentwalls:
			brush_start = origin + Point(0, prog.lip, prog.lip)
			brush_extent = \
				Point(prog.lip, extent.y - prog.lip * 2, extent.z - prog.lip * 2)
		elif dcp.NORTH in absentwalls and dcp.SOUTH in absentwalls:
			brush_start = origin + Point(0, prog.lip, prog.lip)
			brush_extent = \
				Point(prog.lip, extent.y - prog.lip * 2, extent.z - prog.lip * 2)
		elif dcp.NORTH in absentwalls:
			brush_start = origin + Point(0, prog.lip, prog.lip)
			brush_extent = Point(prog.lip, extent.y - prog.lip, extent.z - prog.lip * 2)
		elif dcp.SOUTH in absentwalls:
			brush_start = origin + Point(0, 0, prog.lip)
			brush_extent = Point(prog.lip, extent.y - prog.lip, extent.z - prog.lip * 2)
		else:
			error('absentwalls')
		parts = split.splitWall(
			Region2D(
				Point2D(brush_start.y, brush_start.z),
				Point2D(brush_extent.y, brush_extent.z)
			),
			getHoles(holes, dcp.WEST))
		for part in parts:
			part3d = addDim(part, dims.X, brush_start.x)
			makeBrush(doc, worldspawn, sf, style, part3d, dcp.WEST)
	# east wall
	if dcp.EAST not in absentwalls:
		if dcp.NORTH not in absentwalls and dcp.SOUTH not in absentwalls:
			brush_start = origin + Point(extent.x - prog.lip, prog.lip, prog.lip)
			brush_extent = \
				Point(prog.lip, extent.y - prog.lip * 2, extent.z - prog.lip * 2)
		elif dcp.NORTH in absentwalls and dcp.SOUTH in absentwalls:
			brush_start = origin + Point(extent.x - prog.lip, 0, prog.lip)
			brush_extent = Point(prog.lip, extent.y, extent.z - prog.lip * 2)
		elif dcp.NORTH in absentwalls:
			brush_start = origin + Point(extent.x - prog.lip, prog.lip, prog.lip)
			brush_extent = Point(prog.lip, extent.y - prog.lip, extent.z - prog.lip * 2)
		elif dcp.SOUTH in absentwalls:
			brush_start = origin + Point(extent.x - prog.lip, 0, prog.lip)
			brush_extent = Point(prog.lip, extent.y - prog.lip, extent.z - prog.lip * 2)
		else:
			error('absentwalls')
		parts = split.splitWall(
			Region2D(
				Point2D(brush_start.y, brush_start.z),
				Point2D(brush_extent.y, brush_extent.z)
			),
			getHoles(holes, dcp.EAST))
		for part in parts:
			part3d = addDim(part, dims.X, brush_start.x)
			makeBrush(doc, worldspawn, sf, style, part3d, dcp.EAST)
	# Return inner extents...
	return inner_origin, inner_abslut_extent
コード例 #18
0
 def _get_bounds(self, hollow_attrs):
     '''Work out the internal cube of the hollow.'''
     extent = utils.getPoint(hollow_attrs['extent'])
     return extent - Point(prog.lip * 2, prog.lip * 2, prog.lip * 2)
コード例 #19
0
 def _get_bounds(self, hollow_attrs):
     '''Work out the internal cube of the hollow.'''
     origin = ldl.getPoint(hollow_attrs['origin'])
     extent = ldl.getPoint(hollow_attrs['extent'])
     return extent - Point(ldl.lip * 2, ldl.lip * 2, ldl.lip * 2)