예제 #1
0
def get_light_buffer(obj):
    light = obj.data
    light_type_name = light.type
    light_type = common.LightType.SUN
    if light_type_name == "POINT":
        light_type = common.LightType.POINT
    elif light_type_name == "SPOT":
        light_type = common.LightType.SPOT
    elif light_type_name == "SUN":
        light_type = common.LightType.SUN
    elif light_type_name == "AREA":
        light_type = common.LightType.AREA
    else:
        return None
    color = light.color
    power = light.energy
    if bpy.context.scene.render.engine == "CYCLES":
        shadow = light.cycles.cast_shadow
    else:
        shadow = light.use_shadow

    spot_blend = 10.0
    spot_size = 0.0
    if light_type == common.LightType.SPOT:
        spot_size = light.spot_size
        spot_blend = light.spot_blend

    return (common.encode_string(get_object_path(obj)) +
            common.encode_string(light.name_full) +
            common.encode_int(light_type.value) + common.encode_int(shadow) +
            common.encode_color(color) + common.encode_float(power) +
            common.encode_float(spot_size) + common.encode_float(spot_blend))
예제 #2
0
파일: camera.py 프로젝트: nondejus/mixer
def get_camera_buffer(obj):
    cam = obj.data
    focal = cam.lens
    front_clip_plane = cam.clip_start
    far_clip_plane = cam.clip_end
    aperture = cam.dof.aperture_fstop
    sensor_fit_name = cam.sensor_fit
    sensor_fit = common.SensorFitMode.AUTO
    if sensor_fit_name == "AUTO":
        sensor_fit = common.SensorFitMode.AUTO
    elif sensor_fit_name == "HORIZONTAL":
        sensor_fit = common.SensorFitMode.HORIZONTAL
    elif sensor_fit_name == "VERTICAL":
        sensor_fit = common.SensorFitMode.VERTICAL
    sensor_width = cam.sensor_width
    sensor_height = cam.sensor_height

    path = get_object_path(obj)
    return (
        common.encode_string(path)
        + common.encode_string(obj.name_full)
        + common.encode_float(focal)
        + common.encode_float(front_clip_plane)
        + common.encode_float(far_clip_plane)
        + common.encode_float(aperture)
        + common.encode_int(sensor_fit.value)
        + common.encode_float(sensor_width)
        + common.encode_float(sensor_height)
    )
예제 #3
0
def get_camera_buffer(obj):
    cam = obj.data
    focal = cam.lens
    front_clip_plane = cam.clip_start
    far_clip_plane = cam.clip_end
    dof_enabled = cam.dof.use_dof
    aperture = cam.dof.aperture_fstop
    colimator_name = cam.dof.focus_object.name_full if cam.dof.focus_object is not None else ""
    sensor_fit_name = cam.sensor_fit
    sensor_fit = common.SensorFitMode.AUTO
    if sensor_fit_name == "AUTO":
        sensor_fit = common.SensorFitMode.AUTO
    elif sensor_fit_name == "HORIZONTAL":
        sensor_fit = common.SensorFitMode.HORIZONTAL
    elif sensor_fit_name == "VERTICAL":
        sensor_fit = common.SensorFitMode.VERTICAL
    sensor_width = cam.sensor_width
    sensor_height = cam.sensor_height

    path = get_object_path(obj)
    return (common.encode_string(path) + common.encode_string(obj.name_full) +
            common.encode_float(focal) +
            common.encode_float(front_clip_plane) +
            common.encode_float(far_clip_plane) +
            common.encode_bool(dof_enabled) + common.encode_float(aperture) +
            common.encode_string(colimator_name) +
            common.encode_int(sensor_fit.value) +
            common.encode_float(sensor_width) +
            common.encode_float(sensor_height))
예제 #4
0
def send_grease_pencil_connection(client: Client, obj):
    buffer = common.encode_string(get_object_path(obj))
    buffer += common.encode_string(obj.data.name_full)
    client.add_command(
        common.Command(common.MessageType.GREASE_PENCIL_CONNECTION, buffer, 0))
예제 #5
0
def send_empty(client: Client, obj):
    path = get_object_path(obj)
    buffer = common.encode_string(path)
    if buffer:
        client.add_command(common.Command(common.MessageType.EMPTY, buffer, 0))