Welcome to mirror list, hosted at ThFree Co, Russian Federation.

__init__.py « io_shape_mdd « op « scripts « release - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a48d16d87a66d6f40c7c2209c26aa7293b08f327 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# ##### BEGIN GPL LICENSE BLOCK #####
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

# <pep8 compliant>

# To support reload properly, try to access a package var, if it's there, reload everything
if "bpy" in locals():
    import imp
    if "import_mdd" in locals():
        imp.reload(import_mdd)
    if "export_mdd" in locals():
        imp.reload(export_mdd)


import bpy
from bpy.props import *
from io_utils import ExportHelper, ImportHelper


class ImportMDD(bpy.types.Operator, ImportHelper):
    '''Import MDD vertex keyframe file to shape keys'''
    bl_idname = "import_shape.mdd"
    bl_label = "Import MDD"

    filename_ext = ".mdd"
    filter_glob = StringProperty(default="*.mdd", options={'HIDDEN'})

    frame_start = IntProperty(name="Start Frame", description="Start frame for inserting animation", min=-300000, max=300000, default=0)
    frame_step = IntProperty(name="Step", min=1, max=1000, default=1)

    @classmethod
    def poll(cls, context):
        ob = context.active_object
        return (ob and ob.type == 'MESH')

    def execute(self, context):

        # initialize from scene if unset
        scene = context.scene
        if not self.frame_start:
            self.frame_start = scene.frame_current

        from . import import_mdd
        return import_mdd.load(self, context, **self.as_keywords(ignore=("filter_glob",)))


class ExportMDD(bpy.types.Operator, ExportHelper):
    '''Animated mesh to MDD vertex keyframe file'''
    bl_idname = "export_shape.mdd"
    bl_label = "Export MDD"

    filename_ext = ".mdd"
    filter_glob = StringProperty(default="*.mdd", options={'HIDDEN'})

    # get first scene to get min and max properties for frames, fps

    minframe = 1
    maxframe = 300000
    minfps = 1
    maxfps = 120

    # List of operator properties, the attributes will be assigned
    # to the class instance from the operator settings before calling.
    fps = IntProperty(name="Frames Per Second", description="Number of frames/second", min=minfps, max=maxfps, default=25)
    frame_start = IntProperty(name="Start Frame", description="Start frame for baking", min=minframe, max=maxframe, default=1)
    frame_end = IntProperty(name="End Frame", description="End frame for baking", min=minframe, max=maxframe, default=250)

    @classmethod
    def poll(cls, context):
        obj = context.active_object
        return (obj and obj.type == 'MESH')

    def execute(self, context):
        # initialize from scene if unset
        scene = context.scene
        if not self.frame_start:
            self.frame_start = scene.frame_start
        if not self.frame_end:
            self.frame_end = scene.frame_end
        if not self.fps:
            self.fps = scene.render.fps

        from . import export_mdd
        return export_mdd.save(self, context, **self.as_keywords(ignore=("check_existing", "filter_glob")))


def menu_func_import(self, context):
    self.layout.operator(ImportMDD.bl_idname, text="Lightwave Point Cache (.mdd)")


def menu_func_export(self, context):
    self.layout.operator(ExportMDD.bl_idname, text="Lightwave Point Cache (.mdd)")


def register():
    bpy.types.INFO_MT_file_import.append(menu_func_import)
    bpy.types.INFO_MT_file_export.append(menu_func_export)


def unregister():
    bpy.types.INFO_MT_file_import.remove(menu_func_import)
    bpy.types.INFO_MT_file_export.remove(menu_func_export)

if __name__ == "__main__":
    register()