glTF importer: set camera near/far

This commit is contained in:
Julien Duroure 2020-04-11 13:43:31 +02:00
parent 02ca41d48e
commit 43148f1749
2 changed files with 18 additions and 10 deletions

View File

@ -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',

View File

@ -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: lot's of work for camera here...
if hasattr(pycamera, "znear"):
cam.clip_start = pycamera.znear
# TODO: fov/aspect ratio
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