diff options
author | Martin Poirier <theeth@yahoo.com> | 2009-10-28 23:30:33 +0300 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2009-10-28 23:30:33 +0300 |
commit | 3187e365d90f5c0e46d721370c0d381f83813c66 (patch) | |
tree | 754be9c6f41f10e671a77ea59cce820214c8e09c /source/blender/blenlib/intern/arithb.c | |
parent | c2f9cfb40a740f926d78cbdb20f1f8b09cc7aadd (diff) |
Gimbal Transform orientations
Will use rotation gimbal axis when an object or bone set to Euler rotation mode is selected (global axis otherwise)
Use case: being able to do rotations that only affect one animation curve in the 3d view instead of just in the curve editor.
I'm committing this right now despite what follows because it's already useful as is.
Known bug: manipulator arrows can look slightly skewed (not really a big problem), but more importantly, rotation circles for the rotation manipulator are skewed and will not perfectly reflect the rotation axis (it will still use the correct one though). That will be fixed shortly.
To do: This orientation should act like Local, where each object/bone uses its own orientation and not just the one of the active object/bone.
Note: Saved files with custom orientations might end up with other orientations selected when being opened up. I don't think it's that useful to make a do_version for that, but I can if warranted.
Diffstat (limited to 'source/blender/blenlib/intern/arithb.c')
-rw-r--r-- | source/blender/blenlib/intern/arithb.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c index 6c9ae78bac4..0d3304557c3 100644 --- a/source/blender/blenlib/intern/arithb.c +++ b/source/blender/blenlib/intern/arithb.c @@ -3312,6 +3312,69 @@ void Mat3ToCompatibleEul(float mat[][3], float *eul, float *oldrot) } +/* the matrix is written to as 3 axis vectors */ +void EulToGimbalAxis(float gmat[][3], float *eul, short order) +{ + RotOrderInfo *R= GET_ROTATIONORDER_INFO(order); + short R_order[3]; + short R_order2[3]; + + float quat[4]; + float teul[3]; + float tvec[3]; + int i, a; + + R_order2[R->i]= 0; + R_order2[R->j]= 1; + R_order2[R->k]= 2; + + R_order[0]= R->i; + R_order[1]= R->j; + R_order[2]= R->k; + + for(i= 0; i<3; i++) { + tvec[0]= tvec[1]= tvec[2]= 0.0f; + tvec[i] = 1.0f; + + VecCopyf(teul, eul); + + for(a= R_order2[i]; a >= 1; a--) + teul[R_order[a-1]]= 0.0f; + + EulOToQuat(teul, order, quat); + NormalQuat(quat); + QuatMulVecf(quat, tvec); + Normalize(tvec); + + VecCopyf(gmat[i], tvec); + } + + +#if 0 + + for(i= 0; i<3; i++) { + tvec[0]= tvec[1]= tvec[2]= 0.0f; + tvec[i] = 1.0f; + + VecCopyf(teul, eul); + + for(a= R_order2[i]; a >= 1; a--) + teul[R_order[a-1]]= 0.0f; + + EulToQuat(teul, quat); + NormalQuat(quat); + QuatMulVecf(quat, tvec); + Normalize(tvec); + + VecCopyf(gmat[i], tvec); + } +#endif + + + + +} + /* ************ AXIS ANGLE *************** */ /* Axis angle to Quaternions */ |