Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blender exporter: Added second UV layer support #8076

Merged
merged 1 commit into from
Feb 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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