lots of updates
This commit is contained in:
BIN
tools/Untitled.fmesh_c
Normal file
BIN
tools/Untitled.fmesh_c
Normal file
Binary file not shown.
75
tools/blender_funnyasset.py
Normal file
75
tools/blender_funnyasset.py
Normal file
@@ -0,0 +1,75 @@
|
||||
import bpy
|
||||
import os
|
||||
import struct
|
||||
from bpy_extras.io_utils import ExportHelper
|
||||
from bpy.types import Operator
|
||||
from bpy.props import StringProperty
|
||||
|
||||
bl_info = {
|
||||
"name": "FunnyMesh export",
|
||||
"author": "kotofyt",
|
||||
"version": (1, 0),
|
||||
"blender": (4, 3, 0),
|
||||
"location": "File > Export > FunnyMesh (.fmesh_c)",
|
||||
"description": "Export meshes as FunnyMeshes",
|
||||
"category": "Import-Export",
|
||||
}
|
||||
|
||||
|
||||
class ExportFunnyMesh(Operator, ExportHelper):
|
||||
"""Export to Funnymesh"""
|
||||
bl_idname = "export_scene.fmesh_c"
|
||||
bl_label = "Export Funnymesh"
|
||||
filename_ext = ".fmesh_c"
|
||||
|
||||
filter_glob: StringProperty(
|
||||
default="*.map",
|
||||
options={'HIDDEN'},
|
||||
)
|
||||
|
||||
def execute(self, context):
|
||||
return export_my_format(self.filepath)
|
||||
|
||||
def export_my_format(filepath):
|
||||
with open(filepath, 'wb') as f:
|
||||
|
||||
for obj in bpy.context.scene.objects:
|
||||
if obj.type == 'MESH':
|
||||
mesh = obj.to_mesh()
|
||||
mesh.calc_loop_triangles()
|
||||
uv_layer = mesh.uv_layers.active.data if mesh.uv_layers.active else None
|
||||
for tri in mesh.loop_triangles:
|
||||
for loop_index in tri.loops:
|
||||
vert = mesh.vertices[mesh.loops[loop_index].vertex_index]
|
||||
world_pos = obj.matrix_world @ vert.co
|
||||
print(world_pos.x)
|
||||
f.write(struct.pack('f', world_pos.x))
|
||||
print(world_pos.y)
|
||||
f.write(struct.pack('f', world_pos.y))
|
||||
print(world_pos.z)
|
||||
f.write(struct.pack('f', world_pos.z))
|
||||
if uv_layer:
|
||||
uv = uv_layer[loop_index].uv
|
||||
print(uv.x)
|
||||
f.write(struct.pack('f', uv.x))
|
||||
print(uv.y)
|
||||
f.write(struct.pack('f', uv.y))
|
||||
else:
|
||||
f.write(struct.pack('f', 0))
|
||||
f.write(struct.pack('f', 0))
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
def menu_func_export(self, context):
|
||||
self.layout.operator(ExportFunnyMesh.bl_idname, text="FunnyMesh (.fmesh_c)")
|
||||
|
||||
def register():
|
||||
bpy.utils.register_class(ExportFunnyMesh)
|
||||
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
|
||||
|
||||
def unregister():
|
||||
bpy.utils.unregister_class(ExportFunnyMesh)
|
||||
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
|
||||
|
||||
if __name__ == "__main__":
|
||||
register()
|
||||
Reference in New Issue
Block a user