Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® FBX® / FBX SDK / Wrong Vertex order when importing poly meshes
  RSS 2.0 ATOM  

Wrong Vertex order when importing poly meshes
Rate this thread
 
53406
 
Permlink of this thread  
avatar
  • DP007
  • Posted: 17 March 2011 04:03 AM
  • Total Posts: 17
  • Joined: 16 July 2010 07:06 AM

Hey guys,

I got some issues with the vertex order when importing polygonal meshes via fbx sdk. In my simple example I just created 2 planes in Maya and scaled one plane in x-direction by -1. After that I froze the transformation of the meshes so that the scaling of both is set to (1,1,1). Now if I try to export the scene as fbx and import it in my application the vertex order of the first plane is correct (CCW) while the vertex order of the negatively scaled plane is incorrect. How can this be? Shouldn’t all triangles in a scene have the same vertex order (especially if i freeze transformation on negatively scaled meshes)?
Do I have to manually check the vertex order (can’t imagine that) or is there an option to assure correct vertex order for all triangles contained in a fbx scene?

Thanks in advance.



Replies: 1
/userdata/avatar/3yvwf23us_doug100x100.png

Negative scaling can change the winding order. 

2D example: If I have three verts (0,0) (1,1) (0,1) ccw winding order

scale by (-1,0)

(0,0) (-1,0) (0,1) -> CW

The order of the verts is not changed, but the winding order is.

If there are an odd number of components with negative scaling, the winding order is reversed.

Author: Doug Rogers

Replied: 17 March 2011 04:27 AM  
avatar
  • DP007
  • Posted: 17 March 2011 04:51 AM

So the fbx sdk should handle this for me? Or do I have to manually consider the winding order an rearrange the triangle vertices accordingly?



Replies: 1
/userdata/avatar/3yvwf23us_doug100x100.png

FBX SDK does not handle this case for a good reason. Meshes can be arbitrarily scaled at any time, even during animation.

You have to check the scaling and adjust the winding manually.

Author: Doug Rogers

Replied: 17 March 2011 10:28 AM  
avatar
  • DP007
  • Posted: 17 March 2011 09:52 PM

Ok, but as I said I freeze transformation before exporting to fbx, thus the scale is positive. So how do I check for correct winding in that case?



Replies: 1
/userdata/avatar/3yvwf23us_doug100x100.png

If the scaling is positive in all three axes, the winding order should not be affected.  Is is possible that another matrix is applying a negative scale?

Author: Doug Rogers

Replied: 18 March 2011 03:29 AM  
avatar
  • DP007
  • Posted: 18 March 2011 04:11 AM

For both meshes I somehow got a rotation pivot and a scaling pivot of (-6.85, 0, -0.22). When running the ImportScene sample from the sdk with that file, the info log for the first plane (which wasn’t negatively scaled) also contains two pivot information, two transformation propagation and two geometric transformation sections. I don’t exactly know how to interpret this. Any suggestions?



Replies: 1
/userdata/avatar/3yvwf23us_doug100x100.png

Can you post one or at least an example?  (use .zip)

Author: Doug Rogers

Replied: 18 March 2011 07:23 AM  
avatar
  • DP007
  • Posted: 20 March 2011 10:27 PM

I included the ascii version of the fbx file in the zip. Maybe you could have a look on it. That would be very nice.



Attachment Attachment
Replies: 1
/userdata/avatar/3yvwf23us_doug100x100.png

Nothing seems amiss in this file.  The winding order is consistent with the face normals.  One face normal is up and the other is down.

Author: Doug Rogers

Replied: 21 March 2011 10:32 AM  
avatar

Hi DP007,

In Maya, when you freeze transforms, you get this warning:
// Warning: Freeze transform with negative scale will set the ‘opposite’ attribute for these nodes: pPlaneShape2
It is at this point that the vertex order is modified, in order to freeze the -1 scaling transform.

When the scene is exported to FBX, the FBX exporter simply prints out vertices in the order that Maya saved them.

Maybe if you check option “Normals”, when freezing transforms, that could solve your problem? The vertex order would still be modified, but the normals would get frozen, too.

Viviane
Maya Data Platform
Autodesk



Viviane Rochon
Maya Data Platform
Autodesk

Replies: 0
avatar
  • DP007
  • Posted: 22 March 2011 11:47 PM

Thanks for your reply.

I tried freezing with the normal option set. Nothing really changed.

@Rogers: Sure, I could check the surface normal and rearrange the winding order accordingly. But how to do that when storing normals per vertex not per face? Should I average them to get the face normal? I think thats incorrect.



Replies: 1
/userdata/avatar/3yvwf23us_doug100x100.png

The winding order and the face normal both oriented the triangle facing down.  You can see if the vertex normals are not consistent with the winding order, but in the model you posted, there was no conflict.

Author: Doug Rogers

Replied: 23 March 2011 08:55 AM