GazzolaLab / Blender-Soft-Rod

Soft Arm data visualization using Blender
1 stars 0 forks source link

Set up camera #23

Closed hanson-hschang closed 5 days ago

hanson-hschang commented 1 month ago

Currently, the camera in the results of the .blend file is initialized from a far distance. It might be better to have a command to set camera location, look at and some other camera properties. (Might be useful to have similar things as the one in povray?

hanson-hschang commented 1 month ago

Instead of camera, blender python implement region_3d in viewport (see the following reference)

hanson-hschang commented 1 month ago

The following implementation works:

def find_area(area_type: str) -> Optional[bpy.types.Area]:
    try:
        for area in bpy.data.window_managers[0].windows[0].screen.areas:
            if area.type == area_type:
                return area
        return None
    except:
        return None

def set_view_distance(distance: float) -> None:
    assert (
        isinstance(distance, (int, float)) and distance > 0
    ), "distance must be a positive number"
    area_view_3d = find_area("VIEW_3D")
    region_3d = area_view_3d.spaces[0].region_3d
    region_3d.view_distance = distance
hanson-hschang commented 1 month ago

With commit 8ce65ad, it now can set view distance. Still missing other property, e.g. look_at, view_position, rotation... etc

hanson-hschang commented 5 days ago

Branch merge #28 closes this issue.