Change in VRML1 color retrieval rule for out-of-bounds index

This commit is contained in:
Cirilo Bernardo 2016-01-19 16:13:12 +11:00
parent 39ca807ac4
commit fcd89c57ed
1 changed files with 6 additions and 6 deletions

View File

@ -420,7 +420,7 @@ void WRL1MATERIAL::GetColor( SGCOLOR* aColor, int aIndex )
// Calculate the color based on the given index using the formula: // Calculate the color based on the given index using the formula:
// color = ( emission + ambient + diffuse + shininess * specular ) / N // color = ( emission + ambient + diffuse + shininess * specular ) / N
// where N = number of non-zero components or 1 (if all zero) // where N = number of non-zero components or 1 (if all zero)
// If the index exceeds the number of items in a list, use the FIRST // If the index exceeds the number of items in a list, use the LAST
// item rather than the default; this behavior caters to some bad // item rather than the default; this behavior caters to some bad
// models. // models.
@ -435,7 +435,7 @@ void WRL1MATERIAL::GetColor( SGCOLOR* aColor, int aIndex )
{ {
if( !diffuseColor.empty() ) if( !diffuseColor.empty() )
{ {
rgb = diffuseColor.front(); rgb = diffuseColor.back();
dRed = rgb.x; dRed = rgb.x;
dGreen = rgb.y; dGreen = rgb.y;
dBlue = rgb.z; dBlue = rgb.z;
@ -459,7 +459,7 @@ void WRL1MATERIAL::GetColor( SGCOLOR* aColor, int aIndex )
{ {
if( !emissiveColor.empty() ) if( !emissiveColor.empty() )
{ {
rgb = emissiveColor.front(); rgb = emissiveColor.back();
eRed = rgb.x; eRed = rgb.x;
eGreen = rgb.y; eGreen = rgb.y;
eBlue = rgb.z; eBlue = rgb.z;
@ -483,7 +483,7 @@ void WRL1MATERIAL::GetColor( SGCOLOR* aColor, int aIndex )
{ {
if( !ambientColor.empty() ) if( !ambientColor.empty() )
{ {
rgb = ambientColor.front(); rgb = ambientColor.back();
aRed = rgb.x; aRed = rgb.x;
aGreen = rgb.y; aGreen = rgb.y;
aBlue = rgb.z; aBlue = rgb.z;
@ -507,7 +507,7 @@ void WRL1MATERIAL::GetColor( SGCOLOR* aColor, int aIndex )
{ {
if( !specularColor.empty() ) if( !specularColor.empty() )
{ {
rgb = specularColor.front(); rgb = specularColor.back();
sRed = rgb.x; sRed = rgb.x;
sGreen = rgb.y; sGreen = rgb.y;
sBlue = rgb.z; sBlue = rgb.z;
@ -530,7 +530,7 @@ void WRL1MATERIAL::GetColor( SGCOLOR* aColor, int aIndex )
if( aIndex < 0 || ( aIndex >= (int)shininess.size() ) ) if( aIndex < 0 || ( aIndex >= (int)shininess.size() ) )
{ {
if( !shininess.empty() ) if( !shininess.empty() )
shiny = shininess.front(); shiny = shininess.back();
else else
shiny = 0.2; shiny = 0.2;
} }