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

__init__.py « io_anim_nuke_chan - git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8d6cc7c93ef30f51568589419b56b54ad9571252 (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# ##### 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-80 compliant>

bl_info = {
    "name": "Nuke Animation Format (.chan)",
    "author": "Michael Krupa",
    "version": (1, 0),
    "blender": (2, 80, 0),
    "location": "File > Import/Export > Nuke (.chan)",
    "description": "Import/Export object's animation with nuke",
    "warning": "",
    "wiki_url": "https://docs.blender.org/manual/en/dev/addons/"
                "import_export/anim_nuke_chan.html",
    "category": "Import-Export",
}


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


import bpy
from bpy.types import Operator
from bpy_extras.io_utils import ImportHelper, ExportHelper
from bpy.props import (
        StringProperty,
        BoolProperty,
        EnumProperty,
        FloatProperty,
        )

# property shared by both operators
rotation_order = EnumProperty(
        name="Rotation order",
        description="Choose the export rotation order",
        items=(('XYZ', "XYZ", "XYZ"),
               ('XZY', "XZY", "XZY"),
               ('YXZ', "YXZ", "YXZ"),
               ('YZX', "YZX", "YZX"),
               ('ZXY', "ZXY", "ZXY"),
               ('ZYX', "ZYX", "ZYX"),
               ),
        default='XYZ')


class ImportChan(Operator, ImportHelper):
    """Import animation from .chan file, exported from nuke or houdini """ \
    """(the importer uses frame numbers from the file)"""
    bl_idname = "import_scene.import_chan"
    bl_label = "Import chan file"

    filename_ext = ".chan"

    filter_glob: StringProperty(default="*.chan", options={'HIDDEN'})

    rotation_order: rotation_order
    z_up: BoolProperty(
            name="Make Z up",
            description="Switch the Y and Z axis",
            default=True)

    sensor_width: FloatProperty(
            name="Camera sensor width",
            description="Imported camera sensor width",
            default=32.0)

    sensor_height: FloatProperty(
            name="Camera sensor height",
            description="Imported camera sensor height",
            default=18.0)

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        from . import import_nuke_chan
        return import_nuke_chan.read_chan(context,
                                          self.filepath,
                                          self.z_up,
                                          self.rotation_order,
                                          self.sensor_width,
                                          self.sensor_height)


class ExportChan(Operator, ExportHelper):
    """Export the animation to .chan file, readable by nuke and houdini """ \
    """(the exporter uses frames from the frames range)"""
    bl_idname = "export.export_chan"
    bl_label = "Export chan file"

    filename_ext = ".chan"
    filter_glob: StringProperty(default="*.chan", options={'HIDDEN'})
    y_up: BoolProperty(
            name="Make Y up",
            description="Switch the Y and Z axis",
            default=True)
    rotation_order: rotation_order

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        from . import export_nuke_chan
        return export_nuke_chan.save_chan(context,
                                          self.filepath,
                                          self.y_up,
                                          self.rotation_order)


def menu_func_import(self, context):
    self.layout.operator(ImportChan.bl_idname, text="Nuke (.chan)")


def menu_func_export(self, context):
    self.layout.operator(ExportChan.bl_idname, text="Nuke (.chan)")


def register():
    bpy.utils.register_class(ImportChan)
    bpy.utils.register_class(ExportChan)
    bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
    bpy.types.TOPBAR_MT_file_export.append(menu_func_export)


def unregister():
    bpy.utils.unregister_class(ImportChan)
    bpy.utils.unregister_class(ExportChan)
    bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
    bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)


if __name__ == "__main__":
    register()