Partial Animation Playback and Selective IK


#1

So now that we got Blender animations working, I’ve been looking at doing something silly for Vive users:

Basically, I have script, that uses the HMD object to define its position, and playback an animation depending at what height position the HMD is at, and at what pitch is the user is looking at the world.

How would I go along doing through script selectively disable some (not all) IK features. Specifically I’d want to disable the legs, but keep the arms, head, neck, spine2, working as they do.


#2

I think i figured this out after digging the repository dump during my lunch break. Will be trying it out later today.

Basically, have to use addAnimationStateHandler, and apply

{ inAirAlpha:0.0 }

to remove leg IK.
Then to restore it,

{ inAirAlpha:1.0 }

And to use removeAnimationStateHandler to remove the earlier override.

I realized this when flying around Playa last night and noticing I still had hand tracking, while my feet were not planted on any “ground” like they do when IK is involved.


#3

Notes, You must define the first variable as a callback function
So,

var inAirAlpha = function(t){ return {“inAirAlpha”:0.0, “isInAirStand”:true}; }

Otherwise one Crashes. HARD. needs some safeguards to avoid crashes if incorrect values are used. Similarly could be used to crash others.
Edit: PR 7670 is trying safeguard these.

MyAvatar.addAnimationStateHandler(inAirAlpha , null);

Unfortunately, I couldnt get it to work on my first try. my feet still arent overriden, might need to experiment some more.

Could a dev give me a hint how to go about this? (Disabling IK for Legs)


#4

Thanks for that clue, @Menithal, I might be able to move forward again with the ‘judas’ project.


#5

If you figure something out, do tell. I am still stuck with this as I said in my lastest reply to the thread. I think it is something in the direction of using stateHandler and roleAnimations: but I havent seen any examples.


#6

Ah the Judas project that was the enslavement of the Finnish .expects it’s going as well as trump is with r/Sweden lol


#7

:slight_smile: it is more about :seat::pensive:


#8

@Chris was there any better solutions to this?


#9

@Caitlyn @Chris apparently missed / forgot to post to this post last week, could I get any info on how to do this from the devs? thanks.


#10

Hey, there are a couple of knobs you can use to control IK on your avatar. They all use MyAvatar.addAnimationStateHandler(function, string[]) API. This is kind of an advanced API and it hasn’t been documented yet, because it’s subject to change and our doc writer is pretty busy preparing other docs…

Anyhow, so here it goes. When the C++ code controls the animation system by passing it animation states, which is a set of key-value pairs. Each key is a string describing the name of the variable and the value can be a different type depending on what that variable is used for. (bool, vec3, quat, etc.) This animation state is updated every frame by the C++ code and passed to the animation system. Examples: If the user is using hand controllers, the “rightHandPosition” vec3 variable is passed to the system for performing inverse kinematics. The animation system will then attempt to manipulate the arms such that the hand matches the position specified in this variable.

Ok, so the animationStateHandler in JavaScript can be used to intercept and override these values from C++. So, for example if you wanted to override the rightHandPosition and specify your own, you could. See this script for an example.

To selectively disable some IK targets and not others, you can change the IK type to None. This type is also held in an animation state variable. For example “rightHandType”. See this script for an example of how to disable the feet IK targets but not the head and hands.

So, the names of these variables aren’t hidden from you, they are specified in the avatar-animation.json, they just aren’t documented. You can do a search for all the fields with var in them, and get a list. Here are some of the most relevant variables used to control IK.

  • ikOverlayAlpha - fade in and out inverseKinematics 1.0 is on. 1.0 is off
  • rightHandPosition - vec3
  • rightHandRotation - quat
  • rightHandType - IK type (RotationAndPosition, RotationOnly, HmdHead, HipsRelativeRotationAndPosition, OFF)
  • leftHandPosition - vec3
  • leftHandRotation - quat
  • leftHandType - IK type (RotationAndPosition, RotationOnly, HmdHead, HipsRelativeRotationAndPosition, OFF)
  • rightFootPosition - vec3
  • rightFootRotation - quat
  • rightFootType - IK type (RotationAndPosition, RotationOnly, HmdHead, HipsRelativeRotationAndPosition, OFF)
  • leftFootPosition - vec3
  • leftFootRotation - quat
  • leftFootType - IK type (RotationAndPosition, RotationOnly, HmdHead, HipsRelativeRotationAndPosition, OFF)
  • neckPosition - vec3
  • neckRotation - quat
  • neckType - IK type (RotationAndPosition, RotationOnly, HmdHead, HipsRelativeRotationAndPosition, OFF)
  • headPosition - vec3
  • headRotation - quat
  • headType - IK type (RotationAndPosition, RotationOnly, HmdHead, HipsRelativeRotationAndPosition, OFF)
  • rightHandOverlayAlpha - 0.0 will not override the right hand animation at all, 1.0 will replace it with the grab animation.
  • rightHandGraspAlpha - (0, 1) used to blend between hand open and hand closed poses
  • leftHandOverlayAlpha - 0.0 will not override the left hand animation at all, 1.0 will replace it with the grab animation.
  • leftHandGraspAlpha - (0, 1) used to blend between hand open and hand closed poses
  • inAirAlpha - When avatar in mid-air this is used to blend between the pre-apex, apex and post-apex poses.

Hope this helps,


#11

Thank you much! This will help me finish up sit.