def standardfile():
    return [
        pv.incfiles(),
        pv.skysphere(),
        pv.plane("y",0,"Green"),
        pv.camera([50,50,-80],[0,20,100]),
        pv.lightsource([500,500,1000],"White"),
        building(0,0,0,10),
        ]
def run():
    pv.runpov([
        pv.incfiles(),
        #         pv.plane("y",0,"Green"),
        burners(0,0,0),
        pv.camera([0,100,-100],[0,0,0]),
        pv.lightsource([0,150,-150],"White"),
        ],"cookingrobot")
    pv.display("cookingrobot")
def povfile():
    return [
        pv.incfiles(),
#         pv.skysphere(),
#         pv.plane("y",0,"White"),
        bikeframe(),
        bikeseat(),
        pv.box([0,0,0],[10,2,10],"Grey"),
        pv.camera([4,1,3],[5,0.5,5]),
        pv.lightsource([5,1.9,5],"White"),
        ]
示例#4
0
def _position_camera(image, width, height, depth, make_3d):
    import math
    import povray as pr

    CAMERA_HEIGHT = depth * 1.2
    LIGHT_ANGLE = 70  # lower means longer shadows, darker colors
    LIGHT_COLOR = 1, 1, 1

    w = image.handle.write

    # Set the camera to the middle of the plot, looking down.
    # Have to look at the middle of the entire plot, or else the
    # borders will be off.
    x_mid, y_mid, z_mid = width * 0.5, height * 0.5, depth * 0.5
    if not make_3d:
        # Default camera location.
        camera = (x_mid, y_mid, -CAMERA_HEIGHT)
        #look = (x_mid, y_mid, z_mid)   # should be -z_mid?
        look = (x_mid, y_mid, 0)
        dist_scale = 1.0
        # Make this a bit dimmer to compensate for the fact that the
        # 3D projection is further away.
        w(pr.global_settings(pr.ambient_light(0.67, 0.67, 0.67)))
        w("\n")
    else:
        camera = (width * 0.60, height * 0.50, -CAMERA_HEIGHT)
        look = (x_mid * 0.25, y_mid * 0.35, z_mid)
        dist_scale = 1.5
        #dist_scale = 1.0
        #camera = (width*0.70, height*0.50, -depth*1.2)
        #look = (x_mid*0.25, y_mid*0.35, z_mid)
        #dist_scale = 1.35

    w(
        pr.camera(
            pr.projection("orthographic"),
            pr.location(*camera),
            pr.right(width * dist_scale, 0, 0),
            pr.up(0, height * dist_scale, 0),
            pr.look_at(*look),
        ))

    # The light source is at the upper right of the plot, shining
    # toward the lower left.  Calculate the height such that the
    # light is shining at a specific angle relative to the plane
    # of the plot.  Lower LIGHT_ANGLE means light source is closer
    # to the plane (longer shadows).
    light_x = width * 0.95
    light_y = height * 0.95
    target_x = width * 0.15
    target_y = height * 0.15
    side = math.sqrt((light_x - target_x)**2 + (light_y - target_y)**2)
    z = side * math.tan(math.pi * LIGHT_ANGLE / 180.0)
    #print z
    w(
        pr.light_source(
            pr.vector(light_x, light_y, -z),
            pr.color(*LIGHT_COLOR),
            pr.light_type("parallel"),
        ))
    w("\n")