39 m_Type = WRL1NODES::WRL1_MATERIAL;
48 m_Type = WRL1NODES::WRL1_MATERIAL;
58 wxLogTrace(
traceVrmlPlugin, wxT(
" * [INFO] Destroying Material node." ) );
61 for(
int i = 0; i < 2; ++i )
68 wxLogTrace(
traceVrmlPlugin, wxT(
" * [INFO] destroyed SGCOLOR #%d" ), i );
77 wxCHECK_MSG(
false,
false, wxT(
"AddRefNode is not applicable." ) );
84 wxCHECK_MSG(
false,
false, wxT(
"AddChildNode is not applicable." ) );
90 wxCHECK_MSG( aTopNode,
false, wxT(
"aTopNode is nullptr." ) );
92 char tok = proc.
Peek();
97 " * [INFO] bad file format; unexpected eof %s." ),
107 " * [INFO] bad file format; expecting '{' but got '%s' %s" ),
118 if( proc.
Peek() ==
'}' )
128 __FILE__, __FUNCTION__, __LINE__, proc.
GetError() );
141 if( !glob.compare(
"specularColor" ) )
147 " * [INFO] invalid specularColor %s\n"
148 " * [INFO] file: '%s'\n"
156 else if( !glob.compare(
"diffuseColor" ) )
161 " * [INFO] invalid diffuseColor %s\n"
162 " * [INFO] file: '%s'\n"
163 " * [INFO] error: '%s'." ),
170 else if( !glob.compare(
"emissiveColor" ) )
175 " * [INFO] invalid emissiveColor %s\n"
176 " * [INFO] file: '%s'\n"
184 else if( !glob.compare(
"shininess" ) )
190 " * [INFO] invalid shininess %s\n"
191 " * [INFO] file: '%s'\n"
192 " * [INFO] error: '%s'." ),
193 __FILE__, __FUNCTION__, __LINE__, proc.
GetFileName(),
199 else if( !glob.compare(
"transparency" ) )
205 " * [INFO] invalid transparency %s\n"
206 " * [INFO] file: '%s'\n"
207 " * [INFO] error: '%s'." ),
214 else if( !glob.compare(
"ambientColor" ) )
220 " * [INFO] invalid ambientColor %s\n"
221 " * [INFO] file: '%s'\n"
222 " * [INFO] error: '%s'." ),
232 "* [INFO] bad Material %s.\n"
233 "* [INFO] file: '%s'." ),
247 wxCHECK_MSG( sp,
nullptr, wxT(
"Bad model: no base data given." ) );
260 if( aIndex != 0 && aIndex != 1 )
263 if(
nullptr !=
colors[ aIndex ] )
268 float red, green, blue, val;
366 if(
nullptr == aColor )
377 float dRed, dBlue, dGreen;
378 float eRed, eBlue, eGreen;
379 float aRed, aBlue, aGreen;
380 float sRed, sBlue, sGreen;
383 if( aIndex < 0 || ( aIndex >= (
int)
diffuseColor.size() ) )
431 if( aIndex < 0 || ( aIndex >= (
int)
ambientColor.size() ) )
479 if( aIndex < 0 || ( aIndex >= (
int)
shininess.size() ) )
506 if( aRed + aGreen + aBlue > 0.01f )
509 if( eRed + eGreen + eBlue > 0.01f )
512 if( dRed + dGreen + dBlue > 0.01f )
515 if( ( sRed + sGreen + sBlue ) * shiny > 0.01f )
521 float red, green, blue;
523 red = (eRed + aRed + dRed + sRed * shiny) / n;
524 green = (eGreen + aGreen + dGreen + sGreen * shiny) / n;
525 blue = (eBlue + aBlue + dBlue + sBlue * shiny) / n;
537 else if( aValue > 1.0 )
544 if(
nullptr == aColor )
bool SetDiffuse(float aRVal, float aGVal, float aBVal)
bool SetEmissive(float aRVal, float aGVal, float aBVal)
bool SetSpecular(float aRVal, float aGVal, float aBVal)
bool SetShininess(float aShininess) noexcept
bool SetAmbient(float aRVal, float aGVal, float aBVal)
bool SetTransparency(float aTransparency) noexcept
SGNODE * GetRawPtr(void) noexcept
Function GetRawPtr() returns the raw internal SGNODE pointer.
bool SetColor(float aRedVal, float aGreenVal, float aBlueVal)
The base class of all Scene Graph nodes.
Represent the top node of a VRML1 model.
std::vector< WRLVEC3F > emissiveColor
bool AddChildNode(WRL1NODE *aNode) override
std::vector< WRLVEC3F > ambientColor
void Reclaim(SGNODE *aColor)
Destroy the given color node if it does not have a parent.
bool AddRefNode(WRL1NODE *aNode) override
SGNODE * TranslateToSG(SGNODE *aParent, WRL1STATUS *sp) override
Produce a representation of the data using the intermediate scenegraph structures of the kicad_3dsg l...
void checkRange(float &aValue)
std::vector< WRLVEC3F > diffuseColor
WRL1MATERIAL(NAMEREGISTER *aDictionary)
std::vector< float > transparency
void GetColor(SGCOLOR *aColor, int aIndex)
Compute an SGCOLOR representing the appearance of a vertex or face.
bool Read(WRLPROC &proc, WRL1BASE *aTopNode) override
std::vector< WRLVEC3F > specularColor
std::vector< float > shininess
SGNODE * GetAppearance(int aIndex)
Return an SGAPPEARANCE node representing the appearance for an IndexedFaceSet.
The base class of all VRML1 nodes.
virtual bool AddChildNode(WRL1NODE *aNode)
std::string GetFileName(void)
bool ReadMFFloat(std::vector< float > &aMFFloat)
std::string GetError(void)
bool ReadMFVec3f(std::vector< WRLVEC3F > &aMFVec3f)
bool ReadName(std::string &aName)
std::string GetFilePosition() const
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
collects header files for all SG* wrappers and the API
SGLIB_API SGNODE * GetSGNodeParent(SGNODE *aNode)
SGLIB_API void DestroyNode(SGNODE *aNode) noexcept
Function DestroyNode deletes the given SG* class node.