Blender  V2.93
abc_axis_conversion.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2016 Kévin Dietrich & Blender Foundation.
17  * All rights reserved.
18  */
19 #pragma once
20 
25 #include "BLI_compiler_compat.h"
26 
27 struct Object;
28 
29 namespace blender::io::alembic {
30 
31 /* TODO(kevin): for now keeping these transformations hardcoded to make sure
32  * everything works properly, and also because Alembic is almost exclusively
33  * used in Y-up software, but eventually they'll be set by the user in the UI
34  * like other importers/exporters do, to support other axis. */
35 
36 /* Copy from Y-up to Z-up. */
37 
38 BLI_INLINE void copy_zup_from_yup(float zup[3], const float yup[3])
39 {
40  const float old_yup1 = yup[1]; /* in case zup == yup */
41  zup[0] = yup[0];
42  zup[1] = -yup[2];
43  zup[2] = old_yup1;
44 }
45 
46 BLI_INLINE void copy_zup_from_yup(short zup[3], const short yup[3])
47 {
48  const short old_yup1 = yup[1]; /* in case zup == yup */
49  zup[0] = yup[0];
50  zup[1] = -yup[2];
51  zup[2] = old_yup1;
52 }
53 
54 /* Copy from Z-up to Y-up. */
55 
56 BLI_INLINE void copy_yup_from_zup(float yup[3], const float zup[3])
57 {
58  const float old_zup1 = zup[1]; /* in case yup == zup */
59  yup[0] = zup[0];
60  yup[1] = zup[2];
61  yup[2] = -old_zup1;
62 }
63 
64 BLI_INLINE void copy_yup_from_zup(short yup[3], const short zup[3])
65 {
66  const short old_zup1 = zup[1]; /* in case yup == zup */
67  yup[0] = zup[0];
68  yup[1] = zup[2];
69  yup[2] = -old_zup1;
70 }
71 
72 /* Names are given in (dst, src) order, just like
73  * the parameters of copy_m44_axis_swap() */
74 typedef enum {
78 
79 /* Create a rotation matrix for each axis from euler angles.
80  * Euler angles are swapped to change coordinate system. */
81 void create_swapped_rotation_matrix(float rot_x_mat[3][3],
82  float rot_y_mat[3][3],
83  float rot_z_mat[3][3],
84  const float euler[3],
85  AbcAxisSwapMode mode);
86 
87 void copy_m44_axis_swap(float dst_mat[4][4], float src_mat[4][4], AbcAxisSwapMode mode);
88 
89 typedef enum {
93 
95  float r_yup_mat[4][4],
96  AbcMatrixMode mode,
97  Object *proxy_from);
98 
99 } // namespace blender::io::alembic
#define BLI_INLINE
void create_swapped_rotation_matrix(float rot_x_mat[3][3], float rot_y_mat[3][3], float rot_z_mat[3][3], const float euler[3], AbcAxisSwapMode mode)
BLI_INLINE void copy_yup_from_zup(float yup[3], const float zup[3])
void copy_m44_axis_swap(float dst_mat[4][4], float src_mat[4][4], AbcAxisSwapMode mode)
BLI_INLINE void copy_zup_from_yup(float zup[3], const float yup[3])
void create_transform_matrix(Object *obj, float r_yup_mat[4][4], AbcMatrixMode mode, Object *proxy_from)