[Bf-extensions-cvs] [fe34f82] master: Make rest-frame optional (default off)
Campbell Barton
noreply at git.blender.org
Tue Apr 26 13:37:49 CEST 2016
Commit: fe34f82e7059bb6b89dfc88b55f030111f2d431f
Author: Campbell Barton
Date: Tue Apr 26 21:39:12 2016 +1000
Branches: master
https://developer.blender.org/rBAfe34f82e7059bb6b89dfc88b55f030111f2d431f
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
===================================================================
M io_shape_mdd/__init__.py
M io_shape_mdd/export_mdd.py
===================================================================
diff --git a/io_shape_mdd/__init__.py b/io_shape_mdd/__init__.py
index beef8d4..7715b18 100644
--- a/io_shape_mdd/__init__.py
+++ b/io_shape_mdd/__init__.py
@@ -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):
diff --git a/io_shape_mdd/export_mdd.py b/io_shape_mdd/export_mdd.py
index e7fda3a..155f664 100644
--- a/io_shape_mdd/export_mdd.py
+++ b/io_shape_mdd/export_mdd.py
@@ -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)
More information about the Bf-extensions-cvs
mailing list