[Bf-extensions-cvs] [43148f17] master: glTF importer: set camera near/far

Julien Duroure noreply at git.blender.org
Sat Apr 11 13:43:52 CEST 2020


Commit: 43148f17496ce7d51f0377631b6d393756b22724
Author: Julien Duroure
Date:   Sat Apr 11 13:43:31 2020 +0200
Branches: master
https://developer.blender.org/rBA43148f17496ce7d51f0377631b6d393756b22724

glTF importer: set camera near/far

===================================================================

M	io_scene_gltf2/__init__.py
M	io_scene_gltf2/blender/imp/gltf2_blender_camera.py

===================================================================

diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 5d0dbe79..73ffc5a1 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -15,7 +15,7 @@
 bl_info = {
     'name': 'glTF 2.0 format',
     'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
-    "version": (1, 2, 59),
+    "version": (1, 2, 60),
     'blender': (2, 82, 7),
     'location': 'File > Import-Export',
     'description': 'Import-Export as glTF 2.0',
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_camera.py b/io_scene_gltf2/blender/imp/gltf2_blender_camera.py
index e97bd0b8..159a3f9f 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_camera.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_camera.py
@@ -35,17 +35,25 @@ class BlenderCamera():
         # Blender create a perspective camera by default
         if pycamera.type == "orthographic":
             cam.type = "ORTHO"
+
+            # TODO: xmag/ymag
+
+            cam.clip_start = pycamera.orthographic.znear
+            cam.clip_end = pycamera.orthographic.zfar
+
         else:
-            if hasattr(pycamera.perspective, "yfov"):
-                cam.angle_y = pycamera.perspective.yfov
-                cam.lens_unit = "FOV"
-                cam.sensor_fit = "VERTICAL"
+            cam.angle_y = pycamera.perspective.yfov
+            cam.lens_unit = "FOV"
+            cam.sensor_fit = "VERTICAL"
+
+            # TODO: fov/aspect ratio
 
-        # TODO: lot's of work for camera here...
-        if hasattr(pycamera, "znear"):
-            cam.clip_start = pycamera.znear
+            cam.clip_start = pycamera.perspective.znear
+            if pycamera.perspective.zfar is not None:
+                cam.clip_end = pycamera.perspective.zfar
+            else:
+                # Infinite projection
+                cam.clip_end = 1e12  # some big number
 
-        if hasattr(pycamera, "zfar"):
-            cam.clip_end = pycamera.zfar
 
         return cam



More information about the Bf-extensions-cvs mailing list