Model Texture's Paths

Topics: User Forum
Feb 19, 2007 at 3:08 PM
I noticed that your X-File content importer does not consider the model's directory as the base path to look for its textures. The model files usually refer to textures by a relative path (e.g. ..\Textures\mytex.png), so if a model is located at projdir\Content\Models, the importer should find the texture at projdir\Content\Models\..\Textures\mytex.png, i.e. projdir\Content\Textures\mytex.png.

Your current implementation tries to find the textures in localworkdir(usually the proj dir)\texture_path so it will only get there in very sepecific cases (e.g. your textures are on your project root dir.

As such, my suggestion is that you change your importer to find the texture starting on your model's dir. Something like this (on XModelImporter.cs):

> Add a class private var: private String workingPath;
> Fill that var with the model's path in the ctor:
this.workingPath = System.IO.Path.GetDirectoryName(this.fileName) + System.IO.Path.DirectorySeparatorChar;

> Use it for the texture filename in the ImportMaterial() method:


if (fileName.TrimStart(' ', '"').TrimEnd(' ', '"') != "")
fileName = this.workingPath + fileName;

if (!System.IO.File.Exists(fileName))


Feb 19, 2007 at 10:04 PM
Confirmed and fixed (will be in next checkin). Thanks. You can use the issue tracker to report bugs too.