diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-12-19 13:27:23 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-12-19 13:27:23 +0300 |
commit | 3e23f002b42dc1892665e1705f9f107c4e047b8a (patch) | |
tree | afee38661589d491c664d04855c64e3f263a44df /source/blender/blenkernel | |
parent | de7ffa1bac820a45a65e31cd367bc446153c89af (diff) |
fix for non Euler-XYZ rotations...
- Camera to 3D view didnt check for rotation order.
- Fly mode didnt check for rotation order.
added util functions.
- object_apply_mat4(ob, mat4); applies a 4x4 matrix to an objects loc,scale,rot (accounting for rotation modes)
- object_mat3_to_rot(ob, mat3, use_compat); apply a 3x3 matrix to the objects rotation, option to use a euler compatible with the existing euler.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 26 |
2 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index aeb33cd3628..3e239e91453 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -93,8 +93,10 @@ void disable_speed_curve(int val); float bsystem_time(struct Scene *scene, struct Object *ob, float cfra, float ofs); void object_scale_to_mat3(struct Object *ob, float mat[][3]); void object_rot_to_mat3(struct Object *ob, float mat[][3]); +void object_mat3_to_rot(struct Object *ob, float mat[][3], int use_compat); void object_to_mat3(struct Object *ob, float mat[][3]); void object_to_mat4(struct Object *ob, float mat[][4]); +void object_apply_mat4(struct Object *ob, float mat[][4]); void set_no_parent_ipo(int val); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 9a7a3501031..676ab081533 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1618,6 +1618,32 @@ void object_rot_to_mat3(Object *ob, float mat[][3]) mul_m3_m3m3(mat, dmat, rmat); } +void object_mat3_to_rot(Object *ob, float mat[][3], int use_compat) +{ + if (ob->rotmode == ROT_MODE_QUAT) + mat3_to_quat(ob->quat, mat); + else if (ob->rotmode == ROT_MODE_AXISANGLE) + mat3_to_axis_angle(ob->rotAxis, &ob->rotAngle, mat); + else { + if(use_compat) { + float eul[3]; + VECCOPY(eul, ob->rot); + mat3_to_compatible_eulO(ob->rot, eul, ob->rotmode, mat); + } + else + mat3_to_eulO(ob->rot, ob->rotmode, mat); + } +} + +void object_apply_mat4(Object *ob, float mat[][4]) +{ + float mat3[3][3]; + VECCOPY(ob->loc, mat[3]); + mat4_to_size(ob->size, mat); + copy_m3_m4(mat3, mat); + object_mat3_to_rot(ob, mat3, 0); +} + void object_to_mat3(Object *ob, float mat[][3]) /* no parent */ { float smat[3][3]; |