Skip to content
Snippets Groups Projects
Commit fe34f82e authored by Campbell Barton's avatar Campbell Barton
Browse files

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
parent 8b80d24d
No related branches found
No related tags found
No related merge requests found
...@@ -39,7 +39,12 @@ if "bpy" in locals(): ...@@ -39,7 +39,12 @@ if "bpy" in locals():
import bpy 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 from bpy_extras.io_utils import ExportHelper, ImportHelper
...@@ -95,7 +100,7 @@ class ExportMDD(bpy.types.Operator, ExportHelper): ...@@ -95,7 +100,7 @@ class ExportMDD(bpy.types.Operator, ExportHelper):
# get first scene to get min and max properties for frames, fps # get first scene to get min and max properties for frames, fps
minframe = 1 minframe = 0
maxframe = 300000 maxframe = 300000
minfps = 1.0 minfps = 1.0
maxfps = 120.0 maxfps = 120.0
...@@ -120,6 +125,11 @@ class ExportMDD(bpy.types.Operator, ExportHelper): ...@@ -120,6 +125,11 @@ class ExportMDD(bpy.types.Operator, ExportHelper):
min=minframe, max=maxframe, min=minframe, max=maxframe,
default=250, default=250,
) )
use_rest_frame = BoolProperty(
name="Rest Frame",
description="Write the rest state at the first frame",
default=False,
)
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
......
...@@ -51,7 +51,7 @@ def check_vertcount(mesh, vertcount): ...@@ -51,7 +51,7 @@ def check_vertcount(mesh, vertcount):
raise Exception('Error, number of verts has changed during animation, cannot export') 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) Blender.Window.WaitCursor(1)
...@@ -82,6 +82,9 @@ def save(context, filepath="", frame_start=1, frame_end=300, fps=25.0): ...@@ -82,6 +82,9 @@ def save(context, filepath="", frame_start=1, frame_end=300, fps=25.0):
numverts = len(me.vertices) numverts = len(me.vertices)
numframes = frame_end - frame_start + 1 numframes = frame_end - frame_start + 1
if use_rest_frame:
numframes += 1
f = open(filepath, 'wb') # no Errors yet:Safe to create file f = open(filepath, 'wb') # no Errors yet:Safe to create file
# Write the header # Write the header
...@@ -90,10 +93,10 @@ def save(context, filepath="", frame_start=1, frame_end=300, fps=25.0): ...@@ -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??) # Write the frame times (should we use the time IPO??)
f.write(pack(">%df" % (numframes), *[frame / fps for frame in range(numframes)])) # seconds f.write(pack(">%df" % (numframes), *[frame / fps for frame in range(numframes)])) # seconds
#rest frame needed to keep frames in sync if use_rest_frame:
check_vertcount(me, numverts) check_vertcount(me, numverts)
me.transform(mat_flip * obj.matrix_world) me.transform(mat_flip * obj.matrix_world)
f.write(pack(">%df" % (numverts * 3), *[axis for v in me.vertices for axis in v.co])) 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 for frame in range(frame_start, frame_end + 1): # in order to start at desired frame
scene.frame_set(frame) scene.frame_set(frame)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment