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.
This commit is contained in:
Bill Currie 2011-09-28 07:41:20 +09:00
parent a356ce6572
commit 3b8ab404a0
2 changed files with 16 additions and 0 deletions

View File

@ -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)

View File

@ -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