60 #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) 61 wxLogTrace(
MASK_VRML,
" * [INFO] Destroying Material node\n" );
65 for(
int i = 0; i < 2; ++i )
69 #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) 71 std::ostringstream ostr;
72 ostr <<
" * [INFO] Destroying SGCOLOR #" << i;
73 wxLogTrace(
MASK_VRML,
"%s\n", ostr.str().c_str() );
80 #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) 82 std::ostringstream ostr;
83 ostr <<
" * [INFO] destroyed SGCOLOR #" << i;
84 wxLogTrace(
MASK_VRML,
"%s\n", ostr.str().c_str() );
100 std::ostringstream ostr;
101 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
102 ostr <<
" * [BUG] AddRefNode is not applicable";
103 wxLogTrace(
MASK_VRML,
"%s\n", ostr.str().c_str() );
117 std::ostringstream ostr;
118 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
119 ostr <<
" * [BUG] AddChildNode is not applicable";
120 wxLogTrace(
MASK_VRML,
"%s\n", ostr.str().c_str() );
130 if(
NULL == aTopNode )
134 std::ostringstream ostr;
135 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
136 ostr <<
" * [BUG] aTopNode is NULL";
137 wxLogTrace(
MASK_VRML,
"%s\n", ostr.str().c_str() );
147 char tok = proc.
Peek();
151 #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) 153 std::ostringstream ostr;
154 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
155 ostr <<
" * [INFO] bad file format; unexpected eof at line ";
156 ostr << line <<
", column " << column;
157 wxLogTrace(
MASK_VRML,
"%s\n", ostr.str().c_str() );
166 #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) 168 std::ostringstream ostr;
170 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
171 ostr <<
" * [INFO] bad file format; expecting '{' but got '" << tok;
172 ostr <<
"' at line " << line <<
", column " << column;
173 wxLogTrace(
MASK_VRML,
"%s\n", ostr.str().c_str() );
185 if( proc.
Peek() ==
'}' )
193 #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) 195 std::ostringstream ostr;
196 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
198 wxLogTrace(
MASK_VRML,
"%s\n", ostr.str().c_str() );
215 if( !glob.compare(
"specularColor" ) )
219 #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) 221 std::ostringstream ostr;
222 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
223 ostr <<
" * [INFO] invalid specularColor at line " << line <<
", column ";
224 ostr << column <<
"\n";
225 ostr <<
" * [INFO] file: '" << proc.
GetFileName() <<
"'\n";
226 ostr <<
" * [INFO] message: '" << proc.
GetError() <<
"'";
227 wxLogTrace(
MASK_VRML,
"%s\n", ostr.str().c_str() );
234 else if( !glob.compare(
"diffuseColor" ) )
238 #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) 240 std::ostringstream ostr;
241 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
242 ostr <<
" * [INFO] invalid diffuseColor at line " << line <<
", column ";
243 ostr << column <<
"\n";
244 ostr <<
" * [INFO] file: '" << proc.
GetFileName() <<
"'\n";
245 ostr <<
" * [INFO] message: '" << proc.
GetError() <<
"'";
246 wxLogTrace(
MASK_VRML,
"%s\n", ostr.str().c_str() );
253 else if( !glob.compare(
"emissiveColor" ) )
257 #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) 259 std::ostringstream ostr;
260 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
261 ostr <<
" * [INFO] invalid emissiveColor at line " << line <<
", column ";
262 ostr << column <<
"\n";
263 ostr <<
" * [INFO] file: '" << proc.
GetFileName() <<
"'\n";
264 ostr <<
" * [INFO] message: '" << proc.
GetError() <<
"'";
265 wxLogTrace(
MASK_VRML,
"%s\n", ostr.str().c_str() );
272 else if( !glob.compare(
"shininess" ) )
276 #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) 278 std::ostringstream ostr;
279 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
280 ostr <<
" * [INFO] invalid shininess at line " << line <<
", column ";
281 ostr << column <<
"\n";
282 ostr <<
" * [INFO] file: '" << proc.
GetFileName() <<
"'\n";
283 ostr <<
" * [INFO] message: '" << proc.
GetError() <<
"'";
284 wxLogTrace(
MASK_VRML,
"%s\n", ostr.str().c_str() );
291 else if( !glob.compare(
"transparency" ) )
295 #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) 297 std::ostringstream ostr;
298 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
299 ostr <<
" * [INFO] invalid transparency at line " << line <<
", column ";
300 ostr << column <<
"\n";
301 ostr <<
" * [INFO] file: '" << proc.
GetFileName() <<
"'\n";
302 ostr <<
" * [INFO] message: '" << proc.
GetError() <<
"'";
303 wxLogTrace(
MASK_VRML,
"%s\n", ostr.str().c_str() );
310 else if( !glob.compare(
"ambientColor" ) )
314 #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) 316 std::ostringstream ostr;
317 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
318 ostr <<
" * [INFO] invalid ambientColor at line " << line <<
", column ";
319 ostr << column <<
"\n";
320 ostr <<
" * [INFO] file: '" << proc.
GetFileName() <<
"'\n";
321 ostr <<
" * [INFO] message: '" << proc.
GetError() <<
"'";
322 wxLogTrace(
MASK_VRML,
"%s\n", ostr.str().c_str() );
331 #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) 333 std::ostringstream ostr;
334 ostr << __FILE__ <<
": " << __FUNCTION__ <<
": " << __LINE__ <<
"\n";
335 ostr <<
" * [INFO] bad Material at line " << line <<
", column ";
336 ostr << column <<
"\n";
337 ostr <<
" * [INFO] file: '" << proc.
GetFileName() <<
"'";
338 wxLogTrace(
MASK_VRML,
"%s\n", ostr.str().c_str() );
354 #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) 355 wxLogTrace(
MASK_VRML,
" * [INFO] bad model: no base data given\n" );
372 if( aIndex != 0 && aIndex != 1 )
380 float red, green, blue, val;
489 float dRed, dBlue, dGreen;
490 float eRed, eBlue, eGreen;
491 float aRed, aBlue, aGreen;
492 float sRed, sBlue, sGreen;
495 if( aIndex < 0 || ( aIndex >= (
int)
diffuseColor.size() ) )
543 if( aIndex < 0 || ( aIndex >= (
int)
ambientColor.size() ) )
591 if( aIndex < 0 || ( aIndex >= (
int)
shininess.size() ) )
618 if( aRed + aGreen + aBlue > 0.01f )
621 if( eRed + eGreen + eBlue > 0.01f )
624 if( dRed + dGreen + dBlue > 0.01f )
627 if( ( sRed + sGreen + sBlue ) * shiny > 0.01f )
633 float red, green, blue;
635 red = (eRed + aRed + dRed + sRed * shiny) / n;
636 green = (eGreen + aGreen + dGreen + sGreen * shiny) / n;
637 blue = (eBlue + aBlue + dBlue + sBlue * shiny) / n;
641 aColor->
SetColor( red, green, blue );
651 else if( aValue > 1.0 )
bool ReadMFFloat(std::vector< float > &aMFFloat)
bool ReadMFVec3f(std::vector< WRLVEC3F > &aMFVec3f)
WRL1BASE represents the top node of a VRML1 model.
std::vector< WRLVEC3F > emissiveColor
bool Read(WRLPROC &proc, WRL1BASE *aTopNode) override
bool GetFilePosData(size_t &line, size_t &column)
bool SetTransparency(float aTransparency) noexcept
bool SetDiffuse(float aRVal, float aGVal, float aBVal)
SGLIB_API SGNODE * GetSGNodeParent(SGNODE *aNode)
bool SetColor(float aRedVal, float aGreenVal, float aBlueVal)
The base class of all Scene Graph nodes.
collects header files for all SG* wrappers and the API
SGNODE * GetRawPtr(void) noexcept
Function GetRawPtr() returns the raw internal SGNODE pointer.
void checkRange(float &aValue)
WRL1MATERIAL(NAMEREGISTER *aDictionary)
SGLIB_API void DestroyNode(SGNODE *aNode) noexcept
Function DestroyNode deletes the given SG* class node.
bool SetAmbient(float aRVal, float aGVal, float aBVal)
WRL1NODE represents the base class of all VRML1 nodes.
std::vector< WRLVEC3F > ambientColor
SGNODE * TranslateToSG(SGNODE *aParent, WRL1STATUS *sp) override
Function TranslateToSG produces a representation of the data using the intermediate scenegraph struct...
std::vector< float > shininess
bool SetShininess(float aShininess) noexcept
std::string GetFileName(void)
virtual bool AddChildNode(WRL1NODE *aNode)
SGNODE * GetAppearance(int aIndex)
Function GetAppearance returns an SGAPPEARANCE node representing the appearance for an IndexedFaceSet...
bool SetEmissive(float aRVal, float aGVal, float aBVal)
std::vector< float > transparency
bool SetSpecular(float aRVal, float aGVal, float aBVal)
bool ReadName(std::string &aName)
void GetColor(SGCOLOR *aColor, int aIndex)
Function GetColor computes an SGCOLOR representing the appearance of a vertex or face.
std::vector< WRLVEC3F > specularColor
std::string GetError(void)
bool AddChildNode(WRL1NODE *aNode) override
bool AddRefNode(WRL1NODE *aNode) override
void Reclaim(SGNODE *aColor)
Function Reclaim will destroy the given color node if it does not have a parent.
std::vector< WRLVEC3F > diffuseColor