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>2018-12-02 10:33:14 +0300
committerJulien Duroure <julien.duroure@gmail.com>2018-12-02 10:33:14 +0300
commitdcfaadf5feb1e6c92a889bf2bb162a8a1f74fcd3 (patch)
treefbc759ab8eba56510e83d7807ffab95ba6650457
parent9fcbabfcab0f60910c196226c79874edcae80b65 (diff)
glTF: fix vertex color import + export option tweaks
-rwxr-xr-xio_scene_gltf2/__init__.py26
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_export_keys.py1
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_cameras.py4
-rwxr-xr-xio_scene_gltf2/blender/imp/gltf2_blender_mesh.py10
-rwxr-xr-xio_scene_gltf2/io/exp/gltf2_io_export.py2
5 files changed, 11 insertions, 32 deletions
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 7a6ce124..5f226b52 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -94,13 +94,6 @@ class ExportGLTF2_Base:
default=False
)
- export_strip: BoolProperty(
- name='Strip Whitespace',
- description='Makes JSON portion of export more compact, but harder to' \
- ' read and edit by hand',
- default=False
- )
-
export_indices: EnumProperty(
name='Maximum Indices Type',
items=(('UNSIGNED_BYTE', 'Unsigned Byte', ''),
@@ -132,7 +125,7 @@ class ExportGLTF2_Base:
export_tangents: BoolProperty(
name='Tangents',
description='Export vertex tangents with meshes',
- default=True
+ default=False
)
export_materials: BoolProperty(
@@ -153,13 +146,6 @@ class ExportGLTF2_Base:
default=False
)
- export_camera_infinite: BoolProperty(
- name='Infinite Perspective',
- description='Sets perspective cameras to use infinite perspective' \
- ' projections',
- default=False
- )
-
export_selected: BoolProperty(
name='Selected Objects',
description='Export selected objects only',
@@ -262,7 +248,7 @@ class ExportGLTF2_Base:
export_morph_tangent: BoolProperty(
name='Shape Key Tangents',
description='Export vertex tangents with shape keys (morph targets)',
- default=True
+ default=False
)
export_lights: BoolProperty(
@@ -335,7 +321,6 @@ class ExportGLTF2_Base:
export_settings['gltf_copyright'] = self.export_copyright
export_settings['gltf_embed_buffers'] = self.export_embed_buffers
export_settings['gltf_embed_images'] = self.export_embed_images
- export_settings['gltf_strip'] = self.export_strip
export_settings['gltf_indices'] = self.export_indices
export_settings['gltf_force_indices'] = self.export_force_indices
export_settings['gltf_texcoords'] = self.export_texcoords
@@ -344,10 +329,6 @@ class ExportGLTF2_Base:
export_settings['gltf_materials'] = self.export_materials
export_settings['gltf_colors'] = self.export_colors
export_settings['gltf_cameras'] = self.export_cameras
- if self.export_cameras:
- export_settings['gltf_camera_infinite'] = self.export_camera_infinite
- else:
- export_settings['gltf_camera_infinite'] = False
export_settings['gltf_selected'] = self.export_selected
export_settings['gltf_layers'] = True #self.export_layers
export_settings['gltf_extras'] = self.export_extras
@@ -402,7 +383,6 @@ class ExportGLTF2_Base:
if self.export_format == 'ASCII':
col.prop(self, 'export_embed_buffers')
col.prop(self, 'export_embed_images')
- col.prop(self, 'export_strip')
col = layout.box().column()
col.label(text='Nodes:') # , icon='OOPS')
@@ -428,8 +408,6 @@ class ExportGLTF2_Base:
col = layout.box().column()
col.label(text='Objects:') # , icon='OBJECT_DATA')
col.prop(self, 'export_cameras')
- if self.export_cameras:
- col.prop(self, 'export_camera_infinite')
col = layout.box().column()
col.label(text='Materials:') # , icon='MATERIAL_DATA')
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_export_keys.py b/io_scene_gltf2/blender/exp/gltf2_blender_export_keys.py
index 9e47645a..06271a04 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_export_keys.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_export_keys.py
@@ -40,7 +40,6 @@ BINARY_FILENAME = 'gltf_binaryfilename'
YUP = 'gltf_yup'
MORPH = 'gltf_morph'
INDICES = 'gltf_indices'
-CAMERA_INFINITE = 'gltf_camera_infinite'
BAKE_SKINS = 'gltf_bake_skins'
TEX_COORDS = 'gltf_texcoords'
COLORS = 'gltf_colors'
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 b09092ca..9640a7ce 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_cameras.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_cameras.py
@@ -106,9 +106,7 @@ def __gather_perspective(blender_object, export_settings):
perspective.yfov = 2.0 * math.atan(math.tan(blender_camera.angle * 0.5) / perspective.aspectRatio)
perspective.znear = blender_camera.clip_start
-
- if not export_settings[gltf2_blender_export_keys.CAMERA_INFINITE]:
- perspective.zfar = blender_camera.clip_end
+ perspective.zfar = blender_camera.clip_end
return perspective
return None
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
index 88396455..aafb9498 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
@@ -143,7 +143,7 @@ class BlenderMesh():
if 'COLOR_0' in prim.attributes.keys():
# Create vertex color, once only per object
if vertex_color is None:
- vertex_color = obj.data.vertex_colors.new("COLOR_0")
+ vertex_color = obj.data.vertex_colors.new(name="COLOR_0")
color_data = BinaryData.get_data_from_accessor(gltf, prim.attributes['COLOR_0'])
@@ -152,7 +152,11 @@ class BlenderMesh():
vert_idx = mesh.loops[loop_idx].vertex_index
if vert_idx in range(offset, offset + prim.vertices_length):
cpt_idx = vert_idx - offset
- vertex_color.data[loop_idx].color = color_data[cpt_idx][0:3]
- # TODO : no alpha in vertex color
+ # check dimension, and add alpha if needed
+ if len(color_data[cpt_idx]) == 3:
+ vertex_color_data = color_data[cpt_idx] + (1.0,)
+ else:
+ vertex_color_data = color_data[cpt_idx]
+ vertex_color.data[loop_idx].color = vertex_color_data
offset = offset + prim.vertices_length
diff --git a/io_scene_gltf2/io/exp/gltf2_io_export.py b/io_scene_gltf2/io/exp/gltf2_io_export.py
index 561b2ac1..ebfad744 100755
--- a/io_scene_gltf2/io/exp/gltf2_io_export.py
+++ b/io_scene_gltf2/io/exp/gltf2_io_export.py
@@ -32,7 +32,7 @@ def save_gltf(glTF, export_settings, encoder, glb_buffer):
indent = None
separators = separators = (',', ':')
- if export_settings['gltf_format'] == 'ASCII' and not export_settings['gltf_strip']:
+ if export_settings['gltf_format'] == 'ASCII':
indent = 4
# The comma is typically followed by a newline, so no trailing whitespace is needed on it.
separators = separators = (',', ' : ')