PDA

View Full Version : how read colors in .3ds files ?



airseb
03-11-2005, 01:10 PM
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 ?


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 ;

CWiC
03-12-2005, 01:43 AM
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?

airseb
03-12-2005, 05:07 AM
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 :

float red= 223/255 ;
float green= 174/255 ;
float blue= 132/255 ;
glColor3f(red, green, blue);

dvm
03-12-2005, 05:24 AM
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.

airseb
03-12-2005, 05:41 AM
Thanks for your help guys !
what part of the .3ds loader do you want to see ? it is a very long program.

CWiC
03-14-2005, 07:16 AM
As moucard tell you use 255.0f instead of simply 255 when you divide.