Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Duroure <julien.duroure@gmail.com>2022-10-21 19:45:23 +0300
committerJulien Duroure <julien.duroure@gmail.com>2022-10-21 19:45:23 +0300
commit8a2443844daf7bd32b3aafac53370966f2d330f4 (patch)
tree26abcbcc6638ded5494519cfb0a105c28828799b
parentcd2d9df92577b860419c5b591b9bdd97eb70803d (diff)
glTF importer/exporter: fix ortho camera fram import/export
-rwxr-xr-xio_scene_gltf2/__init__.py2
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_cameras.py18
-rwxr-xr-xio_scene_gltf2/blender/imp/gltf2_blender_camera.py2
3 files changed, 16 insertions, 6 deletions
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index d06b8b08..2c61a9ed 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -4,7 +4,7 @@
bl_info = {
'name': 'glTF 2.0 format',
'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
- "version": (3, 4, 38),
+ "version": (3, 4, 39),
'blender': (3, 3, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_cameras.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_cameras.py
index cee3cb06..d169db34 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_cameras.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_cameras.py
@@ -58,8 +58,16 @@ def __gather_orthographic(blender_camera, export_settings):
znear=None
)
- orthographic.xmag = blender_camera.ortho_scale
- orthographic.ymag = blender_camera.ortho_scale
+ _render = bpy.context.scene.render
+ scene_x = _render.resolution_x * _render.pixel_aspect_x
+ scene_y = _render.resolution_y * _render.pixel_aspect_y
+ scene_square = max(scene_x, scene_y)
+ del _render
+
+ # `Camera().ortho_scale` (and also FOV FTR) maps to the maximum of either image width or image height— This is the box that gets shown from camera view with the checkbox `.show_sensor = True`.
+
+ orthographic.xmag = blender_camera.ortho_scale * (scene_x / scene_square) / 2
+ orthographic.ymag = blender_camera.ortho_scale * (scene_y / scene_square) / 2
orthographic.znear = blender_camera.clip_start
orthographic.zfar = blender_camera.clip_end
@@ -79,9 +87,11 @@ def __gather_perspective(blender_camera, export_settings):
znear=None
)
- width = bpy.context.scene.render.pixel_aspect_x * bpy.context.scene.render.resolution_x
- height = bpy.context.scene.render.pixel_aspect_y * bpy.context.scene.render.resolution_y
+ _render = bpy.context.scene.render
+ width = _render.pixel_aspect_x * _render.resolution_x
+ height = _render.pixel_aspect_y * _render.resolution_y
perspective.aspect_ratio = width / height
+ del _render
if width >= height:
if blender_camera.sensor_fit != 'VERTICAL':
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_camera.py b/io_scene_gltf2/blender/imp/gltf2_blender_camera.py
index 6a580e03..9ee78946 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_camera.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_camera.py
@@ -28,7 +28,7 @@ class BlenderCamera():
if pycamera.type == "orthographic":
cam.type = "ORTHO"
- # TODO: xmag/ymag
+ cam.ortho_scale = max(pycamera.orthographic.xmag, pycamera.orthographic.ymag) * 2
cam.clip_start = pycamera.orthographic.znear
cam.clip_end = pycamera.orthographic.zfar