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

Method CreateFromSDKMeshFile

SampleFramework11/v1.01/Graphics/Model.cpp:857–901  ·  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 memcpy(&material.AmbientAlbedo, &mat->Ambient, sizeof(Float4));
875 memcpy(&material.DiffuseAlbedo, &mat->Diffuse, sizeof(Float4));
876 memcpy(&material.SpecularAlbedo, &mat->Specular, sizeof(Float4));
877 memcpy(&material.Emissive, &mat->Emissive, sizeof(Float4));
878 material.Alpha = mat->Diffuse.w;
879 material.SpecularPower = mat->Power;
880 material.DiffuseMapName = AnsiToWString(mat->DiffuseTexture);
881 material.NormalMapName = AnsiToWString(mat->NormalTexture);
882
883 // Add the normal map prefix
884 if (normalMapSuffix && material.DiffuseMapName.length() > 0
885 && (material.NormalMapName.length() == 0 || overrideNormalMaps))
886 {
887 wstring base = GetFilePathWithoutExtension(material.DiffuseMapName.c_str());
888 wstring extension = GetFileExtension(material.DiffuseMapName.c_str());
889 material.NormalMapName = base + normalMapSuffix + L"." + extension;
890 }
891
892 LoadMaterialResources(material, fileDirectory, device, forceSRGB);
893
894 meshMaterials.push_back(material);
895 }
896
897 uint32 numMeshes = sdkMesh.GetNumMeshes();
898 meshes.resize(numMeshes);
899 for(uint32 meshIdx = 0; meshIdx < numMeshes; ++meshIdx)
900 meshes[meshIdx].InitFromSDKMesh(device, sdkMesh, meshIdx, generateTangentFrame);
901}
902
903void Model::CreateWithAssimp(ID3D11Device* device, const wchar* fileName, bool forceSRGB)
904{

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected