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:
Diffstat (limited to 'io_scene_gltf2/io')
-rwxr-xr-xio_scene_gltf2/io/com/gltf2_io_constants.py5
-rw-r--r--io_scene_gltf2/io/com/gltf2_io_draco_compression_extension.py15
-rw-r--r--io_scene_gltf2/io/com/gltf2_io_variants.py29
-rwxr-xr-xio_scene_gltf2/io/exp/gltf2_io_binary_data.py7
-rwxr-xr-xio_scene_gltf2/io/exp/gltf2_io_buffer.py2
-rwxr-xr-xio_scene_gltf2/io/imp/gltf2_io_gltf.py9
6 files changed, 54 insertions, 13 deletions
diff --git a/io_scene_gltf2/io/com/gltf2_io_constants.py b/io_scene_gltf2/io/com/gltf2_io_constants.py
index 19ead516..816220d9 100755
--- a/io_scene_gltf2/io/com/gltf2_io_constants.py
+++ b/io_scene_gltf2/io/com/gltf2_io_constants.py
@@ -118,6 +118,9 @@ class TextureWrap(IntEnum):
MirroredRepeat = 33648
Repeat = 10497
+class BufferViewTarget(IntEnum):
+ ARRAY_BUFFER = 34962
+ ELEMENT_ARRAY_BUFFER = 34963
#################
# LEGACY DEFINES
@@ -145,3 +148,5 @@ GLTF_DATA_TYPE_VEC4 = "VEC4"
GLTF_DATA_TYPE_MAT2 = "MAT2"
GLTF_DATA_TYPE_MAT3 = "MAT3"
GLTF_DATA_TYPE_MAT4 = "MAT4"
+
+GLTF_IOR = 1.5 \ No newline at end of file
diff --git a/io_scene_gltf2/io/com/gltf2_io_draco_compression_extension.py b/io_scene_gltf2/io/com/gltf2_io_draco_compression_extension.py
index 28f06e51..b9f9ccec 100644
--- a/io_scene_gltf2/io/com/gltf2_io_draco_compression_extension.py
+++ b/io_scene_gltf2/io/com/gltf2_io_draco_compression_extension.py
@@ -27,7 +27,7 @@ def dll_path() -> Path:
'darwin': blender_root.parent / 'Resources' / python_lib / python_version / 'site-packages'
}.get(sys.platform)
else:
- path = Path(path)
+ return Path(path)
library_name = {
'win32': '{}.dll'.format(lib_name),
@@ -46,12 +46,11 @@ def dll_exists(quiet=False) -> bool:
Checks whether the DLL path exists.
:return: True if the DLL exists.
"""
- exists = dll_path().exists()
+ path = dll_path()
+ exists = path.exists() and path.is_file()
if quiet is False:
- print("'{}' ".format(dll_path().absolute()) + ("exists, draco mesh compression is available" if exists else
- "{} {} {}".format(
- "does not exist, draco mesh compression not available,",
- "please add it or create environment variable BLENDER_EXTERN_DRACO_LIBRARY_PATH",
- "pointing to the folder"
- )))
+ if exists:
+ print_console('INFO', 'Draco mesh compression is available, use library at %s' % dll_path().absolute())
+ else:
+ print_console('ERROR', 'Draco mesh compression is not available because library could not be found at %s' % dll_path().absolute())
return exists
diff --git a/io_scene_gltf2/io/com/gltf2_io_variants.py b/io_scene_gltf2/io/com/gltf2_io_variants.py
new file mode 100644
index 00000000..3824fee4
--- /dev/null
+++ b/io_scene_gltf2/io/com/gltf2_io_variants.py
@@ -0,0 +1,29 @@
+# SPDX-License-Identifier: Apache-2.0
+# Copyright 2018-2022 The glTF-Blender-IO authors.
+
+from io_scene_gltf2.io.com.gltf2_io import from_dict, from_union, from_none, from_float, from_str, from_list
+from io_scene_gltf2.io.com.gltf2_io import to_float, to_class
+
+class Variant:
+ """defines variant for use with glTF 2.0."""
+ def __init__(self, name, extensions, extras):
+ self.name = name
+ self.extensions = extensions
+ self.extras = extras
+
+ @staticmethod
+ def from_dict(obj):
+ assert isinstance(obj, dict)
+ name = from_union([from_str, from_none], obj.get("name"))
+ extensions = from_union([lambda x: from_dict(lambda x: from_dict(lambda x: x, x), x), from_none],
+ obj.get("extensions"))
+ extras = obj.get("extras")
+ return Variant(name, extensions, extras)
+
+ def to_dict(self):
+ result = {}
+ result["name"] = from_union([from_str, from_none], self.name)
+ result["extensions"] = from_union([lambda x: from_dict(lambda x: from_dict(lambda x: x, x), x), from_none],
+ self.extensions)
+ result["extras"] = self.extras
+ return result
diff --git a/io_scene_gltf2/io/exp/gltf2_io_binary_data.py b/io_scene_gltf2/io/exp/gltf2_io_binary_data.py
index 10405551..6a617628 100755
--- a/io_scene_gltf2/io/exp/gltf2_io_binary_data.py
+++ b/io_scene_gltf2/io/exp/gltf2_io_binary_data.py
@@ -9,10 +9,11 @@ from io_scene_gltf2.io.com import gltf2_io_constants
class BinaryData:
"""Store for gltf binary data that can later be stored in a buffer."""
- def __init__(self, data: bytes):
+ def __init__(self, data: bytes, bufferViewTarget=None):
if not isinstance(data, bytes):
raise TypeError("Data is not a bytes array")
self.data = data
+ self.bufferViewTarget = bufferViewTarget
def __eq__(self, other):
return self.data == other.data
@@ -21,9 +22,9 @@ class BinaryData:
return hash(self.data)
@classmethod
- def from_list(cls, lst: typing.List[typing.Any], gltf_component_type: gltf2_io_constants.ComponentType):
+ def from_list(cls, lst: typing.List[typing.Any], gltf_component_type: gltf2_io_constants.ComponentType, bufferViewTarget=None):
format_char = gltf2_io_constants.ComponentType.to_type_code(gltf_component_type)
- return BinaryData(array.array(format_char, lst).tobytes())
+ return BinaryData(array.array(format_char, lst).tobytes(), bufferViewTarget)
@property
def byte_length(self):
diff --git a/io_scene_gltf2/io/exp/gltf2_io_buffer.py b/io_scene_gltf2/io/exp/gltf2_io_buffer.py
index 5fae3834..4b70e789 100755
--- a/io_scene_gltf2/io/exp/gltf2_io_buffer.py
+++ b/io_scene_gltf2/io/exp/gltf2_io_buffer.py
@@ -35,7 +35,7 @@ class Buffer:
extensions=None,
extras=None,
name=None,
- target=None
+ target=binary_data.bufferViewTarget
)
return buffer_view
diff --git a/io_scene_gltf2/io/imp/gltf2_io_gltf.py b/io_scene_gltf2/io/imp/gltf2_io_gltf.py
index 9f096e69..75ce7265 100755
--- a/io_scene_gltf2/io/imp/gltf2_io_gltf.py
+++ b/io_scene_gltf2/io/imp/gltf2_io_gltf.py
@@ -28,6 +28,7 @@ class glTFImporter():
self.accessor_cache = {}
self.decode_accessor_cache = {}
self.import_user_extensions = import_settings['import_user_extensions']
+ self.variant_mapping = {} # Used to map between mgltf material idx and blender material, for Variants
if 'loglevel' not in self.import_settings.keys():
self.import_settings['loglevel'] = logging.ERROR
@@ -44,7 +45,13 @@ class glTFImporter():
'KHR_texture_transform',
'KHR_materials_clearcoat',
'KHR_mesh_quantization',
- 'KHR_draco_mesh_compression'
+ 'KHR_draco_mesh_compression',
+ 'KHR_materials_variants',
+ 'KHR_materials_emissive_strength',
+ 'KHR_materials_transmission',
+ 'KHR_materials_specular',
+ 'KHR_materials_sheen',
+ 'KHR_materials_ior'
]
# Add extensions required supported by custom import extensions