-
Notifications
You must be signed in to change notification settings - Fork 0
Coordinate Systems
There are both 3D and 2D coordinate systems used in FUEL for different purposes. These systems differ from the ones used by popular tools and libraries so care must be taken to convert between the systems. Additional considerations must be made when making an importer/exporter for FUEL's object formats based on this information.
3D coordinate systems are used to represent translations, rotations, and scales in 3-dimensional space. This is most useful for storing information about nodes, meshes, and animations among other things.
There are several coordinate systems that are necessary to be aware of when modding FUEL.
+X
goes right, +Y
goes up, and +Z
comes out of the screen. Right-handed. Clockwise.
+X
goes right, +Y
goes up, and +Z
goes into the screen. Left-handed. Clockwise.
+X
goes right, +Y
goes into the screen, and +Z
goes up. Right-handed. Counter-clockwise.
A concept closely related to 3D coordinate systems in meshes is the idea of a "winding order." The winding order of a system defines which side of a face is considered the front. This information can be used to perform "back-face culling," an optimization in which faces that are not facing the camera are not rendered. Furthermore, when converting from a right-handed to a left-handed system, or in the opposite direction, the winding order must be reversed too if the handedness conversion is done by some transformation other than negating the z
component; although, no winding order is tied to a particular handedness.
To convert from Blender's coordinate system to FUEL's coordinate system one must rotate the mesh -90
degrees about the X-axis such that +Y
after the rotation points in the direction of +Z
before the rotation and +Z
after the rotation points in the direction of -Y
before the rotation. It is important to note that the Z component does not need to be negated after this rotation since in FUEL's coordinate system +Z
points out of the screen instead of into it. Furthermore, it is not sufficient to simply swap the Y and Z components since this will convert the coordinate system from right-handed to left-handed and meshes will appear mirrored about the yz
-plane, this solution would, however, counteract the difference in winding order between Blender and FUEL, requiring no change to index order. Since the winding order is reversed between Blender and FUEL, the order of indices per face must be reversed when converting between these systems without also converting the handedness.
The simplest solution to the difference between Blender's Z-up world and FUEL's Y-up world is to create your meshes sideways in Blender as if Y were up. If you intend to convert between these coordinate systems in an import/export script you must take care to do the conversion in all places. These include but are not limited to vertex positions, normals, tangents, quaternions, and transformation matrices.
A more complete solution would be to rotate the mesh -90 degrees about the X-axis before exporting such that when FUEL loads the mesh and applies the +90 degree rotation it is as if the mesh is as it appeared in Blender.
For some reason, the x
and z
components of normals and tangents need to be swapped when importing/exporting. Also, there is a w
component to tangents and normals that appears to be unused in mesh shaders but other shaders use this component to represent a [-1, 1]
scale to be applied to the other 3 components, handedness
, or occlusion
as the variables are named in the shader.
Also, Blender allows transformations to meshes that are not applied to the mesh vertices directly. These transformations must be taken into account when exporting and applied to the exported vertices, otherwise, the mesh will not appear the same in FUEL as it does in Blender. Additionally, vertex positions, normals, and tangents do not receive the same transformation. This can be done manually before exporting by using the Apply menu to apply the transformation directly to the mesh vertices.
To convert from FUEL's coordinate system to Direct39 9's coordinate system one must negate the Z component since +Z
goes into the screen in Direct3D 9's coordinate system and out of the screen in FUEL's. The game handles this conversion automatically using the projection matrix. Although this changes the handedness, no conversion is necessary for the index order since negating the z
component doesn't affect the winding order in Direct3D 9.
Internally 3D points are stored with the components in the following order.
struct Vec3f {
float x;
float y;
float z;
};
Rather confusingly, some in-game development menus will swap the names of the y
and z
components when displaying the player's location portraying the illusion that FUEL is a Z-up world.
2D coordinate systems are used to represent UV/texture coordinates in various tools and libraries.
FUEL and Direct3D 9 share the same texture coordinate system.
Direct3D 9 Texture Coordinate System
(0, 0) top left, (1, 1) bottom right, and (.5, .5) at the center.
(0, 0)-----(1, 0)
| |
| (.5, .5) |
| |
(0, 1)-----(1, 1)
Blender Texture Coordinate System
(0, 0) bottom left, (1, 1) top right, and (.5, .5) at the center.
(0, 1)-----(1, 1)
| |
| (.5, .5) |
| |
(0, 0)-----(1, 0)
Since the coordinate systems are flipped about the x
-axis relative to each other, they can be easily converted back and forth by subtracting the y
component from 1
while keeping the x
component fixed (x, 1 - y)
.
For FMTK Users and Mod Developers
For FMTK Developers
Asobo BigFile Format Specification
Asobo Classes
Animation_Z
Binary_Z
Bitmap_Z
Camera_Z
CollisionVol_Z
Fonts_Z
GameObj_Z
GenWorld_Z
GwRoad_Z
Keyframer*_Z
Light_Z
LightData_Z
Lod_Z
LodData_Z
Material_Z
MaterialAnim_Z
MaterialObj_Z
Mesh_Z
MeshData_Z
Node_Z
Omni_Z
Particles_Z
ParticlesData_Z
RotShape_Z
RotShapeData_Z
Rtc_Z
Skel_Z
Skin_Z
Sound_Z
Spline_Z
SplineGraph_Z
Surface_Z
SurfaceDatas_Z
UserDefine_Z
Warp_Z
World_Z
WorldRef_Z
Asobo File Format Idioms
Asobo CRC32
Asobo LZ Compression
Asobo Arithmetic Coding Compression
Asobo Save Game File Format Specification
Asobo Audio Formats
TotemTech/ToonTech/Zouna/ACE/BSSTech/Opal Timeline
Zouna Modding Resources
Miscellaneous