UBB tut #1
This tutorial is about fixing the texture loader for MS3D models. It allows textures to be loaded from any spot on any drive given that they are in the Data folder. Ok I know of atleast one person that was able to fix this but since the fix hasn't been publicly stated I decided to post the way I fixed it.
So here's what I did. I made a default directory for ms3d editing. Then I stored that path into an array of characters. After I had the part of the filename that needed removed I just had to shift the string pointer by the length of path and store the string in filename. You will need to include mbstring.h in your model file. Here's my working code:
void Model::reloadTextures() {
//my full work dir is c:/code/project_omega/debug/data
//but we want the data left in so it looks in the data folder
char path[] = "c:/code/project_omega/debug/";
//this is where the exact filename is stored
char *filename;
for ( int n = 0; n < m_numMaterials; n++ )
if ( strlen( m_pMaterials[n].m_pTextureFilename ) > 0 ) {
//here's where the work takes place. this wonderful function increases "current" by "count"
filename = (char *)_mbsninc( (unsigned char *)m_pMaterials[n].m_pTextureFilename, strlen(path));
//pass our real filename
m_pMaterials[n].m_texture = LoadGLTexture( filename );
} else
m_pMaterials[n].m_texture = 0;
}
Edit: god damn italics tag wont let me use i like I always do.
Hunter-Killer
Edited by - Hunter-Killer on February 1, 2001 9:33:19 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement