diff options
author | Ton Roosendaal <ton@blender.org> | 2006-10-31 18:51:57 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-10-31 18:51:57 +0300 |
commit | 35d6c6e695351051febf7d6aa84761db1d733295 (patch) | |
tree | a23a19bcff44113fe830c92b9c71fa9539cbef76 /source/blender/src/drawnla.c | |
parent | 52c20fecba07fecb4964d1ef310eb944bccd68ea (diff) |
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
Diffstat (limited to 'source/blender/src/drawnla.c')
-rw-r--r-- | source/blender/src/drawnla.c | 135 |
1 files changed, 118 insertions, 17 deletions
diff --git a/source/blender/src/drawnla.c b/source/blender/src/drawnla.c index 9c66eae794b..a1a5bebe8d6 100644 --- a/source/blender/src/drawnla.c +++ b/source/blender/src/drawnla.c @@ -41,6 +41,7 @@ #include "BMF_Api.h" #include <stdlib.h> +#include <string.h> #include <stdio.h> #include "DNA_view3d_types.h" @@ -183,7 +184,13 @@ static void draw_nla_channels(void) BIF_icon_draw(x+16, y-8, ICON_DOT); glDisable(GL_BLEND); } + if(strip->modifiers.first) { + glEnable(GL_BLEND); + BIF_icon_draw(x+34, y-8, ICON_MODIFIER); + glDisable(GL_BLEND); + } } + y-=(NLACHANNELHEIGHT+NLACHANNELSKIP); } } @@ -398,6 +405,11 @@ static void draw_nla_strips_keys(SpaceNla *snla) #define B_NLA_PANEL 121 #define B_NLA_LOCK 122 +#define B_NLA_MOD_ADD 123 +#define B_NLA_MOD_NEXT 124 +#define B_NLA_MOD_PREV 125 +#define B_NLA_MOD_DEL 126 +#define B_NLA_MOD_DEPS 127 /* For now just returns the first selected strip */ bActionStrip *get_active_nlastrip(Object **obpp) @@ -442,19 +454,73 @@ void do_nlabuts(unsigned short event) allqueue (REDRAWACTION, 0); allqueue (REDRAWVIEW3D, 0); break; + + case B_NLA_MOD_ADD: + { + bActionModifier *amod= MEM_callocN(sizeof(bActionModifier), "bActionModifier"); + + BLI_addtail(&strip->modifiers, amod); + strip->curmod= BLI_countlist(&strip->modifiers)-1; + allqueue (REDRAWNLA, 0); + } + break; + case B_NLA_MOD_DEL: + if(strip->modifiers.first) { + bActionModifier *amod= BLI_findlink(&strip->modifiers, strip->curmod); + BLI_remlink(&strip->modifiers, amod); + MEM_freeN(amod); + if(strip->curmod) strip->curmod--; + allqueue (REDRAWNLA, 0); + } + break; + case B_NLA_MOD_NEXT: + if(strip->curmod < BLI_countlist(&strip->modifiers)-1) + strip->curmod++; + allqueue (REDRAWNLA, 0); + break; + case B_NLA_MOD_PREV: + if(strip->curmod > 0) + strip->curmod--; + allqueue (REDRAWNLA, 0); + break; + case B_NLA_MOD_DEPS: + DAG_scene_sort(G.scene); + DAG_object_flush_update(G.scene, ob, OB_RECALC_OB|OB_RECALC_DATA); + break; } } +static char *make_modifier_menu(ListBase *lb) +{ + bActionModifier *amod; + int index= 1; + char *str, item[64], *types[3]={"Deform", "Noise", "Oomph"}; + + for (amod = lb->first; amod; amod=amod->next, index++); + str= MEM_mallocN(index*64, "key string"); + str[0]= 0; + + index= 0; + for (amod = lb->first; amod; amod=amod->next, index++) { + sprintf (item, "|%s %s%%x%d", types[amod->type], amod->channel, index); + strcat(str, item); + } + + return str; +} + + static void nla_panel_properties(short cntrl) // NLA_HANDLER_PROPERTIES { Object *ob; bActionStrip *strip; uiBlock *block; + uiBut *but; block= uiNewBlock(&curarea->uiblocks, "nla_panel_properties", UI_EMBOSS, UI_HELV, curarea->win); uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | cntrl); uiSetPanelHandler(NLA_HANDLER_PROPERTIES); // for close and esc - if(uiNewPanel(curarea, block, "Transform Properties", "NLA", 10, 230, 318, 204)==0) return; + if(uiNewPanel(curarea, block, "Transform Properties", "NLA", 10, 230, 318, 224)==0) return; /* Determine if an nla strip has been selected */ strip = get_active_nlastrip(&ob); @@ -488,26 +554,61 @@ static void nla_panel_properties(short cntrl) // NLA_HANDLER_PROPERTIES uiBlockBeginAlign(block); uiDefButF(block, NUM, B_NLA_PANEL, "Repeat:", 160,100,150,19, &strip->repeat, 0.001, 1000.0f, 100, 0, "Number of times the action should repeat"); - uiDefButBitS(block, TOG, ACTSTRIP_HOLDLASTFRAME, B_NLA_PANEL, "Hold", 160,80,75,19, &strip->flag, 0, 0, 0, 0, "Toggles whether to continue displaying the last frame past the end of the strip"); - uiDefButS(block, TOG, B_NLA_PANEL, "Add", 235,80,75,19, &strip->mode, 0, 0, 0, 0, "Toggles additive blending mode"); + but= uiDefButC(block, TEX, B_NLA_PANEL, "OffsBone:", 160,80,150,19, strip->offs_bone, 0, 31.0f, 0, 0, "Name of Bone that defines offset for repeat"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)ob); + uiDefButBitS(block, TOG, ACTSTRIP_HOLDLASTFRAME, B_NLA_PANEL, "Hold", 160,60,75,19, &strip->flag, 0, 0, 0, 0, "Toggles whether to continue displaying the last frame past the end of the strip"); + uiDefButS(block, TOG, B_NLA_PANEL, "Add", 235,60,75,19, &strip->mode, 0, 0, 0, 0, "Toggles additive blending mode"); uiBlockEndAlign(block); - uiDefButBitS(block, TOG, ACTSTRIP_USESTRIDE, B_NLA_PANEL, "Stride Path", 10, 50,140,19, &strip->flag, 0, 0, 0, 0, "Plays action based on path position & stride"); - if(ob->dup_group) - uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_NLA_PANEL, "Target:", 160,50, 150, 19, &strip->object, "Target Object in this group"); - - uiBlockBeginAlign(block); - uiDefButBitS(block, TOG, OB_DISABLE_PATH, B_NLA_PANEL, "Disable", 10,20,60,19, &ob->ipoflag, 0, 0, 0, 0, "Disable path temporally, for editing cycles"); - - uiDefButF(block, NUM, B_NLA_PANEL, "Offs:", 70,20,120,19, &strip->actoffs, -500, 500.0, 100, 0, "Action offset in frames to tweak cycle of the action within the stride"); - uiDefButF(block, NUM, B_NLA_PANEL, "Stri:", 190,20,120,19, &strip->stridelen, 0.0001, 1000.0, 100, 0, "Distance covered by one complete cycle of the action specified in the Action Range"); + uiDefButBitS(block, TOG, ACTSTRIP_USESTRIDE, B_NLA_PANEL, "Stride Path", 10, 30,140,19, &strip->flag, 0, 0, 0, 0, "Plays action based on path position & stride"); - uiDefButS(block, ROW, B_NLA_PANEL, "X", 10, 0, 33, 19, &strip->stride_axis, 1, 0, 0, 0, "Dominant axis for Stride Bone"); - uiDefButS(block, ROW, B_NLA_PANEL, "Y", 43, 0, 33, 19, &strip->stride_axis, 1, 1, 0, 0, "Dominant axis for Stride Bone"); - uiDefButS(block, ROW, B_NLA_PANEL, "Z", 76, 0, 34, 19, &strip->stride_axis, 1, 2, 0, 0, "Dominant axis for Stride Bone"); + if(ob->dup_group) + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_NLA_PANEL, "Target:", 160,30, 150, 19, &strip->object, "Target Object in this group"); - uiDefBut(block, TEX, B_NLA_PANEL, "Stride Bone:", 110, 0, 200, 19, strip->stridechannel, 1, 31, 0, 0, "Name of Bone used for stride"); - + if(strip->flag & ACTSTRIP_USESTRIDE) { + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, OB_DISABLE_PATH, B_NLA_PANEL, "Disable", 10,0,60,19, &ob->ipoflag, 0, 0, 0, 0, "Disable path temporally, for editing cycles"); + + uiDefButF(block, NUM, B_NLA_PANEL, "Offs:", 70,0,120,19, &strip->actoffs, -500, 500.0, 100, 0, "Action offset in frames to tweak cycle of the action within the stride"); + uiDefButF(block, NUM, B_NLA_PANEL, "Stri:", 190,0,120,19, &strip->stridelen, 0.0001, 1000.0, 100, 0, "Distance covered by one complete cycle of the action specified in the Action Range"); + + uiDefButS(block, ROW, B_NLA_PANEL, "X", 10, -20, 33, 19, &strip->stride_axis, 1, 0, 0, 0, "Dominant axis for Stride Bone"); + uiDefButS(block, ROW, B_NLA_PANEL, "Y", 43, -20, 33, 19, &strip->stride_axis, 1, 1, 0, 0, "Dominant axis for Stride Bone"); + uiDefButS(block, ROW, B_NLA_PANEL, "Z", 76, -20, 34, 19, &strip->stride_axis, 1, 2, 0, 0, "Dominant axis for Stride Bone"); + + but= uiDefBut(block, TEX, B_NLA_PANEL, "Stride Bone:", 110, -20, 200, 19, strip->stridechannel, 1, 31, 0, 0, "Name of Bone used for stride"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)ob); + } + else { /* modifiers */ + bActionModifier *amod= BLI_findlink(&strip->modifiers, strip->curmod); + + uiBlockBeginAlign(block); + uiDefBut(block, BUT, B_NLA_MOD_ADD, "Add Modifier", 10,0,140,19, NULL, 0, 0, 0, 0, ""); + if(amod) { + char *strp= make_modifier_menu(&strip->modifiers); + + uiDefIconBut(block, BUT, B_NLA_MOD_NEXT, ICON_TRIA_LEFT, 150,0,20,19, NULL, 0, 0, 0, 0, "Previous Modifier"); + uiDefButS(block, MENU, B_NLA_PANEL, strp, 170,0,20,19, &strip->curmod, 0, 0, 0, 0, "Browse modifier"); + MEM_freeN(strp); + uiDefIconBut(block, BUT, B_NLA_MOD_PREV, ICON_TRIA_RIGHT, 190,0,20,19, NULL, 0, 0, 0, 0, "Next Modifier"); + uiDefButS(block, MENU, B_REDR, "Deform %x0|Noise %x1|Oomph %x2", 210,0,80,19, &amod->type, 0, 0, 0, 0, "Modifier type"); + uiDefIconBut(block, BUT, B_NLA_MOD_DEL, ICON_X, 290,0,20,19, NULL, 0, 0, 0, 0, "Delete Modifier"); + + if(amod->type==ACTSTRIP_MOD_DEFORM) { + but= uiDefBut(block, TEX, B_NLA_PANEL, "Chan:", 10, -20, 130, 19, amod->channel, 1, 31, 0, 0, "Name of channel used for modifier"); + uiButSetCompleteFunc(but, autocomplete_bone, (void *)ob); + uiDefButS(block, MENU, B_REDR, "All%x0|XY%x3|XZ%x2|YZ%x1", 140,-20,40,19, &amod->no_rot_axis, 0, 0, 0, 0, "Enable rotation axes (local for curve)"); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_NLA_MOD_DEPS, "Ob:", 180,-20, 130, 19, &amod->ob, "Curve Object"); + } + else + uiDefBut(block, LABEL, B_NOP, "Ack! Not implemented.", 10, -20, 150, 19, NULL, 0, 0, 0, 0, ""); + + } + else { /* for panel aligning */ + uiBlockEndAlign(block); + uiDefBut(block, LABEL, B_NOP, " ", 10, -20, 150, 19, NULL, 0, 0, 0, 0, ""); + } + } } static void nla_blockhandlers(ScrArea *sa) |