Axis rotation #128
Replies: 2 comments 4 replies
-
I have a fairly long discussion over on the VertexDezign Discord about this exact topic. You do seem to already have some understanding of why, but I will give the whole explanation just for clarity. As well as tell you that what you seek is actually already implemented 😉 Coordinate Systems: Blender vs Giants EngineGame engines and 3D-software all have some sort of base coordinate system defined which defines what direction is up/down, left/right and forward/backwards. But they don't necessarily agree on which of the axes X, Y & Z is what. To tell what kind of system a program uses it is normally defined as what axis is Up, combined with the handedness of the coordinate system (I believe the word stems from math/physics, where you can use your left or right hand to find out what kind of coordinate system you are dealing with) The following chart shows a few programs and the definition of their coordinate system. It can be seen that Blender falls into the camp of having a (Z-Up, right handed) coordinate system, which means that our models look like the following, when seen from a "Front Right" perspective (At least this is what I believe Blender categorises it as) Which of course makes sense, since I just modelled coloured arrows that correspond to their respective axis in Blender. Now GE on the other hand, falls into the same category as Maya in that previous chart. So it's world is defined as having (Y-Up, right handed), which is slightly different from Blenders. As you have noted it more or less corresponds to a 90° rotation around the X-axis (Due to sharing the X-axis by both being right handed) If I maintain the same camera view, so we look at the world from the same perspective regardless of whether we are in Blender or GE. And I export the arrows with exactly the same coordinates as they have in Blender, then it looks like this in GE: If we were to look at the arrows transforms, then they would have exactly the same coordinates in Blender and GE at this point. But since GE is essentially rotated 90° around X, we can see that from the cameras perspective the arrows have been rotated as well. If we stick with the convention that the X-axis represents Right and we know that Y is Up, then the blue arrow which was pointing Up in Blender is now pointing in the direction of Backward What the exporter doesTo get rid of this inconsistency, the exporter transforms your objects coordinate basis in a way so that if something was pointing Up in Blender, it will also be pointing Up when it gets into GE. That will look like this: As you can see, from the perspective of the camera (which has the same view as the corresponding camera in Blender), the arrows are pointing in the exact same direction, but if we were to inspect the actual positions of the individual vertices it could be seen that they have changed their position. So why does the exporter do this?No matter what you do, Blender and GE does not agree on the coordinate system. So at some point you are forced to make a choice. Do you want to keep the coordinates of the vertices 1:1 or do you want to keep the "view" 1:1 between the two programs. When I started work on this, I decided to keep the view 1:1. So Up in Blender is going to be your Up when it gets into GE. The reason for doing this is that Blender isn't really geared for handling another coordinate system. In Maya e.g. you can change your coordinate base and model 1:1 between Maya and GE. But in Blender it is hardcoded and thus all the views, UI grid and so on is geared for this Z-Up world. And as I imagined spending most of my time in Blender, this is how I chose to design it. The downsideSince this process changes the coordinate basis of your mesh and objects, this means that if you have positioned something to specifically follow a certain axis, then this will also be transformed. In the case of e.g. a lot of the empties (transformgroups) that you need for vehicles, they are used for things that rely on the orientation of the axis of the empty. This WILL break upon export, if great care isn't taken to consider their conversion, when you place them in Blender. The following table might be of some help:
So for example if you want your empty to point it's Z-axis in the direction of Z, when it gets into GE. You should point the Z-axis in the direction of the Global Y in Blender. What if I don't like this conversion?You are in luck 😉 I thought of this when I originally implemented the conversion and I actually give you the option of converting your i3d into ANY coordinate system you desire. These two options in the exporter panel gives you full control over the coordinate system transformation. They default to (-Z Forward, Y-up) which is the conversion that gives you this 1:1 view between Blender and GE. If you don't want this, you can change them to (Y Forward, Z Up) which tells the exporter to keep the coordinate system as it is. This does maintain your axis orientations, but beware that it makes things a bit more annoying to work with in Blender 😉 Future considerationAs a little ending remark I can share the thoughts that I have had about this and the solution I like the most, which is to do a sort of "best of both worlds" approach, where you get the option of toggling this on a per object basis. So that you could have your models following the "view", since axis orientation mostly doesn't matter for visuals. And then you could turn of the conversion for your empties, so that you can position them correctly directly in Blender, without having to keep tracking of axes conversions. I am open to any other suggestions though, if someone has a better way to do things. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Problem: When you export from Blender and import to GE, the origin's X axis is rotated 90 degrees (essentially). Since so many things are axis dependent, this can be annoying and confusing. You first have to set up the axis in Blender with how you want it to appear in-game, and then, with "Affect only Origins" enabled, do R X -90 so that it looks wrong in Blender, but turns up in GE how you want it.
Solution: Option to rotate the axis/origin on export, so that the axis looks the same in Blender and GE
Beta Was this translation helpful? Give feedback.
All reactions