2011-09-14 10:33:51 +00:00
|
|
|
# vim:ts=4:et
|
|
|
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software Foundation,
|
|
|
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
#
|
|
|
|
# ##### END GPL LICENSE BLOCK #####
|
|
|
|
|
|
|
|
# copied from io_scene_obj
|
|
|
|
|
|
|
|
# <pep8 compliant>
|
|
|
|
|
|
|
|
bl_info = {
|
|
|
|
"name": "Quake MDL format",
|
|
|
|
"author": "Bill Currie",
|
2019-01-08 02:02:11 +00:00
|
|
|
"blender": (2, 80, 0),
|
2011-09-14 10:33:51 +00:00
|
|
|
"api": 35622,
|
|
|
|
"location": "File > Import-Export",
|
|
|
|
"description": "Import-Export Quake MDL (version 6) files. (.mdl)",
|
2019-01-08 02:02:11 +00:00
|
|
|
"warning": "still work in progress",
|
2011-09-14 10:33:51 +00:00
|
|
|
"wiki_url": "",
|
|
|
|
"tracker_url": "",
|
2019-01-08 02:02:11 +00:00
|
|
|
# "support": 'OFFICIAL',
|
2011-09-14 10:33:51 +00:00
|
|
|
"category": "Import-Export"}
|
|
|
|
|
|
|
|
# To support reload properly, try to access a package var, if it's there,
|
|
|
|
# reload everything
|
|
|
|
if "bpy" in locals():
|
|
|
|
import imp
|
|
|
|
if "import_mdl" in locals():
|
|
|
|
imp.reload(import_mdl)
|
2012-04-15 12:55:23 +00:00
|
|
|
if "export_mdl" in locals():
|
|
|
|
imp.reload(export_mdl)
|
2011-09-14 10:33:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
import bpy
|
|
|
|
from bpy.props import BoolProperty, FloatProperty, StringProperty, EnumProperty
|
2012-04-19 13:06:43 +00:00
|
|
|
from bpy.props import FloatVectorProperty, PointerProperty
|
2011-09-14 10:33:51 +00:00
|
|
|
from bpy_extras.io_utils import ExportHelper, ImportHelper, path_reference_mode, axis_conversion
|
|
|
|
|
2012-04-15 12:55:23 +00:00
|
|
|
SYNCTYPE=(
|
|
|
|
('ST_SYNC', "Syncronized", "Automatic animations are all together"),
|
|
|
|
('ST_RAND', "Random", "Automatic animations have random offsets"),
|
|
|
|
)
|
|
|
|
|
|
|
|
EFFECTS=(
|
|
|
|
('EF_NONE', "None", "No effects"),
|
|
|
|
('EF_ROCKET', "Rocket", "Leave a rocket trail"),
|
|
|
|
('EF_GRENADE', "Grenade", "Leave a grenade trail"),
|
|
|
|
('EF_GIB', "Gib", "Leave a trail of blood"),
|
|
|
|
('EF_TRACER', "Tracer", "Green split trail"),
|
|
|
|
('EF_ZOMGIB', "Zombie Gib", "Leave a smaller blood trail"),
|
|
|
|
('EF_TRACER2', "Tracer 2", "Orange split trail + rotate"),
|
|
|
|
('EF_TRACER3', "Tracer 3", "Purple split trail"),
|
|
|
|
)
|
2018-11-24 01:59:41 +00:00
|
|
|
|
2019-01-16 04:15:37 +00:00
|
|
|
class QFMDLSettings(bpy.types.PropertyGroup):
|
2019-08-16 13:32:37 +00:00
|
|
|
eyeposition : FloatVectorProperty(
|
2019-01-16 04:15:37 +00:00
|
|
|
name="Eye Position",
|
|
|
|
description="View possion relative to object origin")
|
2019-08-16 13:32:37 +00:00
|
|
|
synctype : EnumProperty(
|
2019-01-16 04:15:37 +00:00
|
|
|
items=SYNCTYPE,
|
|
|
|
name="Sync Type",
|
|
|
|
description="Add random time offset for automatic animations")
|
2019-08-16 13:32:37 +00:00
|
|
|
rotate : BoolProperty(
|
2019-01-16 04:15:37 +00:00
|
|
|
name="Rotate",
|
|
|
|
description="Rotate automatically (for pickup items)")
|
2019-08-16 13:32:37 +00:00
|
|
|
effects : EnumProperty(
|
2019-01-16 04:15:37 +00:00
|
|
|
items=EFFECTS,
|
|
|
|
name="Effects",
|
|
|
|
description="Particle trail effects")
|
|
|
|
|
2019-08-16 13:34:45 +00:00
|
|
|
script : PointerProperty(
|
|
|
|
type=bpy.types.Text,
|
|
|
|
name="Script",
|
|
|
|
description="Script for animating frames and skins")
|
2019-01-16 04:15:37 +00:00
|
|
|
|
2019-08-16 13:32:37 +00:00
|
|
|
xform : BoolProperty(
|
2019-01-16 04:15:37 +00:00
|
|
|
name="Auto transform",
|
|
|
|
description="Auto-apply location/rotation/scale when exporting",
|
|
|
|
default=True)
|
2019-08-16 13:32:37 +00:00
|
|
|
md16 : BoolProperty(
|
2019-01-16 04:15:37 +00:00
|
|
|
name="16-bit",
|
|
|
|
description="16 bit vertex coordinates: QuakeForge only")
|
2012-08-07 02:49:08 +00:00
|
|
|
xform = BoolProperty(
|
|
|
|
name="Auto transform",
|
|
|
|
description="Auto-apply location/rotation/scale when exporting",
|
|
|
|
default=True)
|
2012-04-22 13:11:41 +00:00
|
|
|
md16 = BoolProperty(
|
|
|
|
name="16-bit",
|
|
|
|
description="16 bit vertex coordinates: QuakeForge only")
|
2011-09-14 10:33:51 +00:00
|
|
|
|
|
|
|
class ImportMDL6(bpy.types.Operator, ImportHelper):
|
|
|
|
'''Load a Quake MDL (v6) File'''
|
|
|
|
bl_idname = "import_mesh.quake_mdl_v6"
|
|
|
|
bl_label = "Import MDL"
|
|
|
|
|
2011-09-21 08:37:32 +00:00
|
|
|
filename_ext = ".mdl"
|
2019-08-16 13:32:37 +00:00
|
|
|
filter_glob : StringProperty(default="*.mdl", options={'HIDDEN'})
|
2011-09-21 08:37:32 +00:00
|
|
|
|
2011-09-14 10:33:51 +00:00
|
|
|
def execute(self, context):
|
|
|
|
from . import import_mdl
|
2011-09-21 09:23:45 +00:00
|
|
|
keywords = self.as_keywords (ignore=("filter_glob",))
|
2011-09-14 10:33:51 +00:00
|
|
|
return import_mdl.import_mdl(self, context, **keywords)
|
|
|
|
|
|
|
|
class ExportMDL6(bpy.types.Operator, ExportHelper):
|
|
|
|
'''Save a Quake MDL (v6) File'''
|
|
|
|
|
|
|
|
bl_idname = "export_mesh.quake_mdl_v6"
|
2011-09-21 08:37:32 +00:00
|
|
|
bl_label = "Export MDL"
|
|
|
|
|
|
|
|
filename_ext = ".mdl"
|
2019-08-16 13:32:37 +00:00
|
|
|
filter_glob : StringProperty(default="*.mdl", options={'HIDDEN'})
|
2011-09-21 09:23:45 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
return (context.active_object != None
|
|
|
|
and type(context.active_object.data) == bpy.types.Mesh)
|
2011-09-14 10:33:51 +00:00
|
|
|
|
|
|
|
def execute(self, context):
|
2011-09-21 08:37:32 +00:00
|
|
|
from . import export_mdl
|
2011-09-21 09:23:45 +00:00
|
|
|
keywords = self.as_keywords (ignore=("check_existing", "filter_glob"))
|
2011-09-14 10:33:51 +00:00
|
|
|
return export_mdl.export_mdl(self, context, **keywords)
|
|
|
|
|
2018-06-08 03:45:57 +00:00
|
|
|
class OBJECT_PT_MDLPanel(bpy.types.Panel):
|
2019-01-16 04:15:37 +00:00
|
|
|
bl_label = "MDL Properties"
|
2012-04-15 12:55:23 +00:00
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
bl_context = 'object'
|
2019-01-16 04:15:37 +00:00
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2012-04-15 12:55:23 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
obj = context.active_object
|
|
|
|
return obj and obj.type == 'MESH'
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
obj = context.active_object
|
|
|
|
layout.prop(obj.qfmdl, "eyeposition")
|
|
|
|
layout.prop(obj.qfmdl, "synctype")
|
|
|
|
layout.prop(obj.qfmdl, "rotate")
|
|
|
|
layout.prop(obj.qfmdl, "effects")
|
2012-04-19 13:06:43 +00:00
|
|
|
layout.prop(obj.qfmdl, "script")
|
2012-08-07 02:49:08 +00:00
|
|
|
layout.prop(obj.qfmdl, "xform")
|
2012-04-22 13:11:41 +00:00
|
|
|
layout.prop(obj.qfmdl, "md16")
|
2011-09-14 10:33:51 +00:00
|
|
|
|
|
|
|
def menu_func_import(self, context):
|
|
|
|
self.layout.operator(ImportMDL6.bl_idname, text="Quake MDL (.mdl)")
|
|
|
|
|
|
|
|
|
|
|
|
def menu_func_export(self, context):
|
|
|
|
self.layout.operator(ExportMDL6.bl_idname, text="Quake MDL (.mdl)")
|
|
|
|
|
2019-01-08 02:02:11 +00:00
|
|
|
classes = (
|
2019-01-16 04:15:37 +00:00
|
|
|
QFMDLSettings,
|
|
|
|
OBJECT_PT_MDLPanel,
|
2019-01-08 02:02:11 +00:00
|
|
|
ImportMDL6,
|
|
|
|
ExportMDL6
|
|
|
|
)
|
2011-09-14 10:33:51 +00:00
|
|
|
|
|
|
|
def register():
|
2019-01-08 02:02:11 +00:00
|
|
|
for cls in classes:
|
|
|
|
bpy.utils.register_class(cls)
|
2011-09-14 10:33:51 +00:00
|
|
|
|
2019-01-16 04:15:37 +00:00
|
|
|
bpy.types.Object.qfmdl = PointerProperty(type=QFMDLSettings)
|
|
|
|
|
2019-01-08 02:02:11 +00:00
|
|
|
bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
|
|
|
|
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
|
2011-09-14 10:33:51 +00:00
|
|
|
|
|
|
|
def unregister():
|
2019-01-08 02:02:11 +00:00
|
|
|
for cls in classes:
|
|
|
|
bpy.utils.unregister_class(cls)
|
2011-09-14 10:33:51 +00:00
|
|
|
|
2019-01-08 02:02:11 +00:00
|
|
|
bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
|
|
|
|
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
|
2011-09-14 10:33:51 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
register()
|