

We need this because we want to relate our layer information with our vertices (Control Points) Int inCtrlPointIndex: the index of the Control Point. Without loss of generality, I will use Binormal as an example:īefore we take a look at the function, let's go over its parameters first.įbxMesh* inMesh: the mesh that we are trying to export
AUTODESK FBX CONVERTER SLOWS DOWN COMPUTER CODE
How can I relate the Control Points to the information in the layer? Well, this is the pretty tricky part and please let me show you some code and then explain it line by line. However, you might have already asked me. In the layer, you can acquire the information of UVs, Normals, Tangents, Binormals. This gift paper is the layer of the mesh in FBX. It is like you have a box, and you wrap it with gift paper. FBX introduces this sense of "Layer", which covers the body of the mesh. In other words, you have this shape, but you don't have any information on how the surface of this shape looks. This body does not have any information about its surface. Then you ask "how can I get the UVs, Normals, Tangents, Binormals?" Well, please think of a mesh like this for a moment: You have this body of the mesh, but this is only the geometry, the shape of it. Unsigned int ctrlPointCount = currMesh->GetControlPointsCount() įor(unsigned int i = 0 i GetControlPointAt(i).mData) ĬurrPosition.y = static_cast(currMesh->GetControlPointAt(i).mData) ĬurrPosition.z = static_cast(currMesh->GetControlPointAt(i).mData) Void FBXExporter::ProcessControlPoints(FbxNode* inNode) this is why I can use inNode->GetMesh() on it to get the mesh The following code would get you the positions of all the vertices of your mesh: // inNode is the Node in this FBX Scene that contains the mesh The position information is stored in the control points. As a result, if you want, you can use "Vertex" and "Control Point" interchangeably. These 8 vertices are the only 8 "control points" in the FBX file. For example, you have a cube, then you have 8 vertices. In FBX we have the term "Control Point", basically a control point is a physical vertex. Now mControlPoints has served its purposeįor(auto itr = mControlPoints.begin() itr != mControlPoints.end() ++itr) įirst please let me explain how FBX stores all its information about a mesh. MTriangles.back().mIndices.push_back(vertexCounter) Sort the blending info so that later we can remove Copy the blending info from each control pointįor(unsigned int i = 0 i mBlendingInfo.size() ++i)ĬurrBlendingInfo.mBlendingIndex = currCtrlPoint->mBlendingInfo.mBlendingIndex ĬurrBlendingInfo.mBlendingWeight = currCtrlPoint->mBlendingInfo.mBlendingWeight Temp.mPosition = currCtrlPoint->mPosition

ReadNormal(currMesh, ctrlPointIndex, vertexCounter, normal) įor (int k = 0 k GetTextureUVIndex(i, j), k, UV)

MTriangleCount = currMesh->GetPolygonCount() įor (unsigned int i = 0 i GetPolygonVertex(i, j) ĬtrlPoint* currCtrlPoint = mControlPoints void FBXExporter::ProcessMesh(FbxNode* inNode) Note that there is some code related to blending info for animation. You don't know what each function does specifically, but you should get the idea that I am traversing the 3 vertices on each triangle of the mesh. This allows me to give you a Top-Down understanding of what you need to do to gather mesh data. For the clarity of this section, I choose to show you how I traverse the mesh in a FBX file first.

The first thing you want to do is to get the mesh data it already feels pretty good if you can import your static mesh into your engine. The link is here: Mesh Data(position, UV, normal, tangent, binormal) If you have no knowledge about how skeletal animation works and what data you need to make skeletal animation happen, please look at Buckeye's article "Skinned Mesh Animation Using Matrices". For things like "how to initialize FBX SDK", please check the sample code yourself, the "ImportScene" sample would be very useful in this respect.
AUTODESK FBX CONVERTER SLOWS DOWN COMPUTER HOW TO
Basically I will tell the reader how to get the data they need for their game engine. This tutorial would be specifically about game engines. Since I don't think anyone has ever posted a clear and thorough tutorial on how to convert FBX files to custom formats, I will do it. I have searched almost all the corners on the Internet to clarify things so that I can have a clear mapping from FBX SDK's data to what I need in a game engine. Plus, since FBX format is utilized by a number of applications, rather than just game engines, the sample code provided is not using the more common technical terms we use in game development. The entire process is not very smooth, mainly because FBX's official documentation is not very clear. I have wanted to make an FBX Exporter to convert FBX files to my own format for a while.
