Beispiel #1
0
def makeCamera(filename, mult=1.0):
    # Exec the file
    code = "\n".join(open(filename).readlines())
    cam = eval(code)
    # Get static parameters
    res = pvr.V2i(int(cam["resx"] * mult), int(cam["resy"] * mult))
    # Get (potentially) time varying parameters
    t0 = cam
    t1 = cam
    if "current_frame" in cam.keys() and "next_frame" in cam.keys():
        t0 = cam["current_frame"]
        t1 = cam["next_frame"]
    posT0 = pvr.Vector(t0["tx"], t0["ty"], t0["tz"])
    eulerT0 = pvr.Euler(radians(t0["rx"]), radians(t0["ry"]),
                        radians(t0["rz"]))
    rotT0 = eulerT0.toQuat()
    fovT0 = degrees(pvr.calculateVerticalFOV(t0["focal"], t0["aperture"], res))
    posT1 = pvr.Vector(t1["tx"], t1["ty"], t1["tz"])
    eulerT1 = pvr.Euler(radians(t1["rx"]), radians(t1["ry"]),
                        radians(t1["rz"]))
    rotT1 = eulerT1.toQuat()
    fovT1 = degrees(pvr.calculateVerticalFOV(t1["focal"], t1["aperture"], res))
    # Create animation curves
    pTimeNext = 1.0 / pvr.RenderGlobals.shutter()
    pos = pvr.VectorCurve()
    rot = pvr.QuatCurve()
    fov = pvr.FloatCurve()
    pos.addSample(0.0, posT0)
    pos.addSample(pTimeNext, posT1)
    rot.addSample(0.0, rotT0)
    rot.addSample(pTimeNext, rotT1)
    fov.addSample(0.0, fovT0)
    fov.addSample(pTimeNext, fovT1)
    # Construct camera
    camera = pvr.PerspectiveCamera()
    camera.setPosition(pos)
    camera.setOrientation(rot)
    camera.setVerticalFOV(fov)
    camera.setClipPlanes(0.1, 1.0)
    camera.setResolution(res)
    return camera
Beispiel #2
0
def makeCamera(filename, mult = 1.0):
    # Exec the file
    code = "\n".join(open(filename).readlines())
    cam = eval(code)
    # Get static parameters
    res = pvr.V2i(int(cam["resx"] * mult), int(cam["resy"] * mult))
    # Get (potentially) time varying parameters
    t0 = cam
    t1 = cam
    if "current_frame" in cam.keys() and "next_frame" in cam.keys():
        t0 = cam["current_frame"]
        t1 = cam["next_frame"]
    posT0 = pvr.Vector(t0["tx"], t0["ty"], t0["tz"])
    eulerT0 = pvr.Euler(radians(t0["rx"]), radians(t0["ry"]), radians(t0["rz"]))
    rotT0 = eulerT0.toQuat()
    fovT0 = degrees(pvr.calculateVerticalFOV(t0["focal"], t0["aperture"], res))
    posT1 = pvr.Vector(t1["tx"], t1["ty"], t1["tz"])
    eulerT1 = pvr.Euler(radians(t1["rx"]), radians(t1["ry"]), radians(t1["rz"]))
    rotT1 = eulerT1.toQuat()
    fovT1 = degrees(pvr.calculateVerticalFOV(t1["focal"], t1["aperture"], res))
    # Create animation curves
    pTimeNext = 1.0 / pvr.RenderGlobals.shutter();
    pos = pvr.VectorCurve()
    rot = pvr.QuatCurve()
    fov = pvr.FloatCurve()
    pos.addSample(0.0, posT0)
    pos.addSample(pTimeNext, posT1)
    rot.addSample(0.0, rotT0)
    rot.addSample(pTimeNext, rotT1)
    fov.addSample(0.0, fovT0)
    fov.addSample(pTimeNext, fovT1)
    # Construct camera
    camera = pvr.PerspectiveCamera()
    camera.setPosition(pos)
    camera.setOrientation(rot)
    camera.setVerticalFOV(fov)
    camera.setClipPlanes(0.1, 1.0)
    camera.setResolution(res)
    return camera
Beispiel #3
0
def standard(resMult=1.0):
    # Settings
    resolution = pvr.V2i(int(2048 * resMult), int(1556 * resMult))
    position = pvr.V3f(0.0, 0.0, 10.0)
    fov = degrees(pvr.calculateVerticalFOV(45.0, 24.0, resolution))
    fovCurve = pvr.FloatCurve()
    fovCurve.addSample(0.0, fov)
    # Create camera
    cam = pvr.PerspectiveCamera()
    cam.setPosition(position)
    cam.setVerticalFOV(fovCurve)
    cam.setClipPlanes(0.1, 1.0)
    cam.setResolution(resolution)
    # Done
    return cam