This topic is 5053 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've changed my directory structure of my project. All the header/cpp and x-files with textures where dumped in one directory so I added a directory source with dirs for my cpp and header files. I also created a directory media with a dir XFiles in it. The problem is that after changing my code to use the new paths I get the error that the textures for my XFile can't be found but the x-file itself can be found. My mesh constructor calls an init function where i use the code from Tutorial 6.. everything worked perfect before I changed the directorys
// Old code:
CubeMesh = new CMesh("Cube.x");
// New code:
CubeMesh = new CMesh(".\\Media\\XFiles\\Cube.x");


Any idea what could be the problem?

##### Share on other sites
I would suggest you debug print the file location when you load the texture, then check that with the actual location. There may be a problem there. But that does seem kind of strange.

If you've got the right file name + location, I can't help you.

##### Share on other sites
Have you created a sub-folder for textures and a sub-folder for X files? The X files and associated textures will most likely need to be in the same directory.

If you have text based X files open them up in Wordpad and look at the material templates. Part of the material template is a path to the texture file. Make sure that path points to the texture file relative to where the X file is.

Also, you do not need the ".\\" at the start of your paths.

##### Share on other sites
I've exported the modells again from 3dsmax and now everythings works fine..

Altough I haven't got a clue why it's working now..

##### Share on other sites
One thing you can do is export the x files as text instead of binary, then check how the texture filenames are being stored by the exporter. It would be good to know this information if you plan on re-distributing. If it stores them as "c:\my documents\projects\test\textures" for instance, that's BAD. It should be a relative path to your x file.

Chris

##### Share on other sites
I've checked the paths and in the working version the complete path is mentioned:

D:\\Programming\\MyPrograms\\RazorEngine\\Media\\XFiles\\Icecube.jpg

If I change this to "Icecube.jpg" I get the error that the texture can't be found.

The strange thin is that if I open my Xfile with the Meshviewer from the SDK the cube shows up with the correct texture.

If I change "Icecube.jpg" to "Media\\XFiles\\Icecube.jpg" the textures are loaded correctly.

So what should I do? Change all the paths in my xfiles before distributing it to other users?

##### Share on other sites
You would want to probably store the installation directory in a key in the registry when the player installs the game. Then, load this registry key in your game, say it's "C:\Program Files\Games Inc\Game of the Year". Then, set the current windows directory to this directory before calling the Load function for the texture. Then if the texture's filename is "textures\tex1.bmp", it will be appended to the current directory (or so is usually the case).

Functions you'll need:
SetCurrentDirectory("String");
See Registry Sample in the MSDN Library.

Chris

• 32
• 12
• 10
• 9
• 9
• ### Forum Statistics

• Total Topics
631349
• Total Posts
2999473
×