Skip to content

Commit

Permalink
Merge pull request #8076 from s9k/exporter-uv2-fix
Browse files Browse the repository at this point in the history
Blender exporter: Added second UV layer support
  • Loading branch information
mrdoob committed Feb 7, 2016
2 parents b3ceeb5 + 6b36454 commit 2f8ea12
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions utils/exporters/blender/addons/io_three/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@
SCALE = 'scale'

UV = 'uv'
UV2 = 'uv2'
ATTRIBUTES = 'attributes'
NORMAL = 'normal'
ITEM_SIZE = 'itemSize'
Expand Down
11 changes: 4 additions & 7 deletions utils/exporters/blender/addons/io_three/exporter/api/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,19 @@ def buffer_position(mesh):


@_mesh
def buffer_uv(mesh):
def buffer_uv(mesh, layer=0):
"""
:param mesh:
:param layer: (Default value = 0)
:rtype: []
"""
uvs_ = []
if len(mesh.uv_layers) is 0:
if len(mesh.uv_layers) <= layer:
return uvs_
elif len(mesh.uv_layers) > 1:
# if memory serves me correctly buffer geometry
# only uses one UV layer
logger.warning("%s has more than 1 UV layer", mesh.name)

for uv_data in mesh.uv_layers[0].data:
for uv_data in mesh.uv_layers[layer].data:
uv_tuple = (uv_data.uv[0], uv_data.uv[1])
uvs_.extend(uv_tuple)

Expand Down
4 changes: 3 additions & 1 deletion utils/exporters/blender/addons/io_three/exporter/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,11 @@ def _parse_buffer_geometry(self):
api.mesh.buffer_position, 3)
uvs_tuple = (constants.UV, option_uvs,
api.mesh.buffer_uv, 2)
uvs2_tuple = (constants.UV2, option_uvs,
lambda m: api.mesh.buffer_uv(m, layer=1), 2)
normals_tuple = (constants.NORMAL, option_normals,
api.mesh.buffer_normal, 3)
dispatch = (pos_tuple, uvs_tuple, normals_tuple)
dispatch = (pos_tuple, uvs_tuple, uvs2_tuple, normals_tuple)

for key, option, func, size in dispatch:

Expand Down

0 comments on commit 2f8ea12

Please sign in to comment.