Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: how read colors in .3ds files ?

Hybrid View

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

    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
    Junior 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
    Member Regular Contributor
    Join Date
    Mar 2002
    Location
    France
    Posts
    363

    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
    Member Regular Contributor
    Join Date
    Aug 2003
    Posts
    368

    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
    Member Regular Contributor
    Join Date
    Mar 2002
    Location
    France
    Posts
    363

    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
    Junior 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •