Jump to content
  • Advertisement
Sign in to follow this  
sjmarsha

Messed up Textures

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi All I have this code to read doom 3 material files, but when I tokenize the file, and return a valid texture name, the map loads all wrong with half the textures missing. If I comment out the tokenizing code, and return a static string from this function the textures load correctly. Any help would be welcome. Here is the code: char * Doom_C::findMatTexture(char * string,char * file_name) { FILE *filein; char oneline[1024]; char *ch; bool return_texture; bool valid_tex; //char temp[100]; char temp_two[100]; char * trimed_mat; //Open MAP File filein = fopen(file_name, "rt"); //test that we found the file if (filein == NULL) { MessageBox(NULL,file_name,"Can't Open File",MB_OK); return ""; } while (!feof(filein)) { fgets(oneline, 1024,filein); ch = strtok(oneline," "); if (ch != '\0') { valid_tex = testTextureName(ch); if (valid_tex) { trimed_mat = trimMaterial(ch); //sprintf(temp, "File: %s and Texture: %s and STRING: %s with lengths %d %d",mat_name,trimed_mat,string,strlen(trimed_mat),strlen(string)); //MessageBox(NULL,temp,"+++ Valid Material Detected",MB_OK); if ((strcmp(trimed_mat,string) == 0)) { sprintf(temp_two, "File: %s and Texture: %s",file_name,trimed_mat); //MessageBox(NULL,temp_two,"+++ Material Detected",MB_OK); return_texture = true; } if (return_texture) { if (testTextureEnding(trimed_mat)) { //MessageBox(NULL,trimed_mat,"+++ Returning Material",MB_OK); fclose(filein); return trimed_mat; } } valid_tex = false; } } do { ch = strtok('\0'," "); if (ch != '\0') { valid_tex = testTextureName(ch); if (valid_tex) { trimed_mat = trimMaterial(ch); //sprintf(temp, "File: %s and Texture: %s",mat_name,trimed_mat); //MessageBox(NULL,temp,"*** Valid Material Detected",MB_OK); if ((strcmp(trimed_mat,string) == 0)) { sprintf(temp_two, "File: %s and Texture: %s",file_name,trimed_mat); //MessageBox(NULL,temp,"*** Material Detected",MB_OK); return_texture = true; } if (return_texture) { if (testTextureEnding(trimed_mat)) { //MessageBox(NULL,trimed_mat,"*** Returning Material",MB_OK); fclose(filein); return trimed_mat; } } valid_tex = false; } } } while(ch); } fclose(filein); return ""; } regards Steve

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!