mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-05-31 08:41:11 +00:00
Moved MDL settings from Object tab to export options/presets
This commit is contained in:
parent
90a707f7f9
commit
8112c4e8b6
2 changed files with 73 additions and 14 deletions
|
@ -66,6 +66,7 @@ EFFECTS=(
|
||||||
)
|
)
|
||||||
|
|
||||||
class QFMDLSettings(bpy.types.PropertyGroup):
|
class QFMDLSettings(bpy.types.PropertyGroup):
|
||||||
|
'''
|
||||||
eyeposition = FloatVectorProperty(
|
eyeposition = FloatVectorProperty(
|
||||||
name="Eye Position",
|
name="Eye Position",
|
||||||
description="View possion relative to object origin")
|
description="View possion relative to object origin")
|
||||||
|
@ -85,9 +86,7 @@ class QFMDLSettings(bpy.types.PropertyGroup):
|
||||||
# type=bpy.types.Object,
|
# type=bpy.types.Object,
|
||||||
# name="Script",
|
# name="Script",
|
||||||
# description="Script for animating frames and skins")
|
# description="Script for animating frames and skins")
|
||||||
script = StringProperty(
|
|
||||||
name="Script",
|
|
||||||
description="Script for animating frames and skins")
|
|
||||||
xform = BoolProperty(
|
xform = BoolProperty(
|
||||||
name="Auto transform",
|
name="Auto transform",
|
||||||
description="Auto-apply location/rotation/scale when exporting",
|
description="Auto-apply location/rotation/scale when exporting",
|
||||||
|
@ -95,6 +94,10 @@ class QFMDLSettings(bpy.types.PropertyGroup):
|
||||||
md16 = BoolProperty(
|
md16 = BoolProperty(
|
||||||
name="16-bit",
|
name="16-bit",
|
||||||
description="16 bit vertex coordinates: QuakeForge only")
|
description="16 bit vertex coordinates: QuakeForge only")
|
||||||
|
'''
|
||||||
|
script = StringProperty(
|
||||||
|
name="Script",
|
||||||
|
description="Script for animating frames and skins")
|
||||||
|
|
||||||
class ImportMDL6(bpy.types.Operator, ImportHelper):
|
class ImportMDL6(bpy.types.Operator, ImportHelper):
|
||||||
'''Load a Quake MDL (v6) File'''
|
'''Load a Quake MDL (v6) File'''
|
||||||
|
@ -114,10 +117,34 @@ class ExportMDL6(bpy.types.Operator, ExportHelper):
|
||||||
|
|
||||||
bl_idname = "export_mesh.quake_mdl_v6"
|
bl_idname = "export_mesh.quake_mdl_v6"
|
||||||
bl_label = "Export MDL"
|
bl_label = "Export MDL"
|
||||||
|
bl_options = {'PRESET'};
|
||||||
|
|
||||||
filename_ext = ".mdl"
|
filename_ext = ".mdl"
|
||||||
filter_glob = StringProperty(default="*.mdl", options={'HIDDEN'})
|
filter_glob = StringProperty(default="*.mdl", options={'HIDDEN'})
|
||||||
|
|
||||||
|
eyeposition = FloatVectorProperty(
|
||||||
|
name="Eye Position",
|
||||||
|
description="View possion relative to object origin")
|
||||||
|
synctype = EnumProperty(
|
||||||
|
items=SYNCTYPE,
|
||||||
|
name="Sync Type",
|
||||||
|
description="Add random time offset for automatic animations")
|
||||||
|
rotate = BoolProperty(
|
||||||
|
name="Rotate",
|
||||||
|
description="Rotate automatically (for pickup items)",
|
||||||
|
default=False)
|
||||||
|
effects = EnumProperty(
|
||||||
|
items=EFFECTS,
|
||||||
|
name="Effects",
|
||||||
|
description="Particle trail effects")
|
||||||
|
xform = BoolProperty(
|
||||||
|
name="Auto transform",
|
||||||
|
description="Auto-apply location/rotation/scale when exporting",
|
||||||
|
default=True)
|
||||||
|
md16 = BoolProperty(
|
||||||
|
name="16-bit",
|
||||||
|
description="16 bit vertex coordinates: QuakeForge only")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return (context.active_object != None
|
return (context.active_object != None
|
||||||
|
|
|
@ -27,6 +27,7 @@ from .qfplist import pldata, PListError
|
||||||
from .quakepal import palette
|
from .quakepal import palette
|
||||||
from .quakenorm import map_normal
|
from .quakenorm import map_normal
|
||||||
from .mdl import MDL
|
from .mdl import MDL
|
||||||
|
from .__init__ import SYNCTYPE, EFFECTS
|
||||||
|
|
||||||
def check_faces(mesh):
|
def check_faces(mesh):
|
||||||
#Check that all faces are tris because mdl does not support anything else.
|
#Check that all faces are tris because mdl does not support anything else.
|
||||||
|
@ -185,14 +186,25 @@ def calc_average_area(mdl):
|
||||||
totalarea += (c * c) ** 0.5 / 2.0
|
totalarea += (c * c) ** 0.5 / 2.0
|
||||||
return totalarea / len(mdl.tris)
|
return totalarea / len(mdl.tris)
|
||||||
|
|
||||||
def get_properties(operator, mdl, obj):
|
def get_properties(
|
||||||
mdl.eyeposition = tuple(obj.qfmdl.eyeposition)
|
operator,
|
||||||
mdl.synctype = MDL.SYNCTYPE[obj.qfmdl.synctype]
|
mdl,
|
||||||
mdl.flags = ((obj.qfmdl.rotate and MDL.EF_ROTATE or 0)
|
eyeposition,
|
||||||
| MDL.EFFECTS[obj.qfmdl.effects])
|
synctype,
|
||||||
if obj.qfmdl.md16:
|
rotate,
|
||||||
|
effects,
|
||||||
|
xform,
|
||||||
|
md16):
|
||||||
|
mdl.eyeposition = eyeposition
|
||||||
|
mdl.synctype = MDL.SYNCTYPE[synctype]
|
||||||
|
mdl.flags = ((rotate and MDL.EF_ROTATE or 0)
|
||||||
|
| MDL.EFFECTS[effects])
|
||||||
|
if md16:
|
||||||
mdl.ident = "MD16"
|
mdl.ident = "MD16"
|
||||||
script = obj.qfmdl.script
|
|
||||||
|
#tomporarily disabled
|
||||||
|
#script = obj.qfmdl.script
|
||||||
|
script = None
|
||||||
mdl.script = None
|
mdl.script = None
|
||||||
if script:
|
if script:
|
||||||
try:
|
try:
|
||||||
|
@ -276,7 +288,18 @@ def process_frame(mdl, scene, frame, vertmap, ingroup = False,
|
||||||
fr.name = name
|
fr.name = name
|
||||||
return fr
|
return fr
|
||||||
|
|
||||||
def export_mdl(operator, context, filepath):
|
def export_mdl(
|
||||||
|
operator,
|
||||||
|
context,
|
||||||
|
filepath = "",
|
||||||
|
eyeposition = (0.0, 0.0, 0.0),
|
||||||
|
synctype = SYNCTYPE[1],
|
||||||
|
rotate = False,
|
||||||
|
effects = EFFECTS[1],
|
||||||
|
xform = True,
|
||||||
|
md16 = False
|
||||||
|
):
|
||||||
|
|
||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
mesh = obj.to_mesh(context.scene, True, 'PREVIEW') #wysiwyg?
|
mesh = obj.to_mesh(context.scene, True, 'PREVIEW') #wysiwyg?
|
||||||
#if not check_faces(mesh):
|
#if not check_faces(mesh):
|
||||||
|
@ -285,8 +308,17 @@ def export_mdl(operator, context, filepath):
|
||||||
# return {'CANCELLED'}
|
# return {'CANCELLED'}
|
||||||
mdl = MDL(obj.name)
|
mdl = MDL(obj.name)
|
||||||
mdl.obj = obj
|
mdl.obj = obj
|
||||||
if not get_properties(operator, mdl, obj):
|
if not get_properties(
|
||||||
return {'CANCELLED'}
|
operator,
|
||||||
|
mdl,
|
||||||
|
eyeposition,
|
||||||
|
synctype,
|
||||||
|
rotate,
|
||||||
|
effects,
|
||||||
|
xform,
|
||||||
|
md16):
|
||||||
|
return {'CANCELLED'}
|
||||||
|
|
||||||
mdl.tris, mdl.stverts, vertmap = build_tris(mesh)
|
mdl.tris, mdl.stverts, vertmap = build_tris(mesh)
|
||||||
if mdl.script:
|
if mdl.script:
|
||||||
if 'skins' in mdl.script:
|
if 'skins' in mdl.script:
|
||||||
|
@ -303,7 +335,7 @@ def export_mdl(operator, context, filepath):
|
||||||
for fno in range(context.scene.frame_start, context.scene.frame_end + 1):
|
for fno in range(context.scene.frame_start, context.scene.frame_end + 1):
|
||||||
context.scene.frame_set(fno)
|
context.scene.frame_set(fno)
|
||||||
mesh = obj.to_mesh(context.scene, True, 'PREVIEW') #wysiwyg?
|
mesh = obj.to_mesh(context.scene, True, 'PREVIEW') #wysiwyg?
|
||||||
if mdl.obj.qfmdl.xform:
|
if xform:
|
||||||
mesh.transform(mdl.obj.matrix_world)
|
mesh.transform(mdl.obj.matrix_world)
|
||||||
mdl.frames.append(make_frame(mesh, vertmap))
|
mdl.frames.append(make_frame(mesh, vertmap))
|
||||||
convert_stverts(mdl, mdl.stverts)
|
convert_stverts(mdl, mdl.stverts)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue