mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-19 07:20:50 +00:00
Support loading entity class data into blender.
The qc source path is specified via the dirpath property in the QF Entity Classes panel of the scene data. The scanned entity classes are stored in a plist in a blender text file for persistent storage (so the directory doesn't need to be scanned every time). Also, so the data doesn't have to be parsed every time, the data is stored in a normal python class hanging off the properties class (evil hack?).
This commit is contained in:
parent
3cad0f978b
commit
16952ffbbb
1 changed files with 59 additions and 47 deletions
|
@ -48,58 +48,66 @@ import bpy
|
||||||
from bpy.props import BoolProperty, FloatProperty, StringProperty, EnumProperty
|
from bpy.props import BoolProperty, FloatProperty, StringProperty, EnumProperty
|
||||||
from bpy.props import FloatVectorProperty, PointerProperty
|
from bpy.props import FloatVectorProperty, PointerProperty
|
||||||
from bpy_extras.io_utils import ExportHelper, ImportHelper, path_reference_mode, axis_conversion
|
from bpy_extras.io_utils import ExportHelper, ImportHelper, path_reference_mode, axis_conversion
|
||||||
|
from bpy.app.handlers import persistent
|
||||||
|
|
||||||
|
from .entityclass import EntityClassDict
|
||||||
from . import import_map
|
from . import import_map
|
||||||
#from . import export_map
|
#from . import export_map
|
||||||
|
|
||||||
SYNCTYPE=(
|
@persistent
|
||||||
('ST_SYNC', "Syncronized", "Automatic animations are all together"),
|
def scene_load_handler(dummy):
|
||||||
('ST_RAND', "Random", "Automatic animations have random offsets"),
|
for scene in bpy.data.scenes:
|
||||||
)
|
if hasattr(scene, "qfmap"):
|
||||||
|
qfmap = scene.qfmap
|
||||||
|
if qfmap.script in bpy.data.texts:
|
||||||
|
script = bpy.data.texts[qfmap.script].as_string()
|
||||||
|
qfmap.entity_classes.from_plist(script)
|
||||||
|
|
||||||
EFFECTS=(
|
def ec_dir_update(self, context):
|
||||||
('EF_NONE', "None", "No effects"),
|
print("ec_dir_update")
|
||||||
('EF_ROCKET', "Rocket", "Leave a rocket trail"),
|
self.entity_classes.from_source_tree(self.dirpath)
|
||||||
('EF_GRENADE', "Grenade", "Leave a grenade trail"),
|
name = context.scene.name + '-EntityClasses'
|
||||||
('EF_GIB', "Gib", "Leave a trail of blood"),
|
if name in bpy.data.texts:
|
||||||
('EF_TRACER', "Tracer", "Green split trail"),
|
txt = bpy.data.texts[name]
|
||||||
('EF_ZOMGIB', "Zombie Gib", "Leave a smaller blood trail"),
|
else:
|
||||||
('EF_TRACER2', "Tracer 2", "Orange split trail + rotate"),
|
txt = bpy.data.texts.new(name)
|
||||||
('EF_TRACER3', "Tracer 3", "Purple split trail"),
|
txt.from_string(self.entity_classes.to_plist())
|
||||||
)
|
self.script = name
|
||||||
|
|
||||||
class QFMDLSettings(bpy.types.PropertyGroup):
|
def ec_script_update(self, context):
|
||||||
eyeposition = FloatVectorProperty(
|
print("ec_script_update")
|
||||||
name="Eye Position",
|
if self.script in bpy.data.texts:
|
||||||
description="View possion relative to object origin")
|
self.entity_classes.from_plist(bpy.data.texts[self.script].as_string())
|
||||||
synctype = EnumProperty(
|
|
||||||
items=SYNCTYPE,
|
class QFEntityClasses(bpy.types.PropertyGroup):
|
||||||
name="Sync Type",
|
dirpath = StringProperty(
|
||||||
description="Add random time offset for automatic animations")
|
name="dirpath",
|
||||||
rotate = BoolProperty(
|
description="Path to qc source tree",
|
||||||
name="Rotate",
|
subtype='DIR_PATH',
|
||||||
description="Rotate automatically (for pickup items)")
|
update=ec_dir_update)
|
||||||
effects = EnumProperty(
|
|
||||||
items=EFFECTS,
|
|
||||||
name="Effects",
|
|
||||||
description="Particle trail effects")
|
|
||||||
#doesn't work :(
|
|
||||||
#script = PointerProperty(
|
|
||||||
# type=bpy.types.Object,
|
|
||||||
# name="Script",
|
|
||||||
# description="Script for animating frames and skins")
|
|
||||||
script = StringProperty(
|
script = StringProperty(
|
||||||
name="Script",
|
name="script",
|
||||||
description="Script for animating frames and skins")
|
description="Script for animating frames and skins",
|
||||||
xform = BoolProperty(
|
update=ec_script_update)
|
||||||
name="Auto transform",
|
entity_classes = EntityClassDict()
|
||||||
description="Auto-apply location/rotation/scale when exporting",
|
|
||||||
default=True)
|
|
||||||
md16 = BoolProperty(
|
|
||||||
name="16-bit",
|
|
||||||
description="16 bit vertex coordinates: QuakeForge only")
|
|
||||||
|
|
||||||
class ImportMDL6(bpy.types.Operator, ImportHelper):
|
class QFECPanel(bpy.types.Panel):
|
||||||
|
bl_space_type = 'PROPERTIES'
|
||||||
|
bl_region_type = 'WINDOW'
|
||||||
|
bl_context = 'scene'
|
||||||
|
bl_label = 'QF Entity Classes'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
return True
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
scene = context.scene
|
||||||
|
layout.prop(scene.qfmap, "dirpath")
|
||||||
|
layout.prop(scene.qfmap, "script")
|
||||||
|
|
||||||
|
class ImportMap(bpy.types.Operator, ImportHelper):
|
||||||
'''Load a Quake map File'''
|
'''Load a Quake map File'''
|
||||||
bl_idname = "import_mesh.quake_map"
|
bl_idname = "import_mesh.quake_map"
|
||||||
bl_label = "Import map"
|
bl_label = "Import map"
|
||||||
|
@ -111,7 +119,7 @@ class ImportMDL6(bpy.types.Operator, ImportHelper):
|
||||||
keywords = self.as_keywords (ignore=("filter_glob",))
|
keywords = self.as_keywords (ignore=("filter_glob",))
|
||||||
return import_map.import_map(self, context, **keywords)
|
return import_map.import_map(self, context, **keywords)
|
||||||
|
|
||||||
class ExportMDL6(bpy.types.Operator, ExportHelper):
|
class ExportMap(bpy.types.Operator, ExportHelper):
|
||||||
'''Save a Quake map File'''
|
'''Save a Quake map File'''
|
||||||
|
|
||||||
bl_idname = "export_mesh.quake_map"
|
bl_idname = "export_mesh.quake_map"
|
||||||
|
@ -130,19 +138,23 @@ class ExportMDL6(bpy.types.Operator, ExportHelper):
|
||||||
return export_map.export_map(self, context, **keywords)
|
return export_map.export_map(self, context, **keywords)
|
||||||
|
|
||||||
def menu_func_import(self, context):
|
def menu_func_import(self, context):
|
||||||
self.layout.operator(ImportMDL6.bl_idname, text="Quake map (.map)")
|
self.layout.operator(ImportMap.bl_idname, text="Quake map (.map)")
|
||||||
|
|
||||||
|
|
||||||
def menu_func_export(self, context):
|
def menu_func_export(self, context):
|
||||||
self.layout.operator(ExportMDL6.bl_idname, text="Quake map (.map)")
|
self.layout.operator(ExportMap.bl_idname, text="Quake map (.map)")
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
bpy.utils.register_module(__name__)
|
bpy.utils.register_module(__name__)
|
||||||
|
|
||||||
|
bpy.types.Scene.qfmap = PointerProperty(type=QFEntityClasses)
|
||||||
|
|
||||||
bpy.types.INFO_MT_file_import.append(menu_func_import)
|
bpy.types.INFO_MT_file_import.append(menu_func_import)
|
||||||
bpy.types.INFO_MT_file_export.append(menu_func_export)
|
bpy.types.INFO_MT_file_export.append(menu_func_export)
|
||||||
|
|
||||||
|
bpy.app.handlers.load_post.append(scene_load_handler)
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
bpy.utils.unregister_module(__name__)
|
bpy.utils.unregister_module(__name__)
|
||||||
|
|
Loading…
Reference in a new issue