I am working on an FBX animation importer, and the rotation values stored in the files treat Z as the vertical axis and Y as the depth axis, instead of the other way around like it is on Roblox. These rotations are in local space (relative to the parent node) rather than global rotation. If I import the rotations as-is, I get malformed results because the Y/Z axes are flipped:
Original:
How can I convert this to proper Roblox rotation? I have access to both the rx,ry,rz rotation values (in wrong axes) and the CFrame matrix (in wrong axes), and can do the rotation in either Roblox after the KeyframeSequence has already been generated or before generating it in Python. I would prefer before so the KeyframeSequence is usable as-is. This is not a Blender plugin, so I don’t have access to libraries like bpy or mathutils.
Resources:
FBX File: RPG-Character@Unarmed-Attack-Kick-L1.FBX (481.0 KB)
Generated KeyframeSequence with wrong axes of rotation: KeyframeSequence.rbxmx (1.5 MB)
Code to visualize KeyframeSequence:
local kfs = ...
local kf = kfs.Keyframe_0
function scaleCFrame(cf, factor)
return cf - cf.p + cf.p*factor
end
function displayPose(pose, parentNode)
local baseCFrame = parentNode and parentNode.CFrame or CFrame.new()
local part = Instance.new("Part")
part.CFrame = baseCFrame * pose.CFrame
part.Name = pose.Name
part.Size = Vector3.new(1,1,1)
part.Transparency = 1
part.Anchored = true
part.CanCollide = false
part.Parent = workspace
Instance.new("Attachment", part)
local sphere = Instance.new("SphereHandleAdornment")
sphere.Radius = 0.5
sphere.Color3 = Color3.new(0.1,0.25,0.75)
sphere.Adornee = part
sphere.Parent = part
if parentNode then
local beam = Instance.new("Beam")
beam.Attachment0 = part.Attachment
beam.Attachment1 = parentNode.Attachment
beam.Parent = part
beam.CurveSize0 = 1
beam.CurveSize1 = 1
beam.FaceCamera = true
end
for _,v in pairs(pose:GetChildren()) do
displayPose(v, part)
end
end
for _,v in pairs(kf:GetChildren()) do
displayPose(v)
end