diff options
author | Toni Alatalo <antont@kyperjokki.fi> | 2005-12-18 23:14:22 +0300 |
---|---|---|
committer | Toni Alatalo <antont@kyperjokki.fi> | 2005-12-18 23:14:22 +0300 |
commit | fae20e494e4d5d5f48a8a3c99938796d596537c2 (patch) | |
tree | ddce7c307c1e0b8b7c77ac985382b06dfe1401d4 /source/blender/src/editipo.c | |
parent | 3bba3813bde61d2bedfd1a2fa434c929ae12230a (diff) |
orange: animation baking code. also a patch to autokey, to only key the keys made.
Diffstat (limited to 'source/blender/src/editipo.c')
-rw-r--r-- | source/blender/src/editipo.c | 82 |
1 files changed, 79 insertions, 3 deletions
diff --git a/source/blender/src/editipo.c b/source/blender/src/editipo.c index 9834bdc704c..3fb48fb417f 100644 --- a/source/blender/src/editipo.c +++ b/source/blender/src/editipo.c @@ -1963,6 +1963,42 @@ void insertkey(ID *id, int blocktype, char *actname, char *constname, int adrcod } } +/* For inserting keys based on the object matrix - not on the current IPO value + Generically - it inserts the passed float value into the appropriate IPO */ +void insertmatrixkey(ID *id, int blocktype, char *actname, char *constname, int adrcode, float matrixvalue) +{ + IpoCurve *icu; + Object *ob; + void *poin= NULL; + float cfra; + int vartype; + + icu= verify_ipocurve(id, blocktype, actname, constname, adrcode); + + if(icu) { + + poin= get_context_ipo_poin(id, blocktype, actname, icu, &vartype); + + if(poin) { + + cfra= frame_to_float(CFRA); + + /* if action is mapped in NLA, it returns a correction */ + if(actname && actname[0] && GS(id->name)==ID_OB) + cfra= get_action_frame((Object *)id, cfra); + + if( GS(id->name)==ID_OB ) { + ob= (Object *)id; + if(ob->sf!=0.0 && (ob->ipoflag & OB_OFFS_OB) ) { + /* actually frametofloat calc again! */ + cfra-= ob->sf*G.scene->r.framelen; + } + } + insert_vert_ipo(icu, cfra, matrixvalue); + } + } +} + void insertkey_editipo(void) { EditIpo *ei; @@ -2340,7 +2376,7 @@ void common_insertkey(void) ob= OBACT; if (ob && (ob->flag & OB_POSEMODE)) { - strcpy(menustr, "Insert Key%t|Loc%x0|Rot%x1|Size%x2|LocRot%x3|LocRotSize%x4|Avail%x9"); + strcpy(menustr, "Insert Key%t|Loc%x0|Rot%x1|Size%x2|LocRot%x3|LocRotSize%x4|Avail%x9|VisualLoc%x11|VisualRot%x12|VisualLocRot%x13"); } else { base= FIRSTBASE; @@ -2350,7 +2386,7 @@ void common_insertkey(void) } if(base==NULL) return; - strcpy(menustr, "Insert Key%t|Loc%x0|Rot%x1|Size%x2|LocRot%x3|LocRotSize%x4|Layer%x5|Avail%x9"); + strcpy(menustr, "Insert Key%t|Loc%x0|Rot%x1|Size%x2|LocRot%x3|LocRotSize%x4|Layer%x5|Avail%x9|VisualLoc%x11|VisualRot%x12|VisualLocRot%x13"); } if(ob) { @@ -2408,6 +2444,25 @@ void common_insertkey(void) } } } + if(event==11 || event==13) { + float obSpaceBoneMat[4][4]; + + bone2objectspace(obSpaceBoneMat, pchan->pose_mat, pchan->bone->arm_mat); + insertmatrixkey(id, ID_PO, pchan->name, NULL, AC_LOC_X, obSpaceBoneMat[3][0]); + insertmatrixkey(id, ID_PO, pchan->name, NULL, AC_LOC_Y, obSpaceBoneMat[3][1]); + insertmatrixkey(id, ID_PO, pchan->name, NULL, AC_LOC_Z, obSpaceBoneMat[3][2]); + } + if(event==12 || event==13) { + float obSpaceBoneMat[4][4]; + float localQuat[4]; + + bone2objectspace(obSpaceBoneMat, pchan->pose_mat, pchan->bone->arm_mat); + Mat4ToQuat(obSpaceBoneMat, localQuat); + insertmatrixkey(id, ID_PO, pchan->name, NULL, AC_QUAT_W, localQuat[0]); + insertmatrixkey(id, ID_PO, pchan->name, NULL, AC_QUAT_X, localQuat[1]); + insertmatrixkey(id, ID_PO, pchan->name, NULL, AC_QUAT_Y, localQuat[2]); + insertmatrixkey(id, ID_PO, pchan->name, NULL, AC_QUAT_Z, localQuat[2]); + } } } if(ob->action) @@ -2460,6 +2515,21 @@ void common_insertkey(void) insertkey(id, ID_OB, actname, NULL, OB_LAY); base->object->lay= tlay; } + if(event==11 || event==13) { + insertmatrixkey(id, ID_OB, actname, NULL, OB_LOC_X, ob->obmat[3][0]); + insertmatrixkey(id, ID_OB, actname, NULL, OB_LOC_Y, ob->obmat[3][1]); + insertmatrixkey(id, ID_OB, actname, NULL, OB_LOC_Z, ob->obmat[3][2]); + } + if(event==12 || event==13) { + float eul[3]; + float rotMat[3][3]; + + Mat3CpyMat4(rotMat, ob->obmat); + Mat3ToEul(rotMat, eul); + insertmatrixkey(id, ID_OB, actname, NULL, OB_ROT_X, eul[0]*(5.72958)); + insertmatrixkey(id, ID_OB, actname, NULL, OB_ROT_Y, eul[1]*(5.72958)); + insertmatrixkey(id, ID_OB, actname, NULL, OB_ROT_Z, eul[2]*(5.72958)); + } } base= base->next; } @@ -4454,4 +4524,10 @@ void move_to_frame(void) BIF_undo_push("Set frame to selected Ipo vertex"); } - +void bone2objectspace(float obSpaceBoneMat[][4], float obSpace[][4], float restPos[][4]) +{ + float imat[4][4]; + + Mat4Invert(imat, restPos); + Mat4MulMat4(obSpaceBoneMat, obSpace, imat); +} |