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-08-06 13:11:15 +0300
committerJulien Duroure <julien.duroure@gmail.com>2022-08-06 13:11:15 +0300
commitef0027e72d295f5bbae1905c6260878851131eef (patch)
tree332450a5c63df82f711aae005c8c1fb85a5f5280
parentc58c8f3c3525247c6f584684260eae4ea87a57a3 (diff)
glTF exporter: add bufferView Target at export
-rwxr-xr-xio_scene_gltf2/__init__.py2
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_primitive_attributes.py4
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py2
-rwxr-xr-xio_scene_gltf2/io/com/gltf2_io_constants.py3
-rwxr-xr-xio_scene_gltf2/io/exp/gltf2_io_binary_data.py7
-rwxr-xr-xio_scene_gltf2/io/exp/gltf2_io_buffer.py2
6 files changed, 12 insertions, 8 deletions
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index e3e2c483..6146be8a 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, 3, 21),
+ "version": (3, 3, 22),
'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_primitive_attributes.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitive_attributes.py
index f28a1f10..8572d185 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitive_attributes.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitive_attributes.py
@@ -44,7 +44,7 @@ def array_to_accessor(array, component_type, data_type, include_max_and_min=Fals
amin = np.amin(array, axis=0).tolist()
return gltf2_io.Accessor(
- buffer_view=gltf2_io_binary_data.BinaryData(array.tobytes()),
+ buffer_view=gltf2_io_binary_data.BinaryData(array.tobytes(), gltf2_io_constants.BufferViewTarget.ARRAY_BUFFER),
byte_offset=None,
component_type=component_type,
count=len(array),
@@ -142,7 +142,7 @@ def __gather_colors(blender_primitive, export_settings):
comp_type = gltf2_io_constants.ComponentType.Float
attributes[color_id] = gltf2_io.Accessor(
- buffer_view=gltf2_io_binary_data.BinaryData(colors.tobytes()),
+ buffer_view=gltf2_io_binary_data.BinaryData(colors.tobytes(), gltf2_io_constants.BufferViewTarget.ARRAY_BUFFER),
byte_offset=None,
component_type=comp_type,
count=len(colors),
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py
index b2ffb6b3..576a1418 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py
@@ -150,7 +150,7 @@ def __gather_indices(blender_primitive, blender_mesh, modifiers, export_settings
return None
element_type = gltf2_io_constants.DataType.Scalar
- binary_data = gltf2_io_binary_data.BinaryData(indices.tobytes())
+ binary_data = gltf2_io_binary_data.BinaryData(indices.tobytes(), bufferViewTarget=gltf2_io_constants.BufferViewTarget.ELEMENT_ARRAY_BUFFER)
return gltf2_blender_gather_accessors.gather_accessor(
binary_data,
component_type,
diff --git a/io_scene_gltf2/io/com/gltf2_io_constants.py b/io_scene_gltf2/io/com/gltf2_io_constants.py
index 175804a3..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
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