🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

3D-app Euler-Rotations to UE4 Euler-Rotations

Started by
29 comments, last by ManitouVR 4 years, 11 months ago

Hello,

I dont really know how to ask the correct questions since i dont know the necessary steps that it takes to convert the given Euler angles from my 3D software to the needed Euler angles in Unreal Engine 4.

I made a plugin for UE4 to spawn instances of Static Mesh Actors into the UE4 level based on a text file which holds the Scale/Rotate/Transform information from the objects in my 3D software scene.

Basically the plugin mirrors the 3D apps objects into UE4.

Everything works but NOT the rotations.

So my question is:

Euler->??->Euler

Thanks!

 

 

3D Artist

Advertisement

I imagine someone's already solved this problem, so maybe someone can offer an off-the-shelf solution. Meanwhile though, I'll ask a couple questions.

Do you know what the Euler-angle order conventions are for the two tools (the modeling program and UE)? By order convention, I mean XYZ, XZY, YXZ, etc.

I assume if you import your models with no modifications, they're 'lying on their side' in UE, and are mirrored along an axis, with winding order reversed (which may or may not matter). Is that accurate? If so, have you already corrected for any of that (e.g. mirroring or winding order)?

Again, I'm guessing this particular conversion has been addressed somewhere - maybe someone else will jump in with a specific answer.

@Zakwayda

Hello and thanks for your answer.

My 3D software uses XYZ rotation order and Unreal Engine 4 uses XZY rotation order (As far as i could find out so far.)

When i import a 3D model into UE4 then i just set the scaling to 100. Everything else gets corrected already on Import.

Import_Options.png

Import_Correction_off.png

3D Artist

I'm just winging it here, and this could be totally wrong, but maybe try this:


UE X = -(Softimage X)
UE Z = -(Softimage Y)
UE Y = -(Softimage Z)

For clarity, e.g. 'UE X = -(Softimage X)' means 'for the X Euler-angle value for UE, use the negative of the X Euler-angle value for Softimage'.

You probably already know this, but to test this thoroughly (more or less) you'd want to try a number of arbitrary orientations and make sure the results come out as expected (because with simple orientations you might get some matches 'by accident' even if the conversion is incorrect).

Hello, thanks for trying to help me. Much appreciated.

I indeed tryd to negate the rotation angles. In all possible combinations. But it seems to just make the values positive or negative.

I honestly think that it is a Matrix problem of some kind.

Here is the function that gets fed with the 3D-app( Softimage XSI) data.


 


void SpawnSMActor(const TCHAR *path,float sX,float sY,float sZ,float rX,float rY,float rZ,float pX,float pY,float pZ)
{
    // Load Static Mesh from given Reference Path from UE4 Explorer
    UStaticMesh* StaMesh = LoadObject<UStaticMesh>(nullptr, path);

    // Transform
    FVector objectScale(sX, sY, sZ);        // Scale

    // ************************************************************************************
    // Conversion XSI Coordinate System to UE4 Coordinate System

    FVector NewPosition;
    FRotator NewRotation;

    // We just simply swap the Z and Y Coordinates

    NewPosition.X = pX * 100; //    TX
    NewPosition.Y = pZ * 100; //    TZ
    NewPosition.Z = pY * 100; //    TY

    // We just simply swap the Pitch(Y) and Yaw(Z) angles

    NewRotation.Roll =  rX;     //    RX
    NewRotation.Pitch = -rZ;    //    RZ
    NewRotation.Yaw =   rY;     //    RY

    FRotator NewobjectRotation(NewRotation.Quaternion());

    FTransform objectTransform(NewobjectRotation, NewPosition, objectScale);

    // ************************************************************************************

    // Creating the Actor and Positioning it in the World based on the Static Mesh
    UWorld* currentWorld = GEditor->GetEditorWorldContext().World();
    ULevel* currentLevel = currentWorld->GetCurrentLevel();
    UClass* StaticMeshClass = AStaticMeshActor::StaticClass();
    AActor* NewActorCreated = GEditor->AddActor(currentLevel, StaticMeshClass, objectTransform, true, RF_Public | RF_Standalone | RF_Transactional);
    AStaticMeshActor* smActor = Cast<AStaticMeshActor>(NewActorCreated);

    smActor->GetStaticMeshComponent()->SetStaticMesh(StaMesh);
    smActor->SetActorScale3D(objectScale);

    // ID Name & Visible Name
    //smActor->Rename(TEXT("MyStaticMeshInTheWorld"));
    //smActor->SetActorLabel("MyStaticMeshInTheWorld");

    GEditor->EditorUpdateComponents();
    smActor->GetStaticMeshComponent()->RegisterComponentWithWorld(currentWorld);
    currentWorld->UpdateWorldComponents(true, false);
    smActor->RerunConstructionScripts();
    GLevelEditorModeTools().MapChangeNotify();
}

 

3D Artist

I looked around online a bit, but couldn't find an authoritative source as to what Euler-angle convention(s) UE uses. I found this thread on the UE forums:

https://forums.unrealengine.com/development-discussion/c-gameplay-programming/5398-euler-rotations-and-matrix-questions

Which seems to suggest maybe the convention is nonintuitive and/or nonstandard.

Earlier you said:

"...Unreal Engine 4 uses XZY rotation order (As far as i could find out so far.)"

Do you have a source for that? If so, can you post a link?

In any case, if UE's Euler-angle convention is different from what you're expecting, that may explain why your conversion isn't working.

Also, can you export the rotations/orientations from Softimage in another format, such as axis-angle or quaternion?

Hello, thanks for this link!

That gives some interesting insights.

I have tested the rotation order in Softimage, only possible in Local Space.

But that does not matter since in my test scene the object lies anyway in global space. So local and global is the same.

So if i switch the order from XYZ to XZW then i get the "same" values like in UE4.

Here is a new video to proof my point:

 

Also here is a link that i have found that says (scroll down to the bottom, last post) Maya to UE4 --> XZY.

Maya has the same coordinate system as XSI:

XSI        (Right Handed , Y axis up )
Maya    (Right Handed , Y axis up )

https://answers.unrealengine.com/questions/62077/what-is-the-rotation-order-for-components-or-bones.html

Quaternions are for game engines mostly. Every3D software that i know stores animations in Euler angles and so does XSI.

 

3D Artist

Also, are you sure the spaces of Softimage and UE are equal? (That is their axises are aligned as to direction of positive and negative and conveniently directed)

@JohnnyCode

UE4       (Left Handed    , Z axis up )      
XSI        (Right Handed , Y axis up )
Maya    (Right Handed , Y axis up )

3D Artist

You will need alignment transformation, not sure that fitting UE4 will be an affine transformation though- if handedness will not sit in tact after you rotate Y to Z. You may need inverse scale by handedness axis then, applied as last in the transformation.

This topic is closed to new replies.

Advertisement