diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-01-14 15:00:52 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-01-14 15:10:18 +0300 |
commit | edad3f93f6da549456ffe8711336d34c7819dbe7 (patch) | |
tree | 50d76c655bedecb15121eaa1c0415da72dbb75f3 /release/scripts/modules/bpy_extras/io_utils.py | |
parent | c8a9a563a709d5b0946d83676ec2caf7125c6cbb (diff) |
Py IO utils: Add helper class to handle orientation (axes).
Also 'fix' T43243, since we can easily add a common better behavior now
when both axis settings are incompatible, by systematically changing
the other axis.
Will update 'main' addons in next commit, contrib ones I'll let to the authors
(old behavior is still possible anyway).
Diffstat (limited to 'release/scripts/modules/bpy_extras/io_utils.py')
-rw-r--r-- | release/scripts/modules/bpy_extras/io_utils.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/release/scripts/modules/bpy_extras/io_utils.py b/release/scripts/modules/bpy_extras/io_utils.py index b1877a9d439..d1eb01a4f11 100644 --- a/release/scripts/modules/bpy_extras/io_utils.py +++ b/release/scripts/modules/bpy_extras/io_utils.py @@ -21,6 +21,7 @@ __all__ = ( "ExportHelper", "ImportHelper", + "IOHelperOrientation", "axis_conversion", "axis_conversion_ensure", "create_derived_objects", @@ -116,6 +117,40 @@ class ImportHelper: return _check_axis_conversion(self) +class IOHelperOrientation: + def _update_axis_forward(self, context): + if self.axis_forward[-1] == self.axis_up[-1]: + self.axis_up = self.axis_up[0:-1] + 'XYZ'[('XYZ'.index(self.axis_up[-1]) + 1) % 3] + axis_forward = EnumProperty( + name="Forward", + items=(('X', "X Forward", ""), + ('Y', "Y Forward", ""), + ('Z', "Z Forward", ""), + ('-X', "-X Forward", ""), + ('-Y', "-Y Forward", ""), + ('-Z', "-Z Forward", ""), + ), + default='-Z', + update=_update_axis_forward, + ) + + def _update_axis_up(self, context): + if self.axis_up[-1] == self.axis_forward[-1]: + self.axis_forward = self.axis_forward[0:-1] + 'XYZ'[('XYZ'.index(self.axis_forward[-1]) + 1) % 3] + axis_up = EnumProperty( + name="Up", + items=(('X', "X Up", ""), + ('Y', "Y Up", ""), + ('Z', "Z Up", ""), + ('-X', "-X Up", ""), + ('-Y', "-Y Up", ""), + ('-Z', "-Z Up", ""), + ), + default='Y', + update=_update_axis_up, + ) + + # Axis conversion function, not pretty LUT # use lookup table to convert between any axis _axis_convert_matrix = ( |