Results 1 to 6 of 6

Thread: how read colors in .3ds files ?

  1. #1
    Senior Member Regular Contributor
    Join Date
    Mar 2002
    Location
    France
    Posts
    286

    how read colors in .3ds files ?

    Hi,
    I don't manage to read colors'meshes in my .3ds files. I read in the 0xa010 then in 0x0011 but when i display the red, green and blue values by doing a cast to an integer i have for example a white color instead of a brown one (for the color of skin of a character)under 3d studio max.
    Can you help me ?

    Code :
     case 0x0011: unsigned char red, green, blue ;
    						 file.read((char*)&red, sizeof (unsigned char));
    						 file.read((char*)&green, sizeof (unsigned char));
    						 file.read((char*)&blue, sizeof (unsigned char));
    						 cout<<dec<<"rouge "<<(int)red<<" vert "<<(int)green<<" bleu "
    							 <<(int)blue<<endl ;
    						 break ;

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jan 2001
    Location
    Ukraine
    Posts
    101

    Re: how read colors in .3ds files ?

    It seems like use correct way to load color values from 3ds file. I've load colors using 0x0011 chunks in very similar way and can't say that result is incorrect. By the way, what the output operator show in your case? All 255? Maybe you have an error of convertion those values later to floating points without division by 255?

  3. #3
    Senior Member Regular Contributor
    Join Date
    Mar 2002
    Location
    France
    Posts
    286

    Re: how read colors in .3ds files ?

    Hi !
    Without dividing by 255 i always have white color, by dividing by 255 i have black color, both by using this code before glDrawElement :
    Code :
    float red= 223/255 ;
    float green= 174/255 ;
    float blue= 132/255 ;
    glColor3f(red, green, blue);

  4. #4
    Senior Member Regular Contributor
    Join Date
    Aug 2003
    Posts
    369

    Re: how read colors in .3ds files ?

    Hmm, there's a mistake I myself run into sometimes. When doing the division remember to put 255.0 so as to convert the number to double (or 255.0f for float). Without it the program executes integer division which would give 0 or 1. Is there a chance you could post the code for the .3d loader here? I'd like to take a look at it.

  5. #5
    Senior Member Regular Contributor
    Join Date
    Mar 2002
    Location
    France
    Posts
    286

    Re: how read colors in .3ds files ?

    Thanks for your help guys !
    what part of the .3ds loader do you want to see ? it is a very long program.

  6. #6
    Senior Member Regular Contributor
    Join Date
    Jan 2001
    Location
    Ukraine
    Posts
    101

    Re: how read colors in .3ds files ?

    As moucard tell you use 255.0f instead of simply 255 when you divide.

Similar Threads

  1. Replies: 2
    Last Post: 10-20-2007, 02:15 PM
  2. how to read 16bit targa files?
    By urban debugger in forum OpenGL: Advanced Coding
    Replies: 16
    Last Post: 10-17-2002, 03:44 PM
  3. HOW CAN I READ DXF FILES??THANKS!!!
    By simba in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 10-07-2002, 10:40 PM
  4. Vertex/Face colors in 3DStudio ASC/ASE files ?
    By byaniv in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-15-2000, 09:06 AM
  5. Read *.dat files
    By Nico in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 06-13-2000, 06:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean