Not logged in, Join Here! or Log In Below:  
News Articles Search    

 Home / 3D Theory & Graphics / lib3ds_file_insert_material () skips 1st material Account Manager
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

May 09, 2005, 01:01 PM

Ok, the meshes are now loaded in correctly, but i noticed a problem with materials.
It seems strange to me, that the very first material disappears during the loop, maybe the problem is somewhere else, but i just posted this thread for getting somekind of inspiration or ideas, what could be wrong..

Please do not pay attention to the function "SubdivideString", as it is a plugin support-function that just tokens the string..

  2. int ProcMats (Lib3dsFile *f3ds, String Materials){
  3. int numMats = 0;
  4. StringList strl, strl2, strl3, strl4;
  5. char msg[256];
  6. int i;
  8.      //Find the number of materials into numMats
  9.      strl = SubdivideString (Materials, String("n"));
  10.      strl2 = SubdivideString (Materials, String(";"));
  11.      numMats = atoi (strl2 [0].c_str());
  13.      //Loop through all the materials
  14.      for (i=0; i<numMats; i++){
  15.                   Lib3dsMaterial *mat3ds = lib3ds_material_new ();
  16.           if (!mat3ds){
  17.              MessageBox (NULL, "Not enough memory for materials", "Error", MB_OK | MB_ICONERROR);
  18.           }
  19.           strl2 = SubdivideString (strl [i+1], String(";"));
  20.           strcpy (mat3ds->name, strl2 [1].c_str());
  21.           //Find Material texture file name
  22.           strl3 = SubdivideString (strl [i+1], String(","));
  23.           strl4 = SubdivideString (strl3 [1], String("\"));
  24.          strcpy (mat3ds->, strl4 [1].c_str());
  26.          lib3ds_file_insert_material (f3ds, mat3ds);
  27.          //If i check the f3ds->materials here when i==0, the materials are as they should be, but whenever i>0, the first materials is disappeared :S  
  28.     }
  29.     GetMaterialName (f3ds, 0); //This function was used for testing, as it isn't functioning, when the materials aren't in the right order
  30.     //It finds the material nr.0 and displays it's name from f3ds
  31.     return numMats;
  32. }

If someone of You has some ideas,
all suggestions are welcome, Thank You

This thread contains 1 message.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.