Houdini rotation to UE4 rotation?

   10260   10   5
User Avatar
Member
13 posts
Joined: 2月 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,
User Avatar
スタッフ
534 posts
Joined: 9月 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
User Avatar
Member
13 posts
Joined: 2月 2006
Offline
Marvelous. That's insanely helpful. Thanks!
User Avatar
Member
11 posts
Joined: 9月 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!

Attachments:
vexCode.PNG (47.5 KB)
consoleOutput.PNG (9.4 KB)

User Avatar
Member
44 posts
Joined: 5月 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.
Edited by frostfx - 2020年2月14日 08:40:56

Attachments:
vop.jpg (58.4 KB)

User Avatar
スタッフ
534 posts
Joined: 9月 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.
User Avatar
Member
11 posts
Joined: 9月 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

Attachments:
vexCode.PNG (52.9 KB)
consoleOutput.PNG (9.5 KB)

User Avatar
スタッフ
534 posts
Joined: 9月 2016
Offline
Posting back what I replied to you on Discord:

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 - 2020年2月14日 11:35:15
User Avatar
Member
11 posts
Joined: 9月 2018
Offline
Hi dpernuit,

Apologies I'd been looking at it for far too long, that works perfectly now thank you for your help / patience
User Avatar
Member
1 posts
Joined: 4月 2019
Offline
Hi guys, I just t tried this and didn't work. I believe is just the same example. I cannot find what I'm missing.

Attachments:
ShareX_7LYamj5uyL.png (510.2 KB)
Houdini_to_Unreal_rotation.hiplc (272.1 KB)

User Avatar
Member
143 posts
Joined: 1月 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)
  • Quick Links