Skip to content

Commit

Permalink
Small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
haekb committed Dec 30, 2019
1 parent 583b533 commit 3bac83b
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ def import_model(model, options):
''' Create a mesh for each piece of each LOD level that we are importing. '''
for lod_index in range(lod_import_count):
for piece_index, piece in enumerate(model.pieces):
print("Procesing piece [", piece_index, "] ", piece.name)
lod = piece.lods[lod_index]

''' Create the object and mesh. '''
Expand Down Expand Up @@ -265,15 +264,13 @@ def import_model(model, options):
# Set the correct UV as active
uv_texture.active_render = True

print(uv_texture)
for face_index, face in enumerate(lod.faces):
material_face_offset = material_face_offsets[0] # TODO: is this right?
texcoords = [vertex.texcoord for vertex in face.vertices]
for i in range(3):
uv = texcoords[i][0], 1.0 - texcoords[i][1]
uv_texture.data[(material_face_offset + face_index) * 3 + i].uv = uv
material_face_offsets[0] += len(lod.faces)
print(material_face_offsets)

''' Assign normals '''
face_offset = 0
Expand Down Expand Up @@ -353,24 +350,24 @@ def recursively_apply_transform(nodes, node_index, pose_bones, parent_matrix):

#print("[",node_index,"] Applying transform to : ", node.name)

if node_index > -1:
# Get the current transform
transform = animation.node_keyframe_transforms[node_index][keyframe_index]

# Correct-ish
# rotation = Quaternion( (transform.rotation.w, -transform.rotation.z, -transform.rotation.x, transform.rotation.y) )
# Get the current transform
transform = animation.node_keyframe_transforms[node_index][keyframe_index]

# Correct-ish
# rotation = Quaternion( (transform.rotation.w, -transform.rotation.z, -transform.rotation.x, transform.rotation.y) )

rotation = Quaternion( (transform.rotation.w, -transform.rotation.z, -transform.rotation.x, transform.rotation.y) )

matrix = rotation.to_matrix().to_4x4() # transform.rotation.to_matrix().to_4x4()
rotation = Quaternion( (transform.rotation.w, -transform.rotation.z, -transform.rotation.x, transform.rotation.y) )

# Apply the translation
matrix.Translation(transform.location.xzy)


# Use a matrix instead!
pose_bone.matrix = parent_matrix @ matrix
matrix = rotation.to_matrix().to_4x4() # transform.rotation.to_matrix().to_4x4()

# Apply the translation
matrix.Translation(transform.location.xzy)


# Use a matrix instead!
pose_bone.matrix = parent_matrix @ matrix

# Recursively apply our transform to our children!
# print("[",node_index,"] Found children count : ", node.child_count)
Expand Down

0 comments on commit 3bac83b

Please sign in to comment.