Compare commits
9 Commits
2b60f0d2a6
...
3e066bbe64
Author | SHA1 | Date | |
---|---|---|---|
3e066bbe64 | |||
![]() |
0cc8beb830 | ||
![]() |
336870ecb5 | ||
![]() |
daacdf1a5d | ||
![]() |
48c05380c6 | ||
![]() |
9f4a205f3d | ||
![]() |
216ea5d7a4 | ||
![]() |
d2c7dbd79f | ||
![]() |
6247a289e6 |
@ -1,8 +1,8 @@
|
|||||||
bl_info = {
|
bl_info = {
|
||||||
'name': 'SWBF .msh Import-Export',
|
'name': 'SWBF .msh Import-Export',
|
||||||
'author': 'Will Snyder, PrismaticFlower',
|
'author': 'Will Snyder, PrismaticFlower',
|
||||||
"version": (1, 3, 0),
|
"version": (1, 3, 3),
|
||||||
'blender': (2, 80, 0),
|
'blender': (4, 3, 2),
|
||||||
'location': 'File > Import-Export',
|
'location': 'File > Import-Export',
|
||||||
'description': 'Export as SWBF .msh file',
|
'description': 'Export as SWBF .msh file',
|
||||||
'warning': '',
|
'warning': '',
|
||||||
@ -261,4 +261,4 @@ def unregister():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
register()
|
register()
|
@ -67,7 +67,7 @@ def extract_anim(armature: bpy.types.Armature, root_name: str) -> Animation:
|
|||||||
|
|
||||||
for frame in range(num_frames):
|
for frame in range(num_frames):
|
||||||
|
|
||||||
frame_time = framerange.x + frame * increment
|
frame_time = int(framerange.x + frame * increment)
|
||||||
bpy.context.scene.frame_set(frame_time)
|
bpy.context.scene.frame_set(frame_time)
|
||||||
|
|
||||||
for keyable_bone in keyable_bones:
|
for keyable_bone in keyable_bones:
|
||||||
|
@ -107,4 +107,4 @@ def extract_and_apply_anim(filename : str, scene : Scene):
|
|||||||
|
|
||||||
arma.animation_data.action = action
|
arma.animation_data.action = action
|
||||||
track = arma.animation_data.nla_tracks.new()
|
track = arma.animation_data.nla_tracks.new()
|
||||||
track.strips.new(action.name, action.frame_range[0], action)
|
track.strips.new(action.name, int(action.frame_range[0]), action)
|
@ -180,8 +180,10 @@ to provide an exact emulation"""
|
|||||||
|
|
||||||
texture_input_nodes.append(texImage)
|
texture_input_nodes.append(texImage)
|
||||||
|
|
||||||
|
specular_key = "Specular" if bpy.app.version < (4, 0, 0) else "Specular IOR Level"
|
||||||
|
|
||||||
bsdf.inputs["Roughness"].default_value = 1.0
|
bsdf.inputs["Roughness"].default_value = 1.0
|
||||||
bsdf.inputs["Specular"].default_value = 0.0
|
bsdf.inputs[specular_key].default_value = 0.0
|
||||||
|
|
||||||
material.use_backface_culling = not bool(mat_props.doublesided)
|
material.use_backface_culling = not bool(mat_props.doublesided)
|
||||||
|
|
||||||
|
@ -128,7 +128,6 @@ def model_to_mesh_object(model: Model, scene : Scene, materials_map : Dict[str,
|
|||||||
blender_mesh.loops.foreach_set("vertex_index", flat_indices)
|
blender_mesh.loops.foreach_set("vertex_index", flat_indices)
|
||||||
|
|
||||||
# Normals
|
# Normals
|
||||||
blender_mesh.create_normals_split()
|
|
||||||
blender_mesh.loops.foreach_set("normal", [component for i in flat_indices for component in vertex_normals[i]])
|
blender_mesh.loops.foreach_set("normal", [component for i in flat_indices for component in vertex_normals[i]])
|
||||||
|
|
||||||
# UVs
|
# UVs
|
||||||
@ -175,7 +174,6 @@ def model_to_mesh_object(model: Model, scene : Scene, materials_map : Dict[str,
|
|||||||
reset_normals = [0.0] * (len(blender_mesh.loops) * 3)
|
reset_normals = [0.0] * (len(blender_mesh.loops) * 3)
|
||||||
blender_mesh.loops.foreach_get("normal", reset_normals)
|
blender_mesh.loops.foreach_get("normal", reset_normals)
|
||||||
blender_mesh.normals_split_custom_set(tuple(zip(*(iter(reset_normals),) * 3)))
|
blender_mesh.normals_split_custom_set(tuple(zip(*(iter(reset_normals),) * 3)))
|
||||||
blender_mesh.use_auto_smooth = True
|
|
||||||
|
|
||||||
|
|
||||||
blender_mesh_object = bpy.data.objects.new(model.name, blender_mesh)
|
blender_mesh_object = bpy.data.objects.new(model.name, blender_mesh)
|
||||||
@ -198,4 +196,3 @@ def model_to_mesh_object(model: Model, scene : Scene, materials_map : Dict[str,
|
|||||||
|
|
||||||
|
|
||||||
return blender_mesh_object
|
return blender_mesh_object
|
||||||
|
|
||||||
|
@ -215,10 +215,11 @@ def create_mesh_geometry(mesh: bpy.types.Mesh, valid_vgroup_indices: Set[int]) -
|
|||||||
yield mesh.uv_layers.active.data[loop_index].uv.y
|
yield mesh.uv_layers.active.data[loop_index].uv.y
|
||||||
|
|
||||||
if segment.colors is not None:
|
if segment.colors is not None:
|
||||||
data_type = mesh.color_attributes.active_color.data_type
|
active_color = mesh.color_attributes.active_color
|
||||||
if data_type == "FLOAT_COLOR" or data_type == "BYTE_COLOR":
|
data_index = loop_index if active_color.domain == "CORNER" else vertex_index
|
||||||
for v in mesh.color_attributes.active_color.data[vertex_index].color:
|
|
||||||
yield v
|
for v in mesh.color_attributes.active_color.data[data_index].color:
|
||||||
|
yield v
|
||||||
|
|
||||||
if segment.weights is not None:
|
if segment.weights is not None:
|
||||||
for v in mesh.vertices[vertex_index].groups:
|
for v in mesh.vertices[vertex_index].groups:
|
||||||
@ -247,9 +248,10 @@ def create_mesh_geometry(mesh: bpy.types.Mesh, valid_vgroup_indices: Set[int]) -
|
|||||||
segment.texcoords.append(mesh.uv_layers.active.data[loop_index].uv.copy())
|
segment.texcoords.append(mesh.uv_layers.active.data[loop_index].uv.copy())
|
||||||
|
|
||||||
if segment.colors is not None:
|
if segment.colors is not None:
|
||||||
data_type = mesh.color_attributes.active_color.data_type
|
active_color = mesh.color_attributes.active_color
|
||||||
if data_type == "FLOAT_COLOR" or data_type == "BYTE_COLOR":
|
data_index = loop_index if active_color.domain == "CORNER" else vertex_index
|
||||||
segment.colors.append(list(mesh.color_attributes.active_color.data[vertex_index].color))
|
|
||||||
|
segment.colors.append(list(active_color.data[data_index].color))
|
||||||
|
|
||||||
if segment.weights is not None:
|
if segment.weights is not None:
|
||||||
groups = mesh.vertices[vertex_index].groups
|
groups = mesh.vertices[vertex_index].groups
|
||||||
|
Loading…
Reference in New Issue
Block a user