MCPcopy Create free account
hub / github.com/beefytech/Beef / LoadMesh

Method LoadMesh

BeefySysLib/fbx/FBXReader.cpp:221–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219//void FBXReader::TranslateNode
220
221FBXMesh* FBXReader::LoadMesh(FbxNode* fbxNode, FbxMesh* fbxMesh)
222{
223 FBXMesh* mesh = new FBXMesh();
224 mesh->mName = fbxNode->GetName();
225
226 FbxAMatrix nodeTransform = GetBindPose(fbxNode, fbxMesh);
227 nodeTransform = FBXCorrectMatrix(nodeTransform);
228
229 int numSrcVertices = fbxMesh->GetControlPointsCount();
230 int numFaces = fbxMesh->GetPolygonCount();
231 int numVertices = numFaces * 3;
232
233 int elementMatCount = fbxMesh->GetElementMaterialCount();
234
235 int numMaterials = fbxNode->GetMaterialCount();
236
237 FBXMaterial* material = &mesh->mMaterial;
238
239 for (int matIdx = 0; matIdx < numMaterials; matIdx++)
240 {
241 FbxSurfaceMaterial* fbxMaterial = fbxNode->GetMaterial(matIdx);
242
243 const char* matName = fbxMaterial->GetName();
244
245 for (int channelIdx = 0; true; channelIdx++)
246 {
247 FbxProperty prop = fbxMaterial->FindProperty(FbxLayerElement::sTextureChannelNames[channelIdx]);
248 if (!prop.IsValid())
249 break;
250 int texCount = prop.GetSrcObjectCount(FbxTexture::ClassId);
251
252 for (int texIdx = 0; texIdx < texCount; texIdx++)
253 {
254 FbxTexture* texture = FbxCast<FbxTexture>(prop.GetSrcObject(FbxTexture::ClassId, texIdx));
255 if (texture != NULL)
256 {
257 FbxFileTexture* fileTexture = FbxCast<FbxFileTexture>(texture);
258
259 if (fileTexture != NULL)
260 {
261 String mediaName = fileTexture->GetMediaName();
262 String fileExt = "";
263
264 int parenPos = (int)mediaName.find(" (");
265 String origFileName = fileTexture->GetFileName();
266 int dotPos = (int)origFileName.rfind('.');
267 if (dotPos != -1)
268 fileExt = origFileName.substr(dotPos);
269 //material->mTexFileName = fileName;
270
271 /*if (parenPos != -1)
272 {
273 String suffix = mediaName.substr(parenPos + 1);
274 String fileName = mediaName.substr(0, parenPos);
275
276 fileName += fileExt;
277
278 if (suffix == "(Map)")

Callers

nothing calls this directly

Calls 14

FBXCorrectMatrixFunction · 0.85
TexCoordsClass · 0.85
Vector3Class · 0.85
IsValidMethod · 0.80
findMethod · 0.80
GetNameMethod · 0.45
GetFileNameMethod · 0.45
lengthMethod · 0.45
resizeMethod · 0.45
GetCountMethod · 0.45
push_backMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected