commit 9a1f696beef9c319f5895aa8c1bb52b80f52f8e7
parent 5efc3bb13011e16e9a75dba3b128328b7b6fc32a
Author: Harridrone <harrison_k_a@hotmail.com>
Date: Sun, 4 Apr 2021 22:15:13 -0400
Updated exporter and added normalization
Diffstat:
3 files changed, 42 insertions(+), 24 deletions(-)
diff --git a/README.md b/README.md
@@ -0,0 +1,13 @@
+### Harry's Vertex Weight Exporter
+##### Version 2.0 (for blender 2.8x and up)
+
+Simply download this git repo as a .zip open blender, and select "Install addon"
+in addons from the preferences menu.
+
+##### How do I link up these weights with the vertices?
+
+This file exports the vertices in the same order as obj files exported by
+blender, so no extra work is needed to link weight to vertex
+
+**Note** that this exporter normalizes vertex weights so they add up to 1.0
+as required by my game engine
+\ No newline at end of file
diff --git a/__init__.py b/__init__.py
@@ -6,27 +6,29 @@ import bpy
bl_info = {
"name": "Vertex Weight Export",
"author": "Harrison Andrews",
- "description": "An ascii exporter that stores just a meshs's vertex weights to their skeleton",
- "location": "File > Export",
- "version": (1, 0),
- "blender": (2, 6, 4),
+ "description": "An ascii exporter that stores just a meshs's vertex weights to their skeleton",
+ "location": "File > Import-Export",
+ "version": (2, 0),
+ "blender": (2, 81, 6),
"warning": "", # used for warning icon and text in addons panel
- "category": "Import-Export"}
-
+ "category": "Import-Export",
+ "support": 'COMMUNITY',
+}
+
from bpy_extras.io_utils import (ExportHelper,
ImportHelper,
path_reference_mode,
axis_conversion,
)
-
+
def writefile(self):
filename = self.filepath
out = open(filename, 'w')
sce = bpy.data.scenes[0]
mesh = bpy.data.meshes[0]
- out.write("#Harry's Vertex Weight Export Version 1.0\n\n")
-
+ out.write("#Harry's Vertex Weight Export Version 2.0\n\n")
+
for vert in mesh.vertices:
out.write("w")
@@ -34,33 +36,35 @@ def writefile(self):
try:
out.write(" %i %f" % (vert.groups[i].group,vert.groups[i].weight))
except:
- out.write(" %i %f" % (0,0))
+ out.write(" %i %f" % (0,0))
out.write("\n")
-
- out.close()
-
+
+ out.close()
+
class ExportWeights(bpy.types.Operator, ExportHelper):
bl_idname = "export_weights.hvw"
bl_label = 'Vertex Weight Export'
bl_options = {'PRESET'}
-
+
filename_ext = ".hvw"
-
+
def execute(self, context):
+ bpy.ops.object.vertex_group_normalize_all()
writefile(self)
return {'FINISHED'}
-
+
def menu_func_export(self, context):
self.layout.operator(ExportWeights.bl_idname, text="Harry Vertex Weight (.hvw)")
-
-def register():
- bpy.utils.register_module(__name__)
- bpy.types.INFO_MT_file_export.append(menu_func_export)
-
-def unregister():
- bpy.types.INFO_MT_file_export.remove(menu_func_export)
-
+
+def register():
+ bpy.utils.register_class(ExportWeights)
+ bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
+
+def unregister():
+ bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
+ bpy.utils.unregister_class(ExportWeights)
+
if __name__ == "__main__":
register()
\ No newline at end of file
diff --git a/__pycache__/__init__.cpython-32.pyc b/__pycache__/__init__.cpython-32.pyc
Binary files differ.