Anonymous

Changes

From Final Fantasy Inside

FF7/Field/Camera Matrix

1,246 bytes removed, 02:24, 24 March 2018
Created page with "=== Section 2: Camera Matrix (Kero) === This is yet to be completely understand, I am pretty sure that this is not exactly trash, since it is based on at leas..."
=== Section 2: Camera Matrix ([[User:Kero|Kero]]) ===
This is yet to be completely understand, I am pretty sure that this is not exactly trash, since it is based on at least 300 changes of field files. It was pretty nasty, as you can imagine, first divide sections of field file, load section 2 into hexedit, change byte, save section 2, run .bat file that complete new field file with new section 2 and compress it. After that I always had to use ficedula lgp tools, awful, I am definitely going to program command line program for this, in gui i had to alway on original field file, click, replace, click instead of just adding line to .bat file. After that run ff7.exe, go to destinated location and observe what happened.
I am working on program to load walkmesh along with camera matrix. I am pretty sure about vectors, after all, they are all same length and they are orthogonal, but i could misinterpret order of them, position of center is little uncertain and resize factor too. The program should help me to figure out these thing.
==== Description of section 2 (field file): Camera ====
The goal of this section is to define camera matrix. In fact it seems pretty simple. For camera matrix, you need vector for axis x, vector for axis y, vector for axis z and position of camera in world space. Vectors for axis x,y,z are defined in world space and in camera space are normally united.
Example: You have axis x defined as vector (0.176,-0.512,0.840) but that is in world space. In camera space it is just (1,0,0).
- Every offset is relative here, 00 is at the start of section 2 (after length indicator). - This will will be in the left handed coordinated system; x-axis from left to right, y-axis from bottom to top, z-axis from near to far. - In here, I am changing signs so these vectors should be correct for file loaded right from section 5 walkmesh. While in walkmesh you don't change any signs, here I am changing them, so they will fit and if you use this article with unchanged values for walkmesh, you should get right image, same as in ff7. (FIXME: not yet true)
This is an overview the camera data format.
==== Section 2 Format ====
{| borderclass="0" cellspacing="1" cellpadding="3" style="background: rgb(0,0,0)" align="centerwikitable"! style="background:rgb(204,204,204)" align="center" | Offset! style="background:rgb(204,204,204)" align="center" | Size! style="background:rgb(204,204,204); width: 200px" align="center" | Description
|-
|style="background:rgb(255,255,255)" | 0x00|style="background:rgb(255,255,255)" | 6 bytes|style="background:rgb(255,255,255)" | Camera Vector X axis
|-
|style="background:rgb(255,255,255)" | 0x06|style="background:rgb(255,255,255)" | 6 bytes|style="background:rgb(255,255,255)" | Camera Vector Y axis
|-
|style="background:rgb(255,255,255)" | 0x0C|style="background:rgb(255,255,255)" | 6 bytes|style="background:rgb(255,255,255)" | Camera Vector Z axis
|-
|style="background:rgb(255,255,255)" | 0x12|style="background:rgb(255,255,255)" | 2 bytes|style="background:rgb(255,255,255)" | Camera Vector Z.z (copy)
|-
|style="background:rgb(255,255,255)" | 0x14|style="background:rgb(255,255,255)" | 4 bytes|style="background:rgb(255,255,255)" | Camera Space X position
|-
|style="background:rgb(255,255,255)" | 0x18|style="background:rgb(255,255,255)" | 4 bytes|style="background:rgb(255,255,255)" | Camera Space Y position
|-
|style="background:rgb(255,255,255)" | 0x1C|style="background:rgb(255,255,255)" | 4 bytes|style="background:rgb(255,255,255)" | Camera Space Z position
|-
|style="background:rgb(255,255,255)" | 0x20|style="background:rgb(255,255,255)" | 4 bytes|style="background:rgb(255,255,255)" | ''Blank''
|-
|style="background:rgb(255,255,255)" | 0x24|style="background:rgb(255,255,255)" | 2 bytes|style="background:rgb(255,255,255)" | Zoom
|}
You will load first vector for axis x (from offset 0 to 5), for axis y (6 to 11) and axis z (12-17). These values are in fixed point with multiply constant 4096. Length of vectors x,y and z is always 4096 (first vecsize is for x, then y and last z), thats make out multiplication constant. These vectors are also always orthogonormal, as you can see in ORTO 1-2 (1=x,2-y,3=z) ORTO U-Vis scalar product of U and V. As you can see, very near zero (first value is without division of multi constant). Now you have three vectors, but they are not looking in correct direction, you have to change some signs. For each vector change sign of y and z values. Now these vectors should point in correct direction, same as in FF7.
I am now assuming that you have vectors for axises loaded, each component of each vector was divided by 4096 (don't forget to store it in float) and you changed signs for component y and z. After vectors is one S16 number (from offset 18 to 19), same as z component of vector for z axis.
Now you want to have position of center of the camera matrix. Get three S32 numbers for position of center (x from 20 to 23, y from 24-27 and z from 28-31). These number are not position of center in worlds pace, but they are position of center of camera space, defined in space, where position of center is in 0,0,0 and axis for vectors are the ones you read, but have opposite signs. You get center of camera matrix like this:
Anonymous user