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

Euler filter for XformCommonAPI #410

Open
AlexSchwank opened this issue Feb 9, 2018 · 6 comments
Open

Euler filter for XformCommonAPI #410

AlexSchwank opened this issue Feb 9, 2018 · 6 comments

Comments

@AlexSchwank
Copy link
Contributor

Description of Issue

When using more advanced xform ops, getting rotation values via the XformCommonAPI can lead to Euler flips.

eulerTest.usda zip

//...
float3 xformOp:rotateXYZ.timeSamples = {
    0: (0, 80, 0),
    1: (0, 90, 0),
    2: (0, 100, 0),
}
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:rotatePivotOffset", "xformOp:translate:rotatePivot", "xformOp:rotateXYZ:rotateOffset", "xformOp:rotateXYZ", "!invert!xformOp:translate:rotatePivot", "xformOp:translate:scalePivotOffset", "xformOp:translate:scalePivot", "xformOp:transform:shear", "xformOp:scale:scaleOffset", "xformOp:scale", "!invert!xformOp:translate:scalePivot"]
//...

XformCommonAPI::GetXformVectors() result

0: (0, 80, 0)
1: (0, 90, -0)
2: (180, 80, 180)

For now, we can fix the rotation for example with Mayas MEulerRotation::setToClosestSolution() but Usd itself should include a

feature for Euler filters.

Thanks,
Alex

Steps to Reproduce

>>> from pxr import Usd, UsdGeom
>>> stage = Usd.Stage.Open("/path/to/eulerTest.usda")
>>> prim = stage.GetPrimAtPath("/myXform")
>>> xformAPI = UsdGeom.XformCommonAPI(prim)
>>> xformAPI.GetXformVectors(0)
(Gf.Vec3d(0.0, 0.0, 0.0), Gf.Vec3f(0.0, 80.0, 0.0), Gf.Vec3f(1.0, 1.0, 1.0), Gf.Vec3f(0.0, 0.0, 0.0), UsdGeom.XformCommonAPI.RotationOrderXYZ)
>>> xformAPI.GetXformVectors(1)
(Gf.Vec3d(0.0, 1.0, 0.0), Gf.Vec3f(0.0, 90.0, -0.0), Gf.Vec3f(1.0, 1.100000023841858, 1.0), Gf.Vec3f(0.0, 0.0, 0.0), UsdGeom.XformCommonAPI.RotationOrderXYZ)
>>> xformAPI.GetXformVectors(2)
(Gf.Vec3d(0.0, 2.0, 0.0), Gf.Vec3f(180.0, 80.0, 180.0), Gf.Vec3f(1.0, 1.2000000476837158, 1.0), Gf.Vec3f(0.0, 0.0, 0.0), UsdGeom.XformCommonAPI.RotationOrderXYZ)

Package Versions

Tested in 0.8.2 & 0.8.3

@jtran56
Copy link

jtran56 commented Feb 9, 2018

Filed as internal issue #157012.

@chadrik
Copy link
Contributor

chadrik commented Feb 10, 2018

Hi @AlexSchwank, @elrond79 made a PR that adds euler filtering to Maya exports but I think it could be very interesting to see this at a higher level in USD.

@AlexSchwank
Copy link
Contributor Author

Thanks @chadrik , I'm not too concerned about exports at the moment. Importing is a bigger issue for us so I'll fix it in a similar way for now. That said, you're right, this issue is meant to track/discuss general solutions to fix Euler flips at a higher level in USD.

@pmolodo
Copy link
Contributor

pmolodo commented Apr 10, 2018

So, it looks like the problem here is that the input rotation doesn't conform the "common xform" stack - the xform stack you give is maya's:

["xformOp:translate", "xformOp:translate:rotatePivotOffset", "xformOp:translate:rotatePivot", "xformOp:rotateXYZ:rotateOffset", "xformOp:rotateXYZ", "!invert!xformOp:translate:rotatePivot", "xformOp:translate:scalePivotOffset", "xformOp:translate:scalePivot", "xformOp:transform:shear", "xformOp:scale:scaleOffset", "xformOp:scale", "!invert!xformOp:translate:scalePivot"]

...while the (fairly simple) common xform only supports stacks with these elements:

["xformOp:translate", "xformOp:translate:pivot", "xformOp:rotateXYZ", "xformOp:scale", "!invert!xformOp:translate:pivot"]

(or other appropriate 1 or 3-axis rotate in place of rotateXYZ).

So the reason why the flip happens in your code snippet is that, since it's not compatible with it's xform stack, it converts to matrix, then decomposes the matrix.

@pmolodo
Copy link
Contributor

pmolodo commented Apr 10, 2018

Having said that... noticed you link to a PR that's dealing specifically with maya imports... maya should be able to understand it's own xform stack, and import your test correctly. So something wrong is definitely going on there...

@pmolodo
Copy link
Contributor

pmolodo commented Apr 10, 2018

Well, left full details in a comment for the PR, but figured out what was going on... the input xform stack is not actually a maya stack, as I first assumed it was.
I still agree that there's a need for a euler filtering option, though, specifically to deal with situations where xform stacks can't be directly translated...

AdamFelt pushed a commit to autodesk-forks/USD that referenced this issue Apr 16, 2024
…lve/adsk/feature/android-dev

USD build for Android
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

4 participants