Beispiel #1
0
    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])
Beispiel #2
0
    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])
Beispiel #3
0
    def generate(self, config):
        C = config

        wheel = draw.makeCylinder(C.wheel_radius-.25,C.height,(0,0,0),(0,1,0),2*math.pi)
        wheel_shape =  draw.makeCylinder(C.wheel_radius-.25,C.height-2,(0,1,0),(0,1,0),2*math.pi)
	wheel = wheel.cut(wheel_shape)
	alloy1 = draw.makeCylinder(C.wheel_radius-1,.01,(0,-.01,0),(0,1,0),2*math.pi)
	alloy2 = draw.makeCylinder(C.wheel_radius-1,.01,(0,C.height,0),(0,1,0),2*math.pi)
	axle = draw.makeCylinder(C.wheel_radius-.9*C.wheel_radius,C.height,(0,0,0),(0,1,0),2*math.pi)
	wheel_texture = self.get_material('wheel_text', M(texture='texture\\wheel.jpg'))
	wheel.set_material(wheel_texture)
	axle.set_material(wheel_texture)
	self.add_geom(alloy1)
	self.add_geom(alloy2)
	self.add_geom(wheel)
	self.add_geom(axle)
Beispiel #4
0
    def generate(self, config):

        C = config
        if C.depth <= 0:
            return

        trunk = draw.makeCylinder(C.diameter/2,C.height)
        self.add_geom(trunk)

        for i in xrange(C.branches):

            if i == 0:
                at_height = C.height
            else:
                at_height = C.height * self.picker.pick((0.5, 0.75))

            location = Location()

            y_rotation = self.picker.pick((-math.pi/2, math.pi/2))
            z_rotation = self.picker.pick((-math.pi/2, math.pi/2))

            location.translate((0, 0, at_height))
            location.rotate((z_rotation, (0, 0, 1)))
            location.rotate((y_rotation, (0, 1, 0)))

            height = C.height * self.picker.pick((0.25, 0.75))
            diameter = C.diameter * self.picker.pick((0.25, 0.75))

            self.subgen('tree', location, diameter = diameter,
                        depth = C.depth-1, height = height)
Beispiel #5
0
    def generate(self, config):
	
	# A window grill is being developed to be fitted into the bus.
        C = config
	grill = draw.makeCylinder(C.radius,C.height,(0,0,0),(1,0,0))
	grill_texture = self.get_material('wheel_text', M(texture='texture\\wheel.jpg'))
	grill.set_material(grill_texture)
	self.add_geom(grill)
 def generate(self, config):
     
     base = draw.makeCylinder(config.width/2,
                              config.base_thickness,
                              (config.width/2,config.width/2,0))
     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)
Beispiel #7
0
    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)
Beispiel #9
0
    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)
Beispiel #10
0
    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)
Beispiel #11
0
    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)
Beispiel #12
0
 def generate(self, config):
     
     base = draw.makeCylinder(config.width/2,
                              config.base_thickness,
                              (config.width/2,config.width/2,0))
     self.add_geoms(base)
Beispiel #13
0
    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)