From 3b8ab404a06533c170401afd0eece397b0222fbd Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 28 Sep 2011 07:41:20 +0900 Subject: [PATCH] Add the ability to save the extra model parameters. The params are eye position, flags and synctype. Provision is made for reading them from a text block on export, but nothing is done other than retrieving the text block. --- tools/io_mesh_qfmdl/export_mdl.py | 4 ++++ tools/io_mesh_qfmdl/import_mdl.py | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/tools/io_mesh_qfmdl/export_mdl.py b/tools/io_mesh_qfmdl/export_mdl.py index deda8707a..87f526deb 100644 --- a/tools/io_mesh_qfmdl/export_mdl.py +++ b/tools/io_mesh_qfmdl/export_mdl.py @@ -168,6 +168,10 @@ def export_mdl(operator, context, filepath): "Mesh has faces with more than 3 vertices.") return {'CANCELLED'} mdl = MDL(obj.name) + #FIXME this should be configurable + #FIXME use it + if mdl.name in bpy.data.texts: + mdl.script = bpy.data.texts[mdl.name].as_string() make_skin(mdl, mesh) mdl.tris, mdl.stverts, vertmap = build_tris(mesh) convert_stverts (mdl, mdl.stverts) diff --git a/tools/io_mesh_qfmdl/import_mdl.py b/tools/io_mesh_qfmdl/import_mdl.py index 48c2b6690..53d4379c2 100644 --- a/tools/io_mesh_qfmdl/import_mdl.py +++ b/tools/io_mesh_qfmdl/import_mdl.py @@ -231,6 +231,15 @@ def merge_frames(mdl): mdl.frames[i:j] = [f] i += 1 +def write_text(mdl): + string = "$eyeposition %g %g %g\n" % mdl.eyeposition + string += "$flags %d\n" % mdl.flags + if mdl.synctype: + string += "$sync\n" + txt = bpy.data.texts.new(mdl.name) + txt.from_string(string) + return txt.name + def import_mdl(operator, context, filepath): bpy.context.user_preferences.edit.use_global_undo = False @@ -260,6 +269,9 @@ def import_mdl(operator, context, filepath): merge_frames(mdl) build_actions(mdl) + operator.report({'INFO'}, + "Extra settings saved in the %s text block." % write_text(mdl)) + mdl.mesh.update() bpy.context.user_preferences.edit.use_global_undo = True