-
Notifications
You must be signed in to change notification settings - Fork 4
Field File Section 2: Camera Matrix
The Camera Matrix section defines the camera matrix. For the camera matrix, you need a vector for axis x, a vector for axis y, and a vector for axis z, as well as a position for the camera in world space. The vectors for the x, y, and z axes are defined in world space, and they have magnitude 1 in camera space. For example, the x axis might be defined as vector (0.176, -0.512, 0.840) in world space, but in camera space, it is simply (1, 0, 0). This wiki is a useful reference for the Camera Matrix section.
- This is a 4-byte unsigned integer denoting the total length (in bytes) of this section
| Offset | Size (bytes) | Description |
|---|---|---|
| 0 | 38 | Camera 1 |
| 38 | 38 | Camera 2 (if applicable) |
| ... | ... | ... |
Each entry in this section is exactly 38 bytes. There is no indicator of the number of entries other than just computing section_length / 38.
| Offset | Size (bytes) | Description |
|---|---|---|
| 0 | 6 | x-Axis Vector |
| 6 | 6 | y-Axis Vector |
| 12 | 6 | z-Axis Vector |
| 18 | 2 | z-Axis Vector Dimension 3 (copy) |
| 20 | 12 | Position (Camera Space) |
| 32 | 4 | Blank |
| 36 | 2 | Zoom |
There is a vector for each of the three axes: x, y, and z. Each vector has 3 dimensions, and each value in the vector is 2 bytes (unsigned integer), so the each of the 3 vectors is 6 bytes total.
According to this wiki, it seems like, for each vector, you need to flip the signs of the 2nd and 3rd dimensions, and all 3 dimensions need to be divided by 4,096.
This is a duplicate of the third dimension (i.e., value) of the z-axis vector. I'm not sure what it's for (padding? just a sanity check?).
There is a 4-byte unsigned integer for each of the three axes (x, y, and z) representing the position of the center of the camera matrix in camera space. You can get the position of the center of the camera matrix in world space (tx,ty,tz) as follows (where (px,py,pz) denotes the Camera Space Position and vx, vy, vz denote the Axis Vectors for axes x, y, and z, respectively):
tx = -(px*vx[1] + py*vy[1] + pz*vz[1])
ty = -(px*vx[2] + py*vy[2] + pz*vz[2])
tz = -(px*vx[3] + py*vy[3] + pz*vz[3])Niema Moshiri 2019