MCPcopy Create free account
hub / github.com/TheRealMJP/BakingLab / CreateFromSDKMeshFile

Method CreateFromSDKMeshFile

SampleFramework11/v1.02/Graphics/Model.cpp:857–895  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

855// == Model =======================================================================================
856
857void Model::CreateFromSDKMeshFile(ID3D11Device* device, LPCWSTR fileName, const wchar* normalMapSuffix,
858 bool generateTangentFrame, bool overrideNormalMaps, bool forceSRGB)
859{
860 Assert_(FileExists(fileName));
861
862 // Use the SDKMesh class to load in the data
863 SDKMesh sdkMesh;
864 sdkMesh.Create(fileName);
865
866 fileDirectory = GetDirectoryFromFilePath(fileName);
867
868 // Make materials
869 uint32 numMaterials = sdkMesh.GetNumMaterials();
870 for(uint32 i = 0; i < numMaterials; ++i)
871 {
872 MeshMaterial material;
873 SDKMESH_MATERIAL* mat = sdkMesh.GetMaterial(i);
874 material.DiffuseMapName = AnsiToWString(mat->DiffuseTexture);
875 material.NormalMapName = AnsiToWString(mat->NormalTexture);
876
877 // Add the normal map prefix
878 if (normalMapSuffix && material.DiffuseMapName.length() > 0
879 && (material.NormalMapName.length() == 0 || overrideNormalMaps))
880 {
881 wstring base = GetFilePathWithoutExtension(material.DiffuseMapName.c_str());
882 wstring extension = GetFileExtension(material.DiffuseMapName.c_str());
883 material.NormalMapName = base + normalMapSuffix + L"." + extension;
884 }
885
886 LoadMaterialResources(material, fileDirectory, device, forceSRGB);
887
888 meshMaterials.push_back(material);
889 }
890
891 uint32 numMeshes = sdkMesh.GetNumMeshes();
892 meshes.resize(numMeshes);
893 for(uint32 meshIdx = 0; meshIdx < numMeshes; ++meshIdx)
894 meshes[meshIdx].InitFromSDKMesh(device, sdkMesh, meshIdx, generateTangentFrame);
895}
896
897void Model::CreateWithAssimp(ID3D11Device* device, const wchar* fileName, bool forceSRGB)
898{

Callers

nothing calls this directly

Calls 13

FileExistsFunction · 0.85
GetDirectoryFromFilePathFunction · 0.85
AnsiToWStringFunction · 0.85
GetFileExtensionFunction · 0.85
CreateMethod · 0.80
GetNumMaterialsMethod · 0.80
GetMaterialMethod · 0.80
lengthMethod · 0.80
GetNumMeshesMethod · 0.80
InitFromSDKMeshMethod · 0.80
push_backMethod · 0.45

Tested by

no test coverage detected