Forward Vector In Cesium for Unreal Environment

Hello everyone.
I am trying to do a thing with a point that is forward of the pawn while using Cesium for Unreal.
Normally one would get the forward vector of the actor in question, multiply that by an amount one wishes to deal with in the forward direction then add it to the current position of the actor to access the point in space that is N units in front of the actor.
However, in Cesium, forward isn’t the same thing as in Unreal coordinates. Its 90 degrees off. That’s ok.

My question is, is there a way to get a cesium forward vector or do we just get the forward vector, rotate it by 90 degrees then multiply that by N. Add the result to the current position then translate all of that from Unreal to Cesium coordinates?

Hi @BDelacroix,

I’m not sure I follow what do you mean when you say “in Cesium”. Cesium geolocates objects in globe-relative coordinates, but ultimately converts them into Unreal coordinates. When you say “forward” in Cesium, it’s a big confusing because we do position and rotate things relative to Unreal.

My initial guess is that “forward” seems different because you’re not directly on top of the CesiumGeoreference origin. When a pawn goes across the globe, it has to automatically adjust its orientation to compensate for the changing globe surface. So that may be part of the issue.

It would help if you can provide a screenshot / diagram of the pawn’s forward vector, versus the forward vector that you want the pawn to go in. I believe there’s a “Draw Debug Arrow” Blueprint you can use to visualize the direction. Thanks!

Sorry I guess I am doing it all wrong then.
I have to turn all of my models by -90 degrees for them to face north with a 0 degree yaw.

What I was running into, and very near the chosen ellipsoid center, was grabbing the forward vector then multiplying by the distance I want then adding that to the current location. It was always going to the right.

Given I have had to learn unreal and cesium all in less than six months, it would not be surprising that I am doing it all wrong.

Hi @BDelacroix,

I think there’s a misunderstanding; you’re not “doing it all wrong”. There’s a clear misalignment that is happening, and I’d like to diagnose it so we’re on the same page. My initial reply was to clarify how the plugin works, not to dismiss your issue. :slightly_smiling_face:

Can you share the Blueprint / code you using so we can replicate what you’re seeing? It would also help to know what Cesium3DTilesets you have in your scene, and where your CesiumGeoreference is located. Then we can give a more accurate solution.

Oh no. I didn’t take it that way at all.

I only get to work on this on Wednesday through Friday each week so I’ll try to remember to do so.

As to the tile set. If I am understanding I would say its the Bing tile set. The GeoReference I set at a location in Florida, I’d have to go look for the exact numbers.

Perhaps if I explain the general approach:

This project just represents objects in the world, mostly airplanes, given positions and telemetry from an external simulator. In order to do that, I stuff the wgs position into the world anchor of the pawn and the attitude (roll, pitch, yaw) to the pawn. I think I saw that world anchor had roll pitch yaw as well at the end of Thursday and it may be that I need to be stuffing those telemetry values to that world anchor component instead of directly to the rotation matrix of the pawn.

Because I pseudo promised I’d do this:
This is the bit of blueprint that I was using to test with forward vector. In this case I was moving a pawn forward 500 units.

As to the ellipsoid center it is not far from where this test pawn is at on the editor but it is:

Lat: 30.038526
Lon: -85.525716
H: 3.000000
Scale is default (100)

Tinkered briefly with the pitch,roll,yaw in the world anchor component of the actor and almost convinced that I was “doing it wrong” and I should be setting the incoming pitch, roll and yaw through the anchor and not directly to the pawn. Will have to explore that more to be sure.

Hey @BDelacroix, sorry for the delay! I have been out of office since last week. :pensive:

Thanks for including the screenshot of your Blueprint. Admittedly, I’m playing catchup right now, but I will dedicate some time to check the math and get back to you with an informed answer. Thank you for your patience :pray:

I got around it by just rotating by 90 degrees.
Further digging I see that the aircraft model is 90 degrees off, but apparently because the bones and animation settings are set with +Y as forward.
I don’t know enough to start messing around with animations to set it all right so I’ve put this problem off for some other time.

I believe that if I could rotate the animations with +X as forward I could just use +X forward as normal and all would be well.

My first try at exporting, rotating and importing the model ended up with plane parts all over the place at all wrong rotation angles. So, I put it all back.

So for now, I’m just living with using a 90 degree rotation from directional vectors, but if you see something obvious it would be appreciated.

Hi @BDelacroix,

Unreal Engine uses a left-handed coordinate system where +X is forward, +Y is right, and +Z is up. So for your model, you would have to convert between the model coordinate system and Unreal’s, which is especially important if your model uses a right-handed coordinate system.

A counter-clockwise 90 degree rotation around the Z axis does make +Y forward, but now the right vector points in the -X direction. My 3D math is rusty, but there may be additional steps you have to do depending on the model’s true coordinate system, and that may be impacting how it is treating the “forward” vector.

So my current suggestion is to double-check that this misalignment (between Unreal and your model) is resolved correctly. Let me know how that goes and we can further troubleshoot from there. :smile:

I am in agreement. At this point I believe it would be a matter of just turning the model in blender or whatever and reimporting. I tried that but now the problem is the animations are all wrong so this is an issue I’ll have to leave until I or someone else learns how to manipulate the animations.

Thanks for your help.

I have managed to turn the models such that the actor axis is correct now. I can’t explain exactly how. Internal to the actor the models are still Y forward but that doesn’t matter so much as the overall actor treats the +X for forward. This will let the flight vector on the hud work as well as other things.

Thanks for your patience. Now it is on me to figure out exactly how I stumbled into getting the alignments right so that others don’t have to struggle.

1 Like