i am trying to read an unknown game file format (ps2 model file). all i know is it's a modified renderware dff file (which has elements of the gta sa dff format). this
particular game uses triangle strips to draw each model. there is duplicate/degenerate vertices present in every model file.
as i understand, the ps2 had serious memory limits. it appears the programmers decided there was significant gains to be had from changing the storage of floating
point data. for example, instead of storing a vertex float in four bytes, they stored it in two bytes. or normal floats in four bytes, they stored it in one byte! my
problem is converting this data to how it is meant to be read. originally i thought there was a fixed scale variable it had to be multiplied by... but now i am just
not sure at all. the total number of vertices for a model file i am looking at currently is 321. coincidently, theres also four different chunks of data that follows
this vertex data i believe is uv, colour vertices and normals. each chunk that follows the vertices chunk is 321 * 4. i believe uv's are stored as two byte floats,
colour vertices are stored as one byte unsigned chars and normals are stored as one byte floats?
eg;
- vertices; 321 * 8 (two byte float * 4) x, y, z, 00 - padding?
- uv's; 321 * 4 (two byte float * two?) u, v
- vertex colours; 321 * 4 (one byte unsigned char * four?) r, g, b, a
- normals; 321 * 4 (one byte * four?) x, y, z, 00 - padding?
i wrote a small console application to parse the manualy extracted binary data and dump it into floats but get undesirable values...
[source lang="cpp"]int n_vertices;signed short data;float (*normals)[3];float normal_scale = 1 / 126.076126092;fread(&n_vertices, 4, 1, f);normals = new float[n_vertices][3];printf("parsing normals...\n");for (int loop_loop = 0; loop_loop < n_vertices; loop_loop++) { for (int loop_iterator = 0; loop_iterator < 3; loop_iterator++) { fread(&data, 1, 1, f); normal = (float)data * normal_scale; normals[loop_loop][loop_iterator] = normal; } // skip the padding fseek(f, 1, SEEK_CUR);}[/source]
four bytes of binary data i presume is the normals looks like this (in hex);
7F000000
when i parse it and dump the floats in my program, i see;
-110.671234 -111.678558 -111.678558
i was originally dividing my vertex float values by 32768.0f. basically, i just dont know what i am doing. can someone shed light onto how a single or two byte float is
stored, then read correctly? im getting two very different values for one byte floats and two byte floats

!
any help at all is appreciated.
thanks for your time.
best regards,
justin