Skip to content

2018.2 14 channel format support #79

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
44 changes: 25 additions & 19 deletions unitypack/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def extract_indices(self):
def extract_vertices(self):
# unity 5+ has 8 channels (6 otherwise)
v5_channel_count = 8
# unity 2018 has 14 channels
v2018_channel_count = 14
buf = BinaryReader(BytesIO(self.mesh.vertex_data.data))
channels = self.mesh.vertex_data.channels
# actual streams attribute 'm_Streams' may only exist in unity 4,
Expand All @@ -105,25 +107,29 @@ def extract_vertices(self):
raise NotImplementedError("(%r) 16 bit floats are not supported" % (self.mesh))
# read the appropriate vertex value into the correct list
if ch and ch["dimension"] > 0 and ch["stream"] == s:
if j == 0:
self.vertices.append(OBJVector3().read(buf))
elif j == 1:
self.normals.append(OBJVector3().read(buf))
elif j == 2:
self.colors.append(OBJVector4().read_color(buf))
elif j == 3:
self.uv1.append(OBJVector2().read(buf))
elif j == 4:
self.uv2.append(OBJVector2().read(buf))
elif j == 5:
if channel_count == v5_channel_count:
self.uv3.append(OBJVector2().read(buf))
else:
self.tangents.append(OBJVector4().read(buf))
elif j == 6: # for unity 5+
self.uv4.append(OBJVector2().read(buf))
elif j == 7: # for unity 5+
self.tangents.append(OBJVector4().read(buf))
if j == 0:
self.vertices.append(OBJVector3().read(buf))
elif j == 1:
self.normals.append(OBJVector3().read(buf))
elif j == 2:
if channel_count == v2018_channel_count:
self.tangents.append(OBJVector4().read(buf))
else:
self.colors.append(OBJVector4().read_color(buf))
elif j == 3:
self.uv1.append(OBJVector2().read(buf))
elif j == 4:
self.uv2.append(OBJVector2().read(buf))
elif j == 5:
if channel_count == v5_channel_count || channel_count == v2018_channel_count:
self.uv3.append(OBJVector2().read(buf))
else:
self.tangents.append(OBJVector4().read(buf))
elif j == 6: # for unity 5+
self.uv4.append(OBJVector2().read(buf))
elif j == 7: # for unity 5+
if channel_count == v5_channel_count:
self.tangents.append(OBJVector4().read(buf))
# TODO investigate possible alignment here, after each stream

def get_num_streams(self, channels):
Expand Down