can anyone explain the FBX format for me?
Asked Answered
T

3

8

i use notepad++ to see the data structure of FBX model but i have some problems understanding it. Here is some info of a cube(side = 10) located in (0,0,0), can anyone tell me what do these members mean? THANKS!

Vertices: *24 {
a: -5,-5,0,5,-5,0,-5,5,0,5,5,0,-5,-5,10,5,-5,10,-5,5,10,5,5,10
} 
PolygonVertexIndex: *36 {
a: 0,2,-4,3,1,-1,4,5,-8,7,6,-5,0,1,-6,5,4,-1,1,3,-8,7,5,-2,3,2,-7,6,7,-4,2,0,-5,4,6,-3
} 
Edges: *18 {
a: 0,1,2,3,4,6,7,8,9,10,13,14,16,19,20,25,26,32
} 
Normals: *108 {
a: 0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,-        1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-   1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0
} 

UV: *24 {
a: 0,0,1,0,0,1,1,1,0,0,1,0,0,1,1,1,0,0,1,0,0,1,1,1
} 
UVIndex: *36 {
a: 9,11,10,10,8,9,8,9,11,11,10,8,4,5,7,7,6,4,0,1,3,3,2,0,4,5,7,7,6,4,0,1,3,3,2,0
} 
Tetrad answered 12/10, 2011 at 7:51 Comment(1)
A more detailed explanation can be found here: banexdevblog.wordpress.com/2014/06/23/…Dinge
P
11

Even with no knowledge of the FBX format you can at least make some very reasonable guesses:

  1. The 24 values under Vertices are the 8 vertices of the cube (with 3 values representing one vertex).

  2. The 36 values under PolygonVertexIndex are the vertex indices (referencing the values from Vertices) for the 12 triangles making up the 6 faces of the cube.

  3. The 24 values under Edges are the vertex indices of the 12 edges of the cube.

  4. The 108 values under Normals are the 36 normals for each of the triangle corners of the 12 triangles (with 3 values representing one normal vector).

  5. The 24 values under UV are 12 texture coordinates (with 2 values representing one texture coordinate pair).

  6. The 36 values under UVIndex are the texture coordinate indices (referencing the values from UV) for the 36 triangle corners of the cube.

I think these assumptions are quite reasonable, though I'm not sure why the PolygonVertexIndex array contains negative values (it seems every third index of each triangle is negative). Maybe to indicate the last index of a polygon, so you can have polygons which need not be triangles.

Phoebephoebus answered 12/10, 2011 at 12:24 Comment(3)
yeah the "normals" are normals for the three vertices of 12 faces. But isn't the a vertex's normal computed by adding the normals of the faces connected with the vertex and then normalizing? I got quite confused with the normal of a vertex and the normal of a face.Tetrad
@Tetrad The normals can be computed anyway you want and for a cube it is no good idea to average a vertex's adjacent face normals. The format seems to store a normal for each triangle corner (therefore 36 normals) and not for each triangle or for each vertex. This way the normals can be whatever they want (per-vertex, per-face or something in between), introducing duplicate normals as neccessary.Phoebephoebus
regarding Edges, These are not vertex indices's, They are direct references to the PolygonVertexIndex array. Each edge is defined by that vertex and the next one in that face (if the index is < 0, it wraps around to the first index in that polygon). (I found this while writing an importer, if you load these values as edge-index-pairs you end up with scrambled edges all over the mesh)Brew
K
12

I think these assumptions are quite reasonable, though I'm not sure why the PolygonVertexIndex array contains negative values (it seems every third index of each triangle is negative). Maybe to indicate the last index of a polygon, so you can have polygons which need not be triangles.

The one with the negative value represents the last vertex indeed.

To find out witch vertex this is, you have to negate it and subtract 1 from that value.

For example, -4 represents 3 ((-4)*(-1) - 1)

Knowhow answered 13/4, 2012 at 16:11 Comment(3)
And this makes perfect sense, Thanks Autodesk... I guess we have to deal with this.Testicle
Now that I think about it the -1 is smart because otherwise you have a problem with index 0!Testicle
indeed, it is, is the last one on the polygon. The FBX can define multivertex polygons, and uses the (-N-1) to show wich one is the end.Cohin
P
11

Even with no knowledge of the FBX format you can at least make some very reasonable guesses:

  1. The 24 values under Vertices are the 8 vertices of the cube (with 3 values representing one vertex).

  2. The 36 values under PolygonVertexIndex are the vertex indices (referencing the values from Vertices) for the 12 triangles making up the 6 faces of the cube.

  3. The 24 values under Edges are the vertex indices of the 12 edges of the cube.

  4. The 108 values under Normals are the 36 normals for each of the triangle corners of the 12 triangles (with 3 values representing one normal vector).

  5. The 24 values under UV are 12 texture coordinates (with 2 values representing one texture coordinate pair).

  6. The 36 values under UVIndex are the texture coordinate indices (referencing the values from UV) for the 36 triangle corners of the cube.

I think these assumptions are quite reasonable, though I'm not sure why the PolygonVertexIndex array contains negative values (it seems every third index of each triangle is negative). Maybe to indicate the last index of a polygon, so you can have polygons which need not be triangles.

Phoebephoebus answered 12/10, 2011 at 12:24 Comment(3)
yeah the "normals" are normals for the three vertices of 12 faces. But isn't the a vertex's normal computed by adding the normals of the faces connected with the vertex and then normalizing? I got quite confused with the normal of a vertex and the normal of a face.Tetrad
@Tetrad The normals can be computed anyway you want and for a cube it is no good idea to average a vertex's adjacent face normals. The format seems to store a normal for each triangle corner (therefore 36 normals) and not for each triangle or for each vertex. This way the normals can be whatever they want (per-vertex, per-face or something in between), introducing duplicate normals as neccessary.Phoebephoebus
regarding Edges, These are not vertex indices's, They are direct references to the PolygonVertexIndex array. Each edge is defined by that vertex and the next one in that face (if the index is < 0, it wraps around to the first index in that polygon). (I found this while writing an importer, if you load these values as edge-index-pairs you end up with scrambled edges all over the mesh)Brew
O
11

The negative vertex index indicates the end of the polygon. You can bitwise negate the negative index, to get the positive one.

In c this would be

posIndex = ~negIndex;
Opportina answered 23/4, 2012 at 21:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.