Rgba2Hex to repair rgba(1,1,1,1)

pull/3158/head
Hehongyuanlove 2020-04-17 12:34:05 +08:00 committed by GitHub
parent 3154cec79c
commit 3bbc8e76bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 10 deletions

View File

@ -254,16 +254,28 @@ void D3MFExporter::writeBaseMaterials() {
if ( mat->Get( AI_MATKEY_COLOR_DIFFUSE, color ) == aiReturn_SUCCESS ) { if ( mat->Get( AI_MATKEY_COLOR_DIFFUSE, color ) == aiReturn_SUCCESS ) {
hexDiffuseColor.clear(); hexDiffuseColor.clear();
tmp.clear(); tmp.clear();
hexDiffuseColor = "#"; // rgbs %
if(color.r <= 1 && color.g <= 1 && color.b <= 1 && color.a <= 1){
tmp = DecimalToHexa( (ai_real) color.r ); hexDiffuseColor = Rgba2Hex(
hexDiffuseColor += tmp; ((ai_real)color.r)*255,
tmp = DecimalToHexa((ai_real)color.g); ((ai_real)color.g)*255,
hexDiffuseColor += tmp; ((ai_real)color.b)*255,
tmp = DecimalToHexa((ai_real)color.b); ((ai_real)color.a)*255,
hexDiffuseColor += tmp; true
tmp = DecimalToHexa((ai_real)color.a); );
hexDiffuseColor += tmp;
}else{
hexDiffuseColor = "#";
tmp = DecimalToHexa( (ai_real) color.r );
hexDiffuseColor += tmp;
tmp = DecimalToHexa((ai_real)color.g);
hexDiffuseColor += tmp;
tmp = DecimalToHexa((ai_real)color.b);
hexDiffuseColor += tmp;
tmp = DecimalToHexa((ai_real)color.a);
hexDiffuseColor += tmp;
}
} else { } else {
hexDiffuseColor = "#FFFFFFFF"; hexDiffuseColor = "#FFFFFFFF";
} }