diff --git a/export/camera.py b/export/camera.py index b4b49187..cc0204cd 100644 --- a/export/camera.py +++ b/export/camera.py @@ -45,9 +45,10 @@ def convert(exporter, scene, context=None, is_camera_moving=False): def _view_ortho(scene, context, definitions): cam_matrix = Matrix(context.region_data.view_matrix).inverted() lookat_orig, lookat_target, up_vector = _calc_lookat(cam_matrix, scene) + world_scale = utils.get_worldscale(scene, False) definitions["type"] = "orthographic" - zoom = 0.915 * context.region_data.view_distance*35/context.space_data.lens + zoom = 0.915 * world_scale * context.region_data.view_distance*35/context.space_data.lens # Move the camera origin away from the viewport center to avoid clipping origin = Vector(lookat_orig) @@ -77,16 +78,18 @@ def _view_persp(scene, context, definitions): def _view_camera(scene, context, definitions): camera = scene.camera lookat_orig, lookat_target, up_vector = _calc_lookat(camera.matrix_world, scene) + world_scale = utils.get_worldscale(scene, False) + definitions["lookat.orig"] = lookat_orig definitions["lookat.target"] = lookat_target definitions["up"] = up_vector # Magic zoom formula for camera viewport zoom from Cycles export code - zoom = 4 / ((math.sqrt(2) + context.region_data.view_camera_zoom / 50) ** 2) + zoom = 4 / ((math.sqrt(2) + (context.region_data.view_camera_zoom * world_scale) / 50) ** 2) if camera.data.type == "ORTHO": definitions["type"] = "orthographic" - zoom *= 0.5 * camera.data.ortho_scale + zoom *= 0.5 * world_scale * camera.data.ortho_scale elif camera.data.type == "PANO": definitions["type"] = "environment" elif camera.data.type == "PERSP": @@ -103,6 +106,7 @@ def _view_camera(scene, context, definitions): def _final(scene, definitions): camera = scene.camera lookat_orig, lookat_target, up_vector = _calc_lookat(camera.matrix_world, scene) + world_scale = utils.get_worldscale(scene, False) definitions["lookat.orig"] = lookat_orig definitions["lookat.target"] = lookat_target definitions["up"] = up_vector @@ -110,7 +114,7 @@ def _final(scene, definitions): if camera.data.type == "ORTHO": cam_type = "orthographic" - zoom = 0.5 * camera.data.ortho_scale + zoom = 0.5 * world_scale * camera.data.ortho_scale elif camera.data.type == "PANO": cam_type = "environment" diff --git a/utils/__init__.py b/utils/__init__.py index f035b6c9..e2a782f6 100644 --- a/utils/__init__.py +++ b/utils/__init__.py @@ -177,6 +177,7 @@ def calc_filmsize_raw(scene, context=None): def calc_filmsize(scene, context=None): border_min_x, border_max_x, border_min_y, border_max_y = calc_blender_border(scene, context) width_raw, height_raw = calc_filmsize_raw(scene, context) + world_scale = get_worldscale(scene, False) if context: # Viewport render @@ -187,7 +188,7 @@ def calc_filmsize(scene, context=None): height = int(height_raw * border_max_y) - int(height_raw * border_min_y) else: # Camera viewport - zoom = 0.25 * ((math.sqrt(2) + context.region_data.view_camera_zoom / 50) ** 2) + zoom = 0.25 * ((math.sqrt(2) + context.region_data.view_camera_zoom * world_scale / 50) ** 2) aspectratio, aspect_x, aspect_y = calc_aspect(scene.render.resolution_x * scene.render.pixel_aspect_x, scene.render.resolution_y * scene.render.pixel_aspect_y, scene.camera.data.sensor_fit) @@ -252,11 +253,12 @@ def calc_screenwindow(zoom, shift_x, shift_y, scene, context=None): width_raw, height_raw = calc_filmsize_raw(scene, context) border_min_x, border_max_x, border_min_y, border_max_y = calc_blender_border(scene, context) + world_scale = get_worldscale(scene, False) # Following: Black Magic scale = 1 if scene.camera and scene.camera.data.type == "ORTHO": - scale = 0.5 * scene.camera.data.ortho_scale + scale = 0.5 * scene.camera.data.ortho_scale * world_scale offset_x = 0 offset_y = 0 @@ -275,7 +277,7 @@ def calc_screenwindow(zoom, shift_x, shift_y, scene, context=None): scene.camera.data.sensor_fit) if scene.camera and scene.camera.data.type == "ORTHO": - zoom = 0.5 * scene.camera.data.ortho_scale + zoom = 0.5 * scene.camera.data.ortho_scale * world_scale else: # No border aspectratio, xaspect, yaspect = calc_aspect(width_raw, height_raw, scene.camera.data.sensor_fit)