def generate(self, config): back_rest = draw.makeBox(config.width, config.back_rest_thickness, config.back_rest_height) no_of_portions = 2. * config.no_of_holes + 1 bar_width = config.width/no_of_portions bar_height = config.back_rest_height - (config.back_rest_height/10) * 2 x = 0 for i in range(no_of_portions): if i%2 != 0: bar_origin = (x,0,config.back_rest_height/10) bar = draw.makeBox(bar_width, config.back_rest_thickness, bar_height,bar_origin) back_rest = back_rest.cut(bar) x = x+bar_width x = self.picker.pick((1.0)) wood_id = self.get_material('grass', M(texture='bark.jpg')) back_rest.set_material(wood_id, texture_coords=[(0.0, 0.0), (x, 0.0), (x, x), (0.0, x)]) self.add_geoms(back_rest)
def generate(self, config): # create four legs legs = [] for i in xrange(4): leg = draw.makeBox(config.leg_thickness, config.leg_thickness, config.leg_height) legs.append(leg) x_translate_by = config.width - config.leg_thickness y_translate_by = config.base_length - config.leg_thickness legs[1].translate((x_translate_by, 0, 0)) # front-right leg legs[2].translate((0, y_translate_by, 0)) # back-left leg legs[3].translate((x_translate_by, y_translate_by, 0)) # back-right leg self.add_geoms(legs) # create base base = draw.makeBox(config.width, config.base_length, config.base_thickness) base.translate((0, 0, config.leg_height)) self.add_geoms(base) # create back rest back_rest = draw.makeBox(config.width, config.back_rest_thickness, config.back_rest_height) back_rest.translate((0, config.base_length - config.back_rest_thickness, config.leg_height + config.base_thickness)) self.add_geoms(back_rest)
def generate(self, config): C = config grass_id = self.get_material('grass', M(texture='textures/grass.jpg')) bark_id = self.get_material('bark', M(texture='textures/bark.jpg')) trunk = draw.makeBox(C.diameter/4., C.diameter/4., C.height) trunk.set_material(bark_id) self.add_geom(trunk) length = C.diameter pnt = (-length/2., -length/2., C.height) top = draw.makeBox(length, length, length, pnt) x = self.picker.pick((1.0)) top.set_material(grass_id, texture_coords=[(0.0, 0.0), (x, 0.0), (x, x), (0.0, x)]) self.add_geom(top)
def generate(self, config): C = config self.register_materials() try: box = draw.makeBox(C.length, C.width, C.height) except: print 'length of box too small ', C.length, C.width, C.height raise building_id = self.get_material('facade_%s' % C.facade) size = self.facades[C.facade][-1] x = C.length/size y = C.height/size texture_coords=[(x, 0.0), (x, y), (0.0, y), (0.0, 0.0)] box.set_material(building_id, 'front', texture_coords) texture_coords=[(x, 0.0), (x, y), (0.0, y), (0.0, 0.0)] box.set_material(building_id, 'left', texture_coords) texture_coords=[(x, y), (0.0, y), (0.0, 0.0), (x, 0.0)] box.set_material(building_id, 'right', texture_coords) texture_coords=[(x, y), (0.0, y), (0.0, 0.0), (x, 0.0)] box.set_material(building_id, 'back', texture_coords) size = self.terraces[C.terrace][-1] x = C.length/size y = C.width/size texture_coords=[(x, y), (0.0, y), (0.0, 0.0), (x, 0.0)] terrace_id = self.get_material('terrace_%s' % C.terrace) box.set_material(terrace_id, 'top', texture_coords) self.add_geoms(box)
def generate(self, config): back_rest = draw.makeBox(config.width, config.back_rest_thickness, config.back_rest_height) self.add_geoms(back_rest)
def generate(self, config): C = config plate = draw.makeBox(C.length, C.width, 0.2) sand_id = self.get_material('sand', M(texture='sand.jpg')) x = self.picker.pick((0.1, 1000.0)) texture_coords=[(0.0, 0.0), (x, 0.0), (x, x), (0.0, x)] plate.set_material(sand_id, texture_coords=texture_coords) self.add_geom(plate) plots = make_plots(self.picker, C.length, C.plot_length_range, C.plot_gap) if not plots: return for origin, length in plots: if length <= 5 and C.width <= 5: print 'returning empty plot' return building_height = self.picker.pick(C.build_height_range) print 'plot got ', C.build_height_range, building_height width = C.width if length > 5: length = self.picker.pick((length/2, length)) if C.width > 5: width = self.picker.pick((width/2, width)) self.subgen('building', origin, length, width, height=building_height) gap = C.width - width if gap > 2: x,y,z = origin x= x+gap/2 y = y+width+1 self.subgen('tree', (x,y,z))
def generate(self, config): base = draw.makeBox(config.width, config.base_length, config.base_thickness) x = self.picker.pick((1.0)) wood_id = self.get_material('grass', M(texture='bark.jpg')) base.set_material(wood_id, texture_coords=[(0.0, 0.0), (x, 0.0), (x, x), (0.0, x)]) self.add_geoms(base)
def generate(self, config): C = config C.num_levels = None box = draw.makeBox(C.length, C.width, C.height) self.add_geoms(box) self.subgen('level1', (0,0,20))
def generate(self, config): plate_size = .01 grid = Grid(config, self.picker) grid.generate() groups = grid.group() # debug images grid.generate_image(open('c:/test.png', 'wb')) grid.generate_groups_image(groups, open('c:/test1.png', 'wb')) cell_gap = 5 cell_size = config.cell_size group_length = lambda g: ((g.max_col - g.min_col + 1) * cell_size) - cell_gap group_width = lambda g: ((g.max_row - g.min_row + 1) * cell_size) - cell_gap group_x = lambda g: (g.min_col) * cell_size + cell_gap/2 group_y = lambda g: (g.min_row) * cell_size + cell_gap/2 # generate layouts as per groups for g in groups: origin = (group_x(g), group_y(g), 0) length, width = group_length(g), group_width(g) if g.habitable: plate = draw.makeBox(length, width, plate_size) plate.translate((group_x(g), group_y(g), 0)) plate.color = 'dark_brown' self.add_geom(plate) self.subgen('sector', origin, length, width, level=g.level) else: box = draw.makeBox(length, width, plate_size) box.color = 'green' if g.type == Cell.FOREST else 'blue' x, y, z = origin box.translate((x, y, plate_size)) self.add_geom(box) side = config.size plate = draw.makeBox(side, side, plate_size) plate.color = 'black' plate.translate((0, 0, -2)) self.add_geom(plate)
def generate(self, config): C = config twidth = C.trunk_width halfwidth = twidth / 2. trunk = draw.makeBox(twidth, twidth, C.height, (-halfwidth, -halfwidth, 0)) self.add_geom(trunk) self.subgen('cube_top', (0, 0, config.height), config.top_size)
def generate(self, config): C = config try: park = draw.makeBox(C.length, C.width, C.height) park_id = self.get_material('grass', M(texture='grass.jpg')) x = self.picker.pick((1.0)) park.set_material(park_id, texture_coords=[(0.0, 0.0), (x, 0.0), (x, x), (0.0, x)]) self.add_geoms(park) except: print 'length of box too small ', C.length, C.width, C.height
def generate(self, config): C = config plate = draw.makeBox(C.length, C.width, 0.2) sand_id = self.get_material('sand', M(texture='textures/sand.jpg')) x = self.picker.pick((0.1, 1000.0)) texture_coords=[(0.0, 0.0), (x, 0.0), (x, x), (0.0, x)] plate.set_material(sand_id, texture_coords=texture_coords) self.add_geom(plate) self.subgen('footpath', (0, 0, 0.25), C.length, C.width, C.pavement)
def generate(self, config): C = config road = draw.makeBox(C.width, C.length, 78) road.visible = False self.add_geom(road) s_roads = self.get_intersection() # print 'got intersections', s_roads if not s_roads: road.visible = True
def generate(self, config): C = config door = draw.makeBox(C.width, C.thickness*2, C.height) door.visible = False door.tags.append('door') self.add_geom(door) ps = self.get_enclosing() geoms = ps.get_geoms(tag='wall') for geom in geoms: new_geom = geom.cut(door) self.replace_geom(geom,new_geom)
def generate(self, config): C = config shelf = draw.makeBox(C.length, C.width, C.height) shelf.tags.append('shelf') # wood_id = self.get_material('wood', M(texture='BookRack/vikraman.jpg')) # shelf.set_material(wood_id, texture_coords=[(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)]) self.add_geom(shelf) self.subgen('rack', (C.length/2, 0, C.height/2), C.length/4., C.width/2, C.height/2.)
def generate(self, config): C = config plate = draw.makeBox(C.length, C.width, 0.2) sand_id = self.get_material('sand', M(texture='sand.jpg')) x = self.picker.pick((0.1, 1000.0)) texture_coords=[(0.0, 0.0), (x, 0.0), (x, x), (0.0, x)] plate.set_material(sand_id, texture_coords=texture_coords) self.add_geom(plate) building_height = self.picker.pick(C.build_height_range) print 'calling building **' self.subgen('building', (0,0,0.2), C.length, C.width, height=building_height)
def generate(self, config): back_rest = draw.makeBox(config.width, config.back_rest_thickness, config.back_rest_height) no_of_portions = 2. * config.no_of_holes + 1 bar_width = config.width/no_of_portions bar_height = config.back_rest_height - (config.back_rest_height/10) * 2 x = 0 for i in range(no_of_portions): if i%2 != 0: bar_origin = (x,0,config.back_rest_height/10) bar = draw.makeBox(bar_width, config.back_rest_thickness, bar_height,bar_origin) back_rest = back_rest.cut(bar) x = x+bar_width self.add_geoms(back_rest)
def generate(self, config): C = config rack = draw.makeBox(C.length, C.width, C.height) rack.visible = False self.add_geom(rack) ps = self.get_enclosing() geoms = ps.get_geoms(tag='shelf') for geom in geoms: new_geom = geom.cut(rack) self.replace_geom(geom,new_geom)
def generate(self, config): C = config C.num_levels = None box = draw.makeBox(C.length, C.width, C.height) building_id = self.get_material('building', M(texture='building.jpg')) x = C.length/100.0 y = C.height/100.0 box.set_material(building_id, texture_coords=[(x, 0.0), (x, y), (0.0, y), (0.0, 0.0)], face='front') box.set_material(building_id, texture_coords=[(x, 0.0), (x, y), (0.0, y), (0.0, 0.0)], face='left') box.set_material(building_id, texture_coords=[(x, y), (0.0, y), (0.0, 0.0), (x, 0.0)], face='right') box.set_material(building_id, texture_coords=[(x, y), (0.0, y), (0.0, 0.0), (x, 0.0)], face='back') self.add_geoms(box) return
def generate(self, config): C = config C.num_levels = None box = draw.makeBox(C.length, C.width, C.height) building_id = self.get_material('building', M(texture='building.jpg')) x = C.length/100.0 y = C.height/100.0 box.set_material(building_id, texture_coords=[(x, 0.0), (x, y), (0.0, y), (0.0, 0.0)], face='front') box.set_material(building_id, texture_coords=[(x, 0.0), (x, y), (0.0, y), (0.0, 0.0)], face='left') box.set_material(building_id, texture_coords=[(x, y), (0.0, y), (0.0, 0.0), (x, 0.0)], face='right') box.set_material(building_id, texture_coords=[(x, y), (0.0, y), (0.0, 0.0), (x, 0.0)], face='back') self.add_geoms(box) return num_levels, slab_height, level_height = \ self.compute_height_params(self.picker, C.height, C.slab_height, C.level_height, C.num_levels) for i in xrange(num_levels): zoffset = (slab_height + level_height) * i slab = draw.makeBox(C.length, C.width, slab_height) origin = (0, 0, zoffset) slab.translate(origin) self.add_geom(slab) for i in xrange(num_levels): zoffset = slab_height + \ (slab_height + level_height) * i origin = (0, 0, zoffset) self.subgen('level', origin, C.length, C.width, level_height, None, C.wall_thickness, C.corridor_length, C.corridor_width)
def generate(self, config): C = config try: box = draw.makeBox(C.length, C.width, C.height) building_id = self.get_material('building', M(texture='building.jpg')) x = C.length/100.0 y = C.height/100.0 box.set_material(building_id, texture_coords=[(x, 0.0), (x, y), (0.0, y), (0.0, 0.0)], face='front') box.set_material(building_id, texture_coords=[(x, 0.0), (x, y), (0.0, y), (0.0, 0.0)], face='left') box.set_material(building_id, texture_coords=[(x, y), (0.0, y), (0.0, 0.0), (x, 0.0)], face='right') box.set_material(building_id, texture_coords=[(x, y), (0.0, y), (0.0, 0.0), (x, 0.0)], face='back') self.add_geoms(box) except: print 'length of box too small ', C.length, C.width, C.height
def generate(self, config): if config.type == 'square': leg = draw.makeBox(config.leg_thickness, config.leg_thickness, config.leg_height) elif config.type == 'cylinder': origin = (config.leg_thickness/2,config.leg_thickness/2,0) leg = draw.makeCylinder(config.leg_thickness/2, config.leg_height, origin) elif config.type == 'triangular': leg = draw.makePolygon([(config.leg_thickness,0,0),(0,config.leg_thickness,0),(0,0,0)]) leg = leg.extrude((0,0,config.leg_height)) self.add_geoms(leg)
def generate(self, config): base = draw.makeBox(config.width, config.base_length, config.base_thickness) smaller = config.width if config.width < config.base_length else config.base_length center_radius = smaller/10 vertical_center = (config.base_length-config.cover_area)/2 center = (config.width/2,vertical_center,0) cylinder = draw.makeCylinder(center_radius, config.base_thickness, center) base = base.cut(cylinder) ell_majorradius = smaller/10 ell_minorradius = smaller/20 e1 = (config.width/2+center_radius+ell_majorradius,vertical_center,0) eli = draw.Ellipse((0,0,0),ell_majorradius,ell_minorradius) ellipse = eli.toShape() ellipse_face = draw.Face(draw.Wire(ellipse.Edges)) ellipse = ellipse_face.extrude((0,0,config.base_thickness)) ellipse1 = ellipse.copy() ellipse1.translate(e1) base = base.cut(ellipse1) e2 = (config.width/2-center_radius-ell_majorradius,vertical_center,0) ellipse2 = ellipse.copy() ellipse2.translate(e2) base = base.cut(ellipse2) e3 = (config.width/2,vertical_center + center_radius + ell_majorradius, 0) ellipse3 = ellipse.copy() aTrsf=draw.Matrix() aTrsf.rotateZ(math.pi/2) # rotate around the z-axis ellipse3=ellipse3.transform(aTrsf) ellipse3.translate(e3) base = base.cut(ellipse3) e4 = (config.width/2,vertical_center - center_radius - ell_majorradius, 0) ellipse4 = ellipse.copy() ellipse4=ellipse4.transform(aTrsf) ellipse4.translate(e4) base = base.cut(ellipse4) x = self.picker.pick((1.0)) wood_id = self.get_material('grass', M(texture='bark.jpg')) base.set_material(wood_id, texture_coords=[(0.0, 0.0), (x, 0.0), (x, x), (0.0, x)]) self.add_geoms(base)
def generate(self, config): if config.type == 'square': leg = draw.makeBox(config.leg_thickness, config.leg_thickness, config.leg_height) elif config.type == 'cylinder': origin = (config.leg_thickness/2,config.leg_thickness/2,0) leg = draw.makeCylinder(config.leg_thickness/2, config.leg_height, origin) elif config.type == 'triangular': leg = draw.makePolygon([(config.leg_thickness,0,0),(0,config.leg_thickness,0),(0,0,0)]) leg = leg.extrude((0,0,config.leg_height)) x = self.picker.pick((1.0)) wood_id = self.get_material('grass', M(texture='bark.jpg')) leg.set_material(wood_id, texture_coords=[(0.0, 0.0), (x, 0.0), (x, x), (0.0, x)]) self.add_geoms(leg)
def generate(self, config): C = config self.register_materials() plate = draw.makeBox(C.length, C.width, 0.2) pavement_id = self.get_material('base_%s' % C.pavement) size = self.pavements[C.pavement][-1] x = C.length/size y = C.width/size plate.set_material(pavement_id, 'front', [(x, 0.0), (x, y), (0.0, y), (0.0, 0.0)]) plate.set_material(pavement_id, 'left', [(x, 0.0), (x, y), (0.0, y), (0.0, 0.0)]) plate.set_material(pavement_id, 'right', [(x, y), (0.0, y), (0.0, 0.0), (x, 0.0)]) plate.set_material(pavement_id, 'back', [(x, y), (0.0, y), (0.0, 0.0), (x, 0.0)]) x = self.picker.pick((0.1, 1000.0)) texture_coords=[(0.0, 0.0), (x, 0.0), (x, x), (0.0, x)] sand_id = self.get_material('sand', M(texture='textures/sand.jpg')) plate.set_material(sand_id, 'top', texture_coords) self.add_geom(plate) self.subgen('pavement', (0, 0, 0.25), C.length, C.width, C.pavement)
def generate(self, config): C = config self.leaves_id = self.get_material('leaves', M(texture='tree\\pine_tree.png')) bark_id = self.get_material('bark', M(texture='tree\\bark.jpg')) if C.top_ratio + C.trunk_ratio < 1.0: C.trunk_ratio = 1.0 - C.top_ratio trunk_height = C.height * C.trunk_ratio dia = C.trunk_diameter trunk = draw.makeBox(dia, dia, trunk_height) trunk.set_material(bark_id) trunk.translate((-dia/2., -dia/2., 0)) self.add_geom(trunk) top_height = C.height * C.top_ratio lift_height = C.height - top_height for rotation in (0, math.pi/2, math.pi/4, -math.pi/4): rotation += .01 plate = self.make_plate(top_height, C.width, lift_height, rotation) self.add_geoms(*plate)
def generate(self, config): C = config divider = draw.makeBox(C.width, C.length, C.height) self.add_geom(divider)
def generate(self, config): C = config main_frame = draw.makeBox(C.length, C.width, C.height) wheel_cavity = draw.makeCylinder(C.wheel_radius,C.width,(C.front_overhang,0,0),(0,1,0),2*math.pi) bus = main_frame.cut(wheel_cavity) wheel_cavity = draw.makeCylinder(C.wheel_radius,C.width,(C.length-C.rear_overhang,0,0),(0,1,0),2*math.pi) # Here creating a hollow inside the bus bus_hollow = draw.makeBox(0.9*C.length, 0.9*C.width, 0.9*(C.height-C.wheel_radius),(0.05*C.length,0.05*C.width,C.wheel_radius)) bus = bus.cut(wheel_cavity) bus=bus.cut(bus_hollow) # To create a cut in the front side. cut_cuboid = draw.makeBox(C.width, C.width, C.height-C.wheel_radius,(0,0,C.wheel_radius)) cuboid_transform= draw.Matrix() cuboid_transform.rotateY(-math.pi/4) cut_cuboid = cut_cuboid.transform(cuboid_transform) #C_transform.rotateY(math.pi/4) #cut_cuboid = cut_cuboid.transform(cuboid_transform) #self.add_geom(cut_cuboid) bus = bus.cut(cut_cuboid) # Calling the Window grill # self.subgen('WindowGrill',(C.length/4,0,C.wheel_radius),C.length/5,(C.height-C.wheel_radius)-1,.1*(C.width)) window1 = draw.makeBox(C.length/8,C.width,(C.height-C.wheel_radius)-2,(C.length/5,0,C.height-2)) window2 = draw.makeBox(C.length/8,C.width,(C.height-C.wheel_radius)-2,(2*C.length/5,0,C.height-2)) window3 = draw.makeBox(C.length/8,C.width,(C.height-C.wheel_radius)-2,(3*C.length/5,0,C.height-2)) window4 = draw.makeBox(C.length/8,C.width,(C.height-C.wheel_radius)-2,(4*C.length/5,0,C.height-2)) win_transform = draw.Matrix() #win_transform.rotateX(math.pi/2) #window = window.transform(win_transform) #grill1= draw.makeCylinder(C.height/2,C.length,(0,C.height/4,0),(0,1,0)) #grill2 = draw.makeCylinder(C.height/2,C.length,(0,C.height/2,0),(0,1,0)) bus = bus.cut(window1) bus = bus.cut(window2) bus = bus.cut(window3) bus = bus.cut(window4) #self.add_geom(window) #self.add_geom(grill1) #self.add_geom(grill2) bus_texture = self.get_material('bus_text', M(texture='texture\\bus.jpg')) bus.set_material(bus_texture) self.subgen('Wheelset',(C.front_overhang,0,0),C.wheel_radius,C.width) self.subgen('Wheelset',(C.length-C.rear_overhang,0,0),C.wheel_radius,C.width) # Adding the window grill self.subgen('WindowGrill', (C.length/5,0,(C.height-2)+(C.height-C.wheel_radius-2)/2+.25),.05,C.length/8) self.subgen('WindowGrill', (C.length/5,C.width,(C.height-2)+(C.height-C.wheel_radius-2)/2+.25),.05,C.length/8) self.subgen('WindowGrill', (C.length/5,0,(C.height-2)+(C.height-C.wheel_radius-2)/2+.5),.05,C.length/8) self.subgen('WindowGrill', (C.length/5,C.width,(C.height-2)+(C.height-C.wheel_radius-2)/2+.5),.05,C.length/8) self.subgen('WindowGrill', (2*C.length/5,0,(C.height-2)+(C.height-C.wheel_radius-2)/2+.25),.05,C.length/8) self.subgen('WindowGrill', (2*C.length/5,C.width,(C.height-2)+(C.height-C.wheel_radius-2)/2+.25),.05,C.length/8) self.subgen('WindowGrill', (2*C.length/5,0,(C.height-2)+(C.height-C.wheel_radius-2)/2+.5),.05,C.length/8) self.subgen('WindowGrill', (2*C.length/5,C.width,(C.height-2)+(C.height-C.wheel_radius-2)/2+.5),.05,C.length/8) self.subgen('WindowGrill', (3*C.length/5,0,(C.height-2)+(C.height-C.wheel_radius-2)/2+.25),.05,C.length/8) self.subgen('WindowGrill', (3*C.length/5,C.width,(C.height-2)+(C.height-C.wheel_radius-2)/2+.25),.05,C.length/8) self.subgen('WindowGrill', (3*C.length/5,0,(C.height-2)+(C.height-C.wheel_radius-2)/2+.5),.05,C.length/8) self.subgen('WindowGrill', (3*C.length/5,C.width,(C.height-2)+(C.height-C.wheel_radius-2)/2+.5),.05,C.length/8) self.subgen('WindowGrill', (4*C.length/5,0,(C.height-2)+(C.height-C.wheel_radius-2)/2+.25),.05,C.length/8) self.subgen('WindowGrill', (4*C.length/5,C.width,(C.height-2)+(C.height-C.wheel_radius-2)/2+.25),.05,C.length/8) self.subgen('WindowGrill', (4*C.length/5,0,(C.height-2)+(C.height-C.wheel_radius-2)/2+.5),.05,C.length/8) self.subgen('WindowGrill', (4*C.length/5,C.width,(C.height-2)+(C.height-C.wheel_radius-2)/2+.5),.05,C.length/8) self.add_geom(bus)
def generate(self, config): base = draw.makeBox(config.width, config.base_length, config.base_thickness) self.add_geoms(base)
def create_cuboid(): c = draw.makeBox(2, 4, 6) return c