Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup unity skeletons for inverse kinematics #49

Open
ammaraskar opened this issue Aug 16, 2023 · 8 comments
Open

Setup unity skeletons for inverse kinematics #49

ammaraskar opened this issue Aug 16, 2023 · 8 comments

Comments

@ammaraskar
Copy link
Collaborator

ammaraskar commented Aug 16, 2023

We have basic animations from the game now!

ReclinerFixed.webm

These currently only work on bones and morphs (also I'm using the bone names instead of the bone CRC32) but this will not work for things like the Sims animations, those use a chain of inverse kinematics and basically only encode hand movements and such. This also applies to some more complicated objects like the cowplant with it's 17 neck bones.

image-1

@ammaraskar
Copy link
Collaborator Author

Animations for sims work too, but without the IK they look a little whacky. Notice how straight the arms are here:

Drowning.webm

@ammaraskar
Copy link
Collaborator Author

As of becb981 we now have good foot IK. The boxes are supposed to be the goal-IK positions from the animation

DrowningWithIK.webm

and

StairWalkUpWithFullik.webm

The arm IK still needs work, it seems to be a little more complicated. They appear to use a 1 float channel, this is the IkWeight portion of the IKTarget that controls how much weight the IK has.

@ammaraskar
Copy link
Collaborator Author

Punching.webm

Arm IK seems to be working now! Turns out l_handcontrol0 and r_handcontrol0 were parented to the root_trans of the skeleton in the scenegraph despite being animated in absolute positions...

We still have to handle IkWeight to handle arms properly in some animations.

@ammaraskar
Copy link
Collaborator Author

Getting close now, I added a little animation viewer to the SimsAnimationTest scene. A lot of stuff plays properly but the head look-at IK and spine position still need work.

AnimationsDemo.webm

@LazyDuchess
Copy link
Owner

even with the wonky rotations this is still insanely impressive. can definitely see some of that wonkiness in the arms and legs there but overall it's really coming together

@ammaraskar
Copy link
Collaborator Author

The next issue seems to be related to the headingOffset parameter. Some animations like a2o-exerciseMachine-benchPress-start_anim have really weird looking data.

For reference this is the original animation in game:

InGameBenchPressWithAnimationDebug.webm

This is what it looks like in unity if we just use the raw data:

RawUnityBenchPress.webm

image


The way to make it look kinda normal is to set the root_rot's z rotation values zero and add 89.95 to the x rotation values. The heading offset for the clip is -1.570 radians, which is -89.95 degrees.

UnityBenchPressKindaWorking.webm

image

@ammaraskar
Copy link
Collaborator Author

Welp that was a stupid bug. Turns out the order of rotations when converting from euler rotations in sims2 is different from unity. Now a lot more animations play properly with 380b83a

UnityBenchPressWorking.webm

@ammaraskar
Copy link
Collaborator Author

Just documenting this here but LazyDuchess pointed out that face blends seem to also be working, they're just hard to see without any texture:

uqYtnPj.mp4

Next up is head look-at IK and then all this code should be moved to an animation controller so different animations can be blended but this is basically done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants