Houdini rotation to UE4 rotation?
11838 10 5- brettmillervfx
- Member
- 13 posts
- Joined: Feb. 2006
- Offline
Anybody know the math to get a houdini euler rotation to a UE4 rotation? I know the HouEngine does this for you but we're experimenting with a JSON based workflow and it doesn't appear that I can feed UE4 a 3x3 matrix so I need to work out how it likes it's euler rotation..
I figure the engine source code has the transform in there somewhere but thought I'd ask first…
thanks,
I figure the engine source code has the transform in there somewhere but thought I'd ask first…
thanks,
- dpernuit
- Staff
- 553 posts
- Joined: Sept. 2016
- Offline
Hi,
Indeed you can find the code to convert transform between UE4 and H in the plugin's source.
HoudiniEngineUtils has functions like FHoudiniEngineUtils::TranslateHapiTransform() that does this.
https://github.com/sideeffects/HoudiniEngineForUnreal/blob/Houdini17.5-Unreal4.22/Source/HoudiniEngineRuntime/Private/HoudiniEngineUtils.cpp#L463-L475 [github.com]
But roughly, to convert from Houdini to unreal:
Rotation (Quaternion): Swap Z and Y, invert W
UE4.X = H.X
UE4.Y = H.Z
UE.Z = H.Y
UE4.W = -H.W
Position: Swap Z and Y, convert from meter to centimeters
UE4.X = H.X * 100
UE4.Y = H.Z * 100
UE.Z = H.Y *100
Scale: Swap Z and Y
UE4.X = H.X
UE4.Y = H.Z
UE.Z = H.Y
Indeed you can find the code to convert transform between UE4 and H in the plugin's source.
HoudiniEngineUtils has functions like FHoudiniEngineUtils::TranslateHapiTransform() that does this.
https://github.com/sideeffects/HoudiniEngineForUnreal/blob/Houdini17.5-Unreal4.22/Source/HoudiniEngineRuntime/Private/HoudiniEngineUtils.cpp#L463-L475 [github.com]
But roughly, to convert from Houdini to unreal:
Rotation (Quaternion): Swap Z and Y, invert W
UE4.X = H.X
UE4.Y = H.Z
UE.Z = H.Y
UE4.W = -H.W
Position: Swap Z and Y, convert from meter to centimeters
UE4.X = H.X * 100
UE4.Y = H.Z * 100
UE.Z = H.Y *100
Scale: Swap Z and Y
UE4.X = H.X
UE4.Y = H.Z
UE.Z = H.Y
- brettmillervfx
- Member
- 13 posts
- Joined: Feb. 2006
- Offline
- DominicSewell
- Member
- 11 posts
- Joined: Sept. 2018
- Offline
dpernuit
Hi,
Indeed you can find the code to convert transform between UE4 and H in the plugin's source.
HoudiniEngineUtils has functions like FHoudiniEngineUtils::TranslateHapiTransform() that does this.
https://github.com/sideeffects/HoudiniEngineForUnreal/blob/Houdini17.5-Unreal4.22/Source/HoudiniEngineRuntime/Private/HoudiniEngineUtils.cpp#L463-L475 [github.com]
But roughly, to convert from Houdini to unreal:
Rotation (Quaternion): Swap Z and Y, invert W
UE4.X = H.X
UE4.Y = H.Z
UE.Z = H.Y
UE4.W = -H.W
Position: Swap Z and Y, convert from meter to centimeters
UE4.X = H.X * 100
UE4.Y = H.Z * 100
UE.Z = H.Y *100
Scale: Swap Z and Y
UE4.X = H.X
UE4.Y = H.Z
UE.Z = H.Y
Hi @dpernuit , I'm trying to convert my rotation values through vex but don't seem to be getting correct results that match my original ue4 input rotations. are you able to point me in the right direction?
Vex code Snippet :
Output Values :
Cheers!
- frostfx
- Member
- 44 posts
- Joined: May 2017
- Offline
im trying to do a similar thing. Tried your values in vops.
im getting similar results. But i guess the euler to quat input needs to be in radians. So i tried the conversion in between but not getting the results to match up in unreal.
so would be also really interested to convert houdini rotations to unreal rotations. thanks.
im getting similar results. But i guess the euler to quat input needs to be in radians. So i tried the conversion in between but not getting the results to match up in unreal.
so would be also really interested to convert houdini rotations to unreal rotations. thanks.
Edited by frostfx - Feb. 14, 2020 08:40:56
- dpernuit
- Staff
- 553 posts
- Joined: Sept. 2016
- Offline
As frostfx mentioned, angles for the quaternions need to be expressed in radians, not degrees…
Even when doing the math right, you may not end up with the exact same rotation values as then one you see in UE4, but the rotation itself will be equivalent…
For example, (50,-100,90) and (-130,-80,-90) have different values but are the same rotation.
Even when doing the math right, you may not end up with the exact same rotation values as then one you see in UE4, but the rotation itself will be equivalent…
For example, (50,-100,90) and (-130,-80,-90) have different values but are the same rotation.
- DominicSewell
- Member
- 11 posts
- Joined: Sept. 2018
- Offline
Hi @dpernuit ive converted my initial values to radians but i still dont seem to be getting correct values? Using the unreal rotation of X 50 Y -100 Z 90 my calculation returns X -260 Y 50 Z -90 which as far as i can tell is not a different version of the same rotation. There seems to still be something im doing wrong along the way?
Im ultimately just trying to get the Y axis rotation that has occurred in unreal so i can translate this to a rotation in the UVs
Im ultimately just trying to get the Y axis rotation that has occurred in unreal so i can translate this to a rotation in the UVs
- dpernuit
- Staff
- 553 posts
- Joined: Sept. 2016
- Offline
Posting back what I replied to you on Discord:
Looking at your code, your forgot to negate the last component of the UE Quaternion. Try with:
HQuat (X,Y,Z,W) = UEQuat( -X, -Z, -Y, W)
and the other way around is
UEQuat (X,Y,Z,W) = HQuat (X, Z, Y, -W)
Looking at your code, your forgot to negate the last component of the UE Quaternion. Try with:
vector4 unrealQuaternion = set(houdiniQuaternion[0], houdiniQuaternion[2], houdiniQuaternion[1], -houdiniQuaternion[3]);
Edited by dpernuit - Feb. 14, 2020 11:35:15
- DominicSewell
- Member
- 11 posts
- Joined: Sept. 2018
- Offline
- dmdrn
- Member
- 1 posts
- Joined: April 2019
- Offline
- ikoon
- Member
- 211 posts
- Joined: Jan. 2016
- Offline
Thank you very much @dpernuit
I wanted to match the rotation of Houdini camera (exported from Houdini to USD and imported with USD Stage Unreal plugin). I managed to get it working, but I had to shuffle the quaternion different way.
I inverted y coordinate in quaternion instead of w:
hou.Quaternion(x, z, -y, w)
In UE, there should be left handed coordinate system, but rotating around X and Y axes in UE follows the right hand rule. Can someone please shed some light on this?
(btw I also had to pre-rotate the Houdini camera with hou.hmath.buildRotateAboutAxis(world_cam_UP_vector, 90) so that it looks the same direction as UE cam)
I wanted to match the rotation of Houdini camera (exported from Houdini to USD and imported with USD Stage Unreal plugin). I managed to get it working, but I had to shuffle the quaternion different way.
I inverted y coordinate in quaternion instead of w:
hou.Quaternion(x, z, -y, w)
In UE, there should be left handed coordinate system, but rotating around X and Y axes in UE follows the right hand rule. Can someone please shed some light on this?
(btw I also had to pre-rotate the Houdini camera with hou.hmath.buildRotateAboutAxis(world_cam_UP_vector, 90) so that it looks the same direction as UE cam)
-
- Quick Links