mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-22 22:29:11 +00:00
LoadIQM: attempt to load texture from IQM at loadtime. (#4029)
tries to load the texture with the base path of the original IQM file, relative paths should work.
This commit is contained in:
@@ -4268,6 +4268,8 @@ static Model LoadIQM(const char *fileName)
|
|||||||
// In case file can not be read, return an empty model
|
// In case file can not be read, return an empty model
|
||||||
if (fileDataPtr == NULL) return model;
|
if (fileDataPtr == NULL) return model;
|
||||||
|
|
||||||
|
const char* basePath = GetDirectoryPath(fileName);
|
||||||
|
|
||||||
// Read IQM header
|
// Read IQM header
|
||||||
IQMHeader *iqmHeader = (IQMHeader *)fileDataPtr;
|
IQMHeader *iqmHeader = (IQMHeader *)fileDataPtr;
|
||||||
|
|
||||||
@@ -4312,6 +4314,7 @@ static Model LoadIQM(const char *fileName)
|
|||||||
memcpy(material, fileDataPtr + iqmHeader->ofs_text + imesh[i].material, MATERIAL_NAME_LENGTH*sizeof(char));
|
memcpy(material, fileDataPtr + iqmHeader->ofs_text + imesh[i].material, MATERIAL_NAME_LENGTH*sizeof(char));
|
||||||
|
|
||||||
model.materials[i] = LoadMaterialDefault();
|
model.materials[i] = LoadMaterialDefault();
|
||||||
|
model.materials[i].maps[MATERIAL_MAP_ALBEDO].texture = LoadTexture(TextFormat("%s/%s", basePath, material));
|
||||||
|
|
||||||
TRACELOG(LOG_DEBUG, "MODEL: [%s] mesh name (%s), material (%s)", fileName, name, material);
|
TRACELOG(LOG_DEBUG, "MODEL: [%s] mesh name (%s), material (%s)", fileName, name, material);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user