From 3fb72902eaa1ec3837aaa4acd4bb6d3a50abc339 Mon Sep 17 00:00:00 2001 From: dbp Date: Thu, 23 Oct 2014 14:59:20 +0400 Subject: [PATCH] 0025349: Graphic3d_MaterialAspect::Color() returns a value different from that set by the method Graphic3d_MaterialAspect::SetColor Fix bug with default color of clip plane. --- src/Graphic3d/Graphic3d_MaterialAspect.cdl | 4 ++-- src/Graphic3d/Graphic3d_MaterialAspect.cxx | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Graphic3d/Graphic3d_MaterialAspect.cdl b/src/Graphic3d/Graphic3d_MaterialAspect.cdl index 14ee809672..76ca03492d 100644 --- a/src/Graphic3d/Graphic3d_MaterialAspect.cdl +++ b/src/Graphic3d/Graphic3d_MaterialAspect.cdl @@ -157,7 +157,7 @@ is AColor : Color from Quantity ) is static; ---Level: Public - ---Purpose: Modifies the ambient colour of the surface. + ---Purpose: Modifies the ambient and diffuse colour of the surface. -- Category: Methods to modify the class definition SetAmbientColor ( me : in out; @@ -260,7 +260,7 @@ is is static; ---C++: return const& ---Level: Public - ---Purpose: Returns the ambient colour of the surface. + ---Purpose: Returns the diffuse colour of the surface. ---Category: Inquire methods AmbientColor ( me ) diff --git a/src/Graphic3d/Graphic3d_MaterialAspect.cxx b/src/Graphic3d/Graphic3d_MaterialAspect.cxx index e872ad3d06..12c3181dae 100644 --- a/src/Graphic3d/Graphic3d_MaterialAspect.cxx +++ b/src/Graphic3d/Graphic3d_MaterialAspect.cxx @@ -20,7 +20,8 @@ // purpose : // ======================================================================= Graphic3d_MaterialAspect::Graphic3d_MaterialAspect() -: myAmbientColor (0.2, 0.2, 0.2, Quantity_TOC_RGB) +: myDiffuseColor (0.2, 0.2, 0.2, Quantity_TOC_RGB), + myAmbientColor (0.2, 0.2, 0.2, Quantity_TOC_RGB) { myRequestedMaterialName = Graphic3d_NOM_DEFAULT; Init (myRequestedMaterialName); @@ -31,7 +32,8 @@ Graphic3d_MaterialAspect::Graphic3d_MaterialAspect() // purpose : // ======================================================================= Graphic3d_MaterialAspect::Graphic3d_MaterialAspect (const Graphic3d_NameOfMaterial theName) -: myAmbientColor (0.2, 0.2, 0.2, Quantity_TOC_RGB) +: myDiffuseColor (0.2, 0.2, 0.2, Quantity_TOC_RGB), + myAmbientColor (0.2, 0.2, 0.2, Quantity_TOC_RGB) { myRequestedMaterialName = theName; Init (myRequestedMaterialName); @@ -56,7 +58,7 @@ void Graphic3d_MaterialAspect::Init (const Graphic3d_NameOfMaterial theName) myEmissiveCoef = 0.0f; myEnvReflexion = 0.0f; myShininess = 0.039f; - myDiffuseColor .SetValues (0.0, 0.0, 0.0, Quantity_TOC_RGB); + myDiffuseColor .SetValues (0.2, 0.2, 0.2, Quantity_TOC_RGB); mySpecularColor.SetValues (1.0, 1.0, 1.0, Quantity_TOC_RGB); myMaterialName = theName; @@ -668,7 +670,9 @@ void Graphic3d_MaterialAspect::SetRefractionIndex (const Standard_Real theValue) // ======================================================================= const Quantity_Color& Graphic3d_MaterialAspect::Color() const { - return myAmbientColor; + // It is generally accepted to consider diffuse color as + // "general" color of a material when light shines on it + return myDiffuseColor; } // ======================================================================= -- 2.39.5