Page 1 of 2

Animation code: Passing TagState's directly into fragments

Posted: Sun Feb 19, 2017 5:19 pm
by Personwithhat2
Basically this:

I have a fragment playing. I want to apply a new Tag to the fragment (action) running. I don't know how I'm supposed to pass a modified TagState into SetFragment.

I assume that global tags are updated on the fragment when the `AUTO_REINSTALL_BEST_MATCH` (via Auto-Update in the editor) is set on the fragment, in addition to on creation (I see a union with globalTags).

I think that global tags can be edited by accessing the AnimationContext's CTagState and doing a Set() for the new tag.

How do I apply it to only a specific fragment? There is only a `pass in the fragment tags you want` statement in the documentation, and I can't find a sample that doesn't use TAG_STATE_EMPTY.

Since there is only (one?) instance of CTagState (in the animation context) and creating a TagState depends on the CTagDefinition (Since CTagState just passes it along) I have no idea what I should do.

Do something like this? (pseudo code-ish)

Code: Select all

CTagState cState(ctagDefinition) ; cState.Set(TagID, true) SetFragment (.... cState.GetMask() ... )
But since it passes a ref to that TagState I'm not sure if this won't cause harm somewhere.

Plus, if I were to directly re-queue the fragment via the below, in order to (for example) clear the already-set tag or add another one:

Code: Select all

pAct->SetFragment(fragID, tagState.GetMask(), OPTION_IDX_RANDOM, 0, false);
Would that break something since I do that directly? (Yes, I know the function's protected, I got around that through inheritance etc.)
I'm calling this outside of an Action so ti's independent of the Update() and Pre-Update(). What kind of checks do I need to make this work? (Or would this work just fine for action updates?)

Re: Animation code: Passing TagState's directly into fragments

Posted: Wed Feb 22, 2017 6:36 am
by Personwithhat2
More Questions!!!

Would blending pre-designated animations via mannequin fulfill the same functions as the AimIK CE thing? (Aim poses etc.)
e.g. blend head movements left/right/up/down based off of player input

'How' to do this (at least in general) would be a big help since I'm not sure if making this another layer that Mannequin would blend would work right o-o

Re: Animation code: Passing TagState's directly into fragments

Posted: Thu Feb 23, 2017 1:28 am
by Personwithhat2
Where can I find details on the animation motion params? All I can get is this:
Some more practical example for 1D blend spaces with the remaining motion parameters:


All these parameters are linked to specialized C++ code, which extracts the values from the root-motion and uses them to drive the blend-spaces. Adding new parameters requires a change in C++ code.


Code: Select all

enum EMotionParamID { eMotionParamID_TravelSpeed = 0, eMotionParamID_TurnSpeed, eMotionParamID_TravelAngle, //!< Forward, backwards and sidestepping. eMotionParamID_TravelSlope, eMotionParamID_TurnAngle, //!< Idle2Move and idle-rotations. eMotionParamID_TravelDist, //!< Idle-steps. eMotionParamID_StopLeg, //!< Move2Idle. eMotionParamID_BlendWeight, //!< Custom parameters. eMotionParamID_BlendWeight2, eMotionParamID_BlendWeight3, eMotionParamID_BlendWeight4, eMotionParamID_BlendWeight5, eMotionParamID_BlendWeight6, eMotionParamID_BlendWeight7, eMotionParamID_BlendWeight_Last = eMotionParamID_BlendWeight7, eMotionParamID_COUNT, };

No comment on most of them....and it's not like 'forward,backwards, and sidestepping' describes what it does

Yes, the templates use them, but they just 'use' them it doesn't really describe it much either.

Re: Animation code: Passing TagState's directly into fragments

Posted: Fri Feb 24, 2017 12:16 am
by Personwithhat2
Another day, another lack of replies from anyone. ZZzzz

Re: Animation code: Passing TagState's directly into fragments

Posted: Fri Feb 24, 2017 6:45 pm
by revolutionart
Hi, here's a reply:

Wait for someone who can anwser your question.

Re: Animation code: Passing TagState's directly into fragments

Posted: Fri Feb 24, 2017 7:10 pm
by Personwithhat2
I'm shifting my work into other parts of the project so yeah, I'm waiting.

I do appreciate knowing that these forums are actually read and that the lack of a reply isn't because you treat me like an idiot, but rather because the people who can respond are busy. Which is fine, although obviously the questions I'm asking can be answered in 5 minutes by someone who knows the animation system. Which is really the only reason why I'm bothering, because 3 days of my time = 5 minutes of yours.

Re: Animation code: Passing TagState's directly into fragments

Posted: Sun Feb 26, 2017 8:22 pm
by ximbimbim
Hi, first for the TagState to using tagstate on fragments, you need to get id in animation context like this:

Code: Select all

TagID tid = m_pAnimationContext->state.GetDef().Find("TAG");
Then with animation context you set the new state to TRUE or FALSE, like this:

Code: Select all

m_pAnimationContext->state.Set(tid, true);
Maybe, you need set AUTO UPDATE flag to true on mannequin.

For AimIK i can't help you, I've never used it. But depending on the situation you can write a procedural clip
to make simple rotation of bone directly.

For motion params, in c++ don't have much to do, you only update values to been processed in mannequin.
The greater part of work is maded in Blendspace file, If you need to pass values to procedural clips you can use params.

sorry for my english.

Re: Animation code: Passing TagState's directly into fragments

Posted: Mon Feb 27, 2017 4:50 am
by Personwithhat2
None of that is what I was asking for.

The recommendation that you posted only changes GLOBAL tags (which I mentioned already).

The 'auto-update' is unrelated (and I mentioned that too), that just makes the fragment re-queue itself once global tags have changed, but it doesn't remove/add any fragment-related tags (not to sure on this last one, need to refresh memory). Even if it did check for that, it doesn't set the fragment specific tags. Which is what I need.

Using set-fragment directly makes it automatically register as 're-queuing self'.

Again, FRAGMENT-specific tags. NOT global tags. ... in+Actions
tagState: the fragtags you want to set.

I still appreciate the help, better than the zip from others so far.

Re: Animation code: Passing TagState's directly into fragments

Posted: Mon Feb 27, 2017 7:34 pm
by ximbimbim
I'm sorry, the command to update fragmentTag is similar to global, you actually use the same command but it should be a small adaptation to a TAction class.

Code: Select all

pAnimationContext->state.GetDef().Set(FragState, tagID, <value>);
So if you call the method using the GetFragTagState command from TAction it will not change the state because the tag state class is passed by copy.

Then you can create a command within a custom IAction to update it by using GetContext (), or create a command to pass m_fragTags by reference and use it in:

Code: Select all

pAnimationContext->state.GetDef().Set(FragState, tagID, <value>);
This way it is not necessary to call SetFragment.


Code: Select all

class TMyAction : public TAction<SAnimationContext> { public: ... // METHOD 1 TagState& GetFragTag() { << Pass m_fragTags by reference return m_fragTags; } // METHOD 2 void SetFlagId(TagID flag, bool value) { GetContext().state.GetDef().Set(m_fragTags, tag, value); } }; // Set fragID // METHOD 1 m_pAnimationContext->state.GetDef().Set(pMyAction->GetFragTag(), id, true); // METHOD 2 pAction->SetFlagId(<tagID>, true|false);

Re: Animation code: Passing TagState's directly into fragments

Posted: Tue Feb 28, 2017 7:08 pm
by Personwithhat2
That might work...

I was hoping that I wouldn't have to derive.

That might set the fragTags but that doesn't update the fragment running depending on the tags(?)
Unless I'm missing something? I run SetFragment to update tags and change the fragment. Just changing tags doesn't help and I don't think auto-update works on non-global tags.