def generate(self, config): cylinder_height = (config.leg_height-config.leg_thickness*2)/2 base_cylinder = draw.makeCylinder(config.leg_thickness/2, cylinder_height) current_height = cylinder_height + config.leg_thickness/2 base_sphere = draw.makeSphere(config.leg_thickness/2, (0,0,current_height)) current_height = current_height + config.leg_thickness/2 top_cylinder = draw.makeCylinder(config.leg_thickness/2, cylinder_height,(0,0,current_height)) current_height = current_height + cylinder_height \ + config.leg_thickness/2 top_sphere = draw.makeSphere(config.leg_thickness/2, (0,0,current_height)) # leg = draw.makeCompound([base_cylinder, base_sphere, top_cylinder, top_sphere]) # leg.translate((config.leg_thickness/2,config.leg_thickness/2,0)) base_cylinder.translate((config.leg_thickness/2,config.leg_thickness/2,0)) base_sphere.translate((config.leg_thickness/2,config.leg_thickness/2,0)) top_cylinder.translate((config.leg_thickness/2,config.leg_thickness/2,0)) top_sphere.translate((config.leg_thickness/2,config.leg_thickness/2,0)) self.add_geoms([base_cylinder, base_sphere, top_cylinder, top_sphere])
def generate(self, config): cylinder_height = (config.leg_height-config.leg_thickness*2)/2 base_cylinder = draw.makeCylinder(config.leg_thickness/2, cylinder_height) current_height = cylinder_height + config.leg_thickness/2 base_sphere = draw.makeSphere(config.leg_thickness/2, (0,0,current_height)) current_height = current_height + config.leg_thickness/2 top_cylinder = draw.makeCylinder(config.leg_thickness/2, cylinder_height,(0,0,current_height)) current_height = current_height + cylinder_height \ + config.leg_thickness/2 top_sphere = draw.makeSphere(config.leg_thickness/2, (0,0,current_height)) # leg = draw.makeCompound([base_cylinder, base_sphere, top_cylinder, top_sphere]) # leg.translate((config.leg_thickness/2,config.leg_thickness/2,0)) base_cylinder.translate((config.leg_thickness/2,config.leg_thickness/2,0)) base_sphere.translate((config.leg_thickness/2,config.leg_thickness/2,0)) top_cylinder.translate((config.leg_thickness/2,config.leg_thickness/2,0)) top_sphere.translate((config.leg_thickness/2,config.leg_thickness/2,0)) for geom in [base_cylinder, top_cylinder]: x = self.picker.pick((1.0)) wood_id = self.get_material('grass', M(texture='bark.jpg')) geom.set_material(wood_id, texture_coords=[(0.0, 0.0), (x, 0.0), (x, x), (0.0, x)]) self.add_geoms([base_cylinder, base_sphere, top_cylinder, top_sphere])
def generate(self, config): C = config cylinder = draw.makeCylinder(3, 10, (0, 0, 0), (1, 0, 0)) sphere = draw.makeSphere(5, (5, 0, 0)) if C.cut: diff = cylinder.cut(sphere) self.add_geom(diff) if C.common: common = cylinder.common(sphere) self.add_geom(common) if C.fuse: fuse = cylinder.fuse(sphere) self.add_geom(fuse)
def generate(self, config): # x is on horizontal, y is on depthwards, z is on upwards ''' z y | * | * | * - - - x all units are in metres ''' # in short ''' pnt is where the object has to be created dir is in which directiong it has to be created draw.makeBox(length, width, height, pnt=(0,0,0), dir=(0,0,1)) draw.makeSphere(radius, pnt=(0,0,0), dir=(0,0,1), angle1=0.5*PI, angle2=0.5*PI, angle3=2*PI) draw.makeCylinder(radius, height, pnt=(0,0,0), dir=(0,0,1), angle=2*PI) draw.makePlane(length,width, pnt=(0,0,0), dir=(0,0,1)) draw.makePolygon([]) -- Make a polygon of a list of points ''' C = config if C.box: box = draw.makeBox(1, 1, 1) self.add_geom(box) # adding box to the scene pnt = (2, 2, 2) o_box = draw.makeBox(1, 1, 1, pnt) self.add_geom(o_box) # adding another box at different point in scene if C.sphere: sphere = draw.makeSphere(2) self.add_geom(sphere) pnt = (2, 2, 2) o_sphere = draw.makeSphere(2, pnt) self.add_geom(o_sphere) if C.cylinder: cylinder = draw.makeCylinder(1, 1) self.add_geom(cylinder) pnt = (2, 2, 2) o_cylinder = draw.makeCylinder(1, 1, pnt) self.add_geom(o_cylinder) if C.plane: plane = draw.makePlane(1, 1) self.add_geom(plane) pnt = (2, 2, 2) o_plane = draw.makePlane(1, 1, pnt) self.add_geom(o_plane) if C.polygon: polygon = draw.makePolygon([(0, 0, 0), (1, 0, 0), (1, 0, 1), (0, 0, 1), (0, 0, 0)]) # this returns a wire connecting points face = draw.Face(polygon) # filling up the wire with mass, u can also do other things with the wire self.add_geom(face)