Flipping a Pose over an Axis?

Howdy developers!

Today I’m calling on the help of anyone who knows how to properly use CFrames. I have what I think is a simple problem, I just have no idea what the solution is.

I’m trying to take a number of poses in an animation and modify their CFrames so that the left arm perfectly matches the right arm, albeit flipped over the vertical axis so things look correct. As you can see below, I’ve simply duplicated the Pose “RightUpperArm” and renamed it to “LeftUpperArm”, and this is the result. It’s a perfect match of the RightUpperArm, but that’s not what I’m after (left pistol grip is different, that is all). I want this to be flipped so it looks natural. I’ve tried messing around with some stuff like :fromMatrix() and :GetComponents() but it seems to produce some results I don’t understand fully.

How would you accomplish this?

e8675155cbd33297bc9a8ddc29946f3e

3 Likes

You could try doing something like this for each animation transform (Pose.CFrame):

local axis,angle = jointCF:ToAxisAngle()
mirrorJointCF = CFrame.fromAxisAngle(axis*Vector3.new(-1,1,1),-angle) + (jointCF.p * Vector3.new(-1,1,1))

In other words, convert to axis-angle, reflect across the YZ plane by negating the X component of the axis, mirroring the rotation by negating the angle, and then also mirroring the X component of translation. Fair warning, I don’t have time to go and test this, and it’s not a general purpose solution (because it’s using joint local space), but I think it’s correct for the special case of a Roblox avatar because all the animation transforms are identity in the rest pose. Also, I didn’t test it :grimacing:

4 Likes

Holy moly I can’t believed that worked! This is perfect.

I appreciate that you took the time to type this out and explain it. Thanks you!

1 Like