Make rest-frame optional (default off)
When the rest frame is included, increase the total-frame variable written to the MDD. D1923 by @unixcyclist with edits
This commit is contained in:
parent
8b80d24da9
commit
fe34f82e70
|
@ -39,7 +39,12 @@ if "bpy" in locals():
|
|||
|
||||
|
||||
import bpy
|
||||
from bpy.props import StringProperty, IntProperty, FloatProperty
|
||||
from bpy.props import (
|
||||
BoolProperty,
|
||||
FloatProperty,
|
||||
IntProperty,
|
||||
StringProperty,
|
||||
)
|
||||
from bpy_extras.io_utils import ExportHelper, ImportHelper
|
||||
|
||||
|
||||
|
@ -95,7 +100,7 @@ class ExportMDD(bpy.types.Operator, ExportHelper):
|
|||
|
||||
# get first scene to get min and max properties for frames, fps
|
||||
|
||||
minframe = 1
|
||||
minframe = 0
|
||||
maxframe = 300000
|
||||
minfps = 1.0
|
||||
maxfps = 120.0
|
||||
|
@ -120,6 +125,11 @@ class ExportMDD(bpy.types.Operator, ExportHelper):
|
|||
min=minframe, max=maxframe,
|
||||
default=250,
|
||||
)
|
||||
use_rest_frame = BoolProperty(
|
||||
name="Rest Frame",
|
||||
description="Write the rest state at the first frame",
|
||||
default=False,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
|
|
|
@ -51,7 +51,7 @@ def check_vertcount(mesh, vertcount):
|
|||
raise Exception('Error, number of verts has changed during animation, cannot export')
|
||||
|
||||
|
||||
def save(context, filepath="", frame_start=1, frame_end=300, fps=25.0):
|
||||
def save(context, filepath="", frame_start=1, frame_end=300, fps=25.0, use_rest_frame=False):
|
||||
"""
|
||||
Blender.Window.WaitCursor(1)
|
||||
|
||||
|
@ -82,6 +82,9 @@ def save(context, filepath="", frame_start=1, frame_end=300, fps=25.0):
|
|||
numverts = len(me.vertices)
|
||||
|
||||
numframes = frame_end - frame_start + 1
|
||||
if use_rest_frame:
|
||||
numframes += 1
|
||||
|
||||
f = open(filepath, 'wb') # no Errors yet:Safe to create file
|
||||
|
||||
# Write the header
|
||||
|
@ -90,10 +93,10 @@ def save(context, filepath="", frame_start=1, frame_end=300, fps=25.0):
|
|||
# Write the frame times (should we use the time IPO??)
|
||||
f.write(pack(">%df" % (numframes), *[frame / fps for frame in range(numframes)])) # seconds
|
||||
|
||||
#rest frame needed to keep frames in sync
|
||||
check_vertcount(me, numverts)
|
||||
me.transform(mat_flip * obj.matrix_world)
|
||||
f.write(pack(">%df" % (numverts * 3), *[axis for v in me.vertices for axis in v.co]))
|
||||
if use_rest_frame:
|
||||
check_vertcount(me, numverts)
|
||||
me.transform(mat_flip * obj.matrix_world)
|
||||
f.write(pack(">%df" % (numverts * 3), *[axis for v in me.vertices for axis in v.co]))
|
||||
|
||||
for frame in range(frame_start, frame_end + 1): # in order to start at desired frame
|
||||
scene.frame_set(frame)
|
||||
|
|
Loading…
Reference in New Issue