diff options
author | Joshua Leung <aligorith@gmail.com> | 2007-12-09 11:46:23 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2007-12-09 11:46:23 +0300 |
commit | d033c248d31c0471f218ebafc9a6034401a5246f (patch) | |
tree | a5b7252e7f69e7f8a75f28820e05215221d24eda /source/blender/src | |
parent | 259c807f70607386b63ff2c89d48cbefe97ffbe6 (diff) |
== Armature Visualisation - A few additions ==
* Added an option to make frame numbers of keyframes draw on bone-paths even when frame numbers for other points are not shown.
* Added a new ghosting method, which only shows the keyframes within a range.
Diffstat (limited to 'source/blender/src')
-rw-r--r-- | source/blender/src/buttons_editing.c | 17 | ||||
-rw-r--r-- | source/blender/src/drawarmature.c | 89 |
2 files changed, 93 insertions, 13 deletions
diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 6c033c02db2..059c705eab1 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -3986,10 +3986,13 @@ static void editing_panel_armature_visuals(Object *ob, bArmature *arm) uiDefBut(block, LABEL, 0, "Ghost Options", 10,180,150,20, 0, 0, 0, 0, 0, ""); uiBlockBeginAlign(block); - uiDefButS(block, MENU, REDRAWVIEW3D, "Ghosts %t|Around Current Frame %x0|In Range %x1", + uiDefButS(block, MENU, REDRAWVIEW3D, "Ghosts %t|Around Current Frame %x0|In Range %x1|On Keyframes %x2", 10, 160, 150, 20, &arm->ghosttype, 0, 0, 0, 0, "Choose range of Ghosts to draw for current Action"); - uiDefButS(block, NUM, REDRAWVIEW3D, "GStep: ", 10,140,150,20, &arm->ghostsize, 1.0f, 20.0f, 0, 0, "How many frames between Ghost instances"); + if (arm->ghosttype != ARM_GHOST_KEYS) + uiDefButS(block, NUM, REDRAWVIEW3D, "GStep: ", 10,140,150,20, &arm->ghostsize, 1.0f, 20.0f, 0, 0, "How many frames between Ghost instances"); + else + uiDefBut(block, LABEL, REDRAWVIEW3D, "GStep: N/A", 10,140,150,20, NULL, 0.0f, 0.0f, 0, 0, "How many frames between Ghost instances"); uiBlockEndAlign(block); uiBlockBeginAlign(block); @@ -3997,7 +4000,7 @@ static void editing_panel_armature_visuals(Object *ob, bArmature *arm) /* range is around current frame */ uiDefButS(block, NUM, REDRAWVIEW3D, "Ghost: ", 10,110,150,20, &arm->ghostep, 0.0f, 30.0f, 0, 0, "Draw Ghosts around current frame, for current Action"); } - else if (arm->ghosttype == ARM_GHOST_RANGE) { + else if (ELEM(arm->ghosttype, ARM_GHOST_RANGE, ARM_GHOST_KEYS)) { /* range is defined by start+end frame below */ uiDefButI(block, NUM,REDRAWVIEW3D,"GSta:",10,110,150,20, &arm->ghostsf,1.0,MAXFRAMEF, 0, 0, "The start frame for Ghost display range"); uiDefButI(block, NUM,REDRAWVIEW3D,"GEnd:",10,90,150,20, &arm->ghostef,arm->ghostsf,MAXFRAMEF, 0, 0, "The end frame for Ghost display range"); @@ -4008,9 +4011,11 @@ static void editing_panel_armature_visuals(Object *ob, bArmature *arm) uiDefBut(block, LABEL, 0, "Bone Paths Drawing:", 165,180,170,20, 0, 0, 0, 0, 0, ""); uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, ARM_PATH_FNUMS, REDRAWVIEW3D, "Frame Nums", 170, 160, 80, 20, &arm->pathflag, 0, 0, 0, 0, "Show frame numbers on path"); - uiDefButS(block, NUM, REDRAWVIEW3D, "PStep:",250,160,80,20, &arm->pathsize,1,100, 10, 50, "Frames between highlighted points on bone path"); - uiDefButBitS(block, TOG, ARM_PATH_KFRAS, REDRAWVIEW3D, "Show Keys", 170, 140, 160, 20, &arm->pathflag, 0, 0, 0, 0, "Show key frames on path"); + uiDefButS(block, NUM, REDRAWVIEW3D, "PStep:",170,160,80,20, &arm->pathsize,1,100, 10, 50, "Frames between highlighted points on bone path"); + uiDefButBitS(block, TOG, ARM_PATH_FNUMS, REDRAWVIEW3D, "Frame Nums", 250, 160, 80, 20, &arm->pathflag, 0, 0, 0, 0, "Show frame numbers on path"); + + uiDefButBitS(block, TOG, ARM_PATH_KFRAS, REDRAWVIEW3D, "Show Keys", 170, 140, 80, 20, &arm->pathflag, 0, 0, 0, 0, "Show key frames on path"); + uiDefButBitS(block, TOG, ARM_PATH_KFNOS, REDRAWVIEW3D, "Keyframe Nums", 250, 140, 80, 20, &arm->pathflag, 0, 0, 0, 0, "Show frame numbers of key frames on path"); uiBlockEndAlign(block); uiBlockBeginAlign(block); diff --git a/source/blender/src/drawarmature.c b/source/blender/src/drawarmature.c index 96038324a4b..9fb0e497159 100644 --- a/source/blender/src/drawarmature.c +++ b/source/blender/src/drawarmature.c @@ -1903,7 +1903,7 @@ static void draw_pose_paths(Object *ob) glPointSize(1.0); /* Draw frame numbers of keyframes */ - if (arm->pathflag & ARM_PATH_FNUMS) { + if ((arm->pathflag & ARM_PATH_FNUMS) || (arm->pathflag & ARM_PATH_KFNOS)) { for(a=0, fp=fp_start; a<len; a++, fp+=3) { for (ak= keys.first; ak; ak= ak->next) { if (ak->cfra == (a+sfra)) { @@ -1939,7 +1939,7 @@ static void draw_ghost_poses_range(Base *base) start = arm->ghostsf; end = arm->ghostef; - if (end<=start) + if (end <= start) return; stepsize= (float)(arm->ghostsize); @@ -1960,10 +1960,10 @@ static void draw_ghost_poses_range(Base *base) armature_rebuild_pose(ob, ob->data); /* child pointers for IK */ glEnable(GL_BLEND); - if(G.vd->zbuf) glDisable(GL_DEPTH_TEST); + if (G.vd->zbuf) glDisable(GL_DEPTH_TEST); /* draw from first frame of range to last */ - for(CFRA= start; CFRA<end; CFRA+=stepsize) { + for (CFRA= start; CFRA<end; CFRA+=stepsize) { colfac = (end-CFRA)/range; BIF_ThemeColorShadeAlpha(TH_WIRE, 0, -128-(int)(120.0f*sqrt(colfac))); @@ -1972,7 +1972,7 @@ static void draw_ghost_poses_range(Base *base) draw_pose_channels(base, OB_WIRE); } glDisable(GL_BLEND); - if(G.vd->zbuf) glEnable(GL_DEPTH_TEST); + if (G.vd->zbuf) glEnable(GL_DEPTH_TEST); free_pose_channels(posen); MEM_freeN(posen); @@ -1984,7 +1984,79 @@ static void draw_ghost_poses_range(Base *base) armature_rebuild_pose(ob, ob->data); ob->flag |= OB_POSEMODE; ob->ipoflag= ipoflago; +} +static void draw_ghost_poses_keys(Base *base) +{ + Object *ob= base->object; + bAction *act= ob_get_action(ob); + bArmature *arm= ob->data; + bPose *posen, *poseo; + ListBase keys= {NULL, NULL}; + ActKeyColumn *ak, *akn; + float start, end, range, colfac, i; + int cfrao, flago, ipoflago; + + start = arm->ghostsf; + end = arm->ghostef; + if (end <= start) + return; + + /* get keyframes - then clip to only within range */ + action_to_keylist(act, &keys, NULL); + range= 0; + for (ak= keys.first; ak; ak= akn) { + akn= ak->next; + + if ((ak->cfra < start) || (ak->cfra > end)) + BLI_freelinkN(&keys, ak); + else + range++; + } + if (range == 0) return; + + /* store values */ + ob->flag &= ~OB_POSEMODE; + cfrao= CFRA; + flago= arm->flag; + arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES); + ipoflago= ob->ipoflag; + ob->ipoflag |= OB_DISABLE_PATH; + + /* copy the pose */ + poseo= ob->pose; + copy_pose(&posen, ob->pose, 1); + ob->pose= posen; + armature_rebuild_pose(ob, ob->data); /* child pointers for IK */ + + glEnable(GL_BLEND); + if (G.vd->zbuf) glDisable(GL_DEPTH_TEST); + + /* draw from first frame of range to last */ + for (ak=keys.first, i=0; ak; ak=ak->next, i++) { + colfac = i/range; + BIF_ThemeColorShadeAlpha(TH_WIRE, 0, -128-(int)(120.0f*sqrt(colfac))); + + CFRA= (int)ak->cfra; + + do_all_pose_actions(ob); + where_is_pose(ob); + draw_pose_channels(base, OB_WIRE); + } + glDisable(GL_BLEND); + if (G.vd->zbuf) glEnable(GL_DEPTH_TEST); + + free_pose_channels(posen); + BLI_freelistN(&keys); + MEM_freeN(posen); + + /* restore */ + CFRA= cfrao; + ob->pose= poseo; + arm->flag= flago; + armature_rebuild_pose(ob, ob->data); + ob->flag |= OB_POSEMODE; + ob->ipoflag= ipoflago; } /* object is supposed to be armature in posemode */ @@ -2122,10 +2194,13 @@ int draw_armature(Base *base, int dt) arm->flag |= ARM_POSEMODE; } else if(ob->flag & OB_POSEMODE) { - if (arm->ghosttype == ARM_GHOST_RANGE){ + if (arm->ghosttype == ARM_GHOST_RANGE) { draw_ghost_poses_range(base); } - else { + else if (arm->ghosttype == ARM_GHOST_KEYS) { + draw_ghost_poses_keys(base); + } + else if (arm->ghosttype == ARM_GHOST_CUR) { if (arm->ghostep) draw_ghost_poses(base); } |