35 ambient.SetColor( 0.05317f, 0.17879f, 0.01804f );
38 diffuse.SetColor( 0.8f, 0.8f, 0.8f );
44 wxLogTrace( MASK_3D_SG,
45 wxT(
"%s:%s:%d * [BUG] inappropriate parent to SGAPPEARANCE (type %s )" ),
46 __FILE__, __FUNCTION__, __LINE__, aParent->GetNodeType() );
50 m_Parent->AddChildNode( this );
73 if(
nullptr == aParent )
92 return emissive.SetColor( aRVal, aGVal, aBVal );
98 wxCHECK_MSG( aRGBColor,
false, wxT(
"NULL pointer passed for aRGBColor" ) );
100 return emissive.SetColor( aRGBColor );
106 return emissive.SetColor( aRGBColor );
112 return diffuse.SetColor( aRVal, aGVal, aBVal );
118 wxCHECK_MSG( aRGBColor,
false, wxT(
"NULL pointer passed for aRGBColor" ) );
120 return diffuse.SetColor( aRGBColor );
126 return diffuse.SetColor( aRGBColor );
132 return specular.SetColor( aRVal, aGVal, aBVal );
138 wxCHECK_MSG( aRGBColor,
false, wxT(
"NULL pointer passed for aRGBColor" ) );
140 return specular.SetColor( aRGBColor );
145 return specular.SetColor( aRGBColor );
151 return ambient.SetColor( aRVal, aGVal, aBVal );
157 wxCHECK_MSG( aRGBColor,
false, wxT(
"NULL pointer passed for aRGBColor" ) );
159 return ambient.SetColor( aRGBColor );
165 return ambient.SetColor( aRGBColor );
171 if(
nullptr == aNodeName || 0 == aNodeName[0] )
174 if( !
m_Name.compare( aNodeName ) )
183 wxCHECK_MSG( aCaller, ,
184 wxT(
"unexpected code branch; node should have no children or refs" ) );
190 wxCHECK_MSG( aCaller, ,
191 wxT(
"unexpected code branch; node should have no children or refs" ) );
197 wxCHECK_MSG( aNode,
false, wxT(
"this node does not accept children or refs" ) );
206 wxCHECK_MSG( aNode,
false, wxT(
"this node does not accept children or refs" ) );
229 aFile <<
" appearance DEF " <<
GetName() <<
" Appearance {\n";
234 aFile <<
" appearance USE " <<
GetName() <<
"\n";
240 aFile <<
" appearance Appearance {\n";
243 aFile <<
" material Material {\n";
246 float ambr, ambg, ambb;
247 ambient.GetColor( ambr, ambg, ambb );
248 float amb = ( 0.212671 * ambr + 0.71516 * ambg + 0.072169 * ambb );
249 diffuse.GetColor( ambr, ambg, ambb );
250 float den = ( 0.212671 * ambr + 0.71516 * ambg + 0.072169 * ambb );
261 aFile <<
" ambientIntensity " << tmp <<
"\n";
266 aFile <<
" diffuseColor " << tmp <<
" ";
270 aFile << tmp <<
"\n";
274 aFile <<
" emissiveColor " << tmp <<
" ";
278 aFile << tmp <<
"\n";
281 aFile <<
" shininess " << tmp <<
"\n";
285 aFile <<
" specularColor " << tmp <<
" ";
289 aFile << tmp <<
"\n";
292 aFile <<
" transparency " << tmp <<
"\n";
302 if(
nullptr == parentNode )
304 wxCHECK_MSG(
m_Parent,
false, wxT(
"corrupt data; m_aParent is NULL" ) );
320 wxCHECK_MSG( parentNode ==
m_Parent,
false, wxT(
"corrupt data; parentNode != m_aParent" ) );
324 wxLogTrace( MASK_3D_SG, wxT(
"%s:%s:%d * [INFO] bad stream" ),
325 __FILE__, __FUNCTION__, __LINE__ );
330 aFile <<
"[" <<
GetName() <<
"]";
SGNODE * FindNode(const char *aNodeName, const SGNODE *aCaller) noexcept override
Search the tree of linked nodes and return a reference to the first node found with the given name.
bool AddRefNode(SGNODE *aNode) noexcept override
bool SetSpecular(float aRVal, float aGVal, float aBVal)
void unlinkRefNode(const SGNODE *aNode) noexcept override
Remove pointers to a referenced node.
bool AddChildNode(SGNODE *aNode) noexcept override
void unlinkChildNode(const SGNODE *aNode) noexcept override
Remove references to an owned child.
SGAPPEARANCE(SGNODE *aParent)
bool SetEmissive(float aRVal, float aGVal, float aBVal)
bool WriteVRML(std::ostream &aFile, bool aReuseFlag) override
Writes this node's data to a VRML file.
bool ReadCache(std::istream &aFile, SGNODE *parentNode) override
Reads binary format data from a cache file.
bool SetDiffuse(float aRVal, float aGVal, float aBVal)
bool SetAmbient(float aRVal, float aGVal, float aBVal)
bool WriteCache(std::ostream &aFile, SGNODE *parentNode) override
Write this node's data to a binary cache file.
void ReNameNodes(void) override
Rename a node and all its child nodes in preparation for write operations.
virtual bool SetParent(SGNODE *aParent, bool notify=true) override
Set the parent SGNODE of this object.
virtual bool WriteCache(std::ostream &aFile, SGNODE *parentNode)=0
Write this node's data to a binary cache file.
const char * GetName(void)
SGNODE * GetParent(void) const noexcept
Returns a pointer to the parent SGNODE of this object or NULL if the object has no parent (ie.
S3D::SGTYPES GetNodeType(void) const noexcept
Return the type of this node instance.
SGNODE * m_Parent
Pointer to parent node; may be NULL for top level transform.
std::string m_Name
name to use for referencing the entity by name.
bool m_written
Set to true when the object has been written after a ReNameNodes().
S3D::SGTYPES m_SGtype
Type of Scene Graph node.
bool WriteColor(std::ostream &aFile, const SGCOLOR &aColor)
void FormatFloat(std::string &result, double value)
bool ReadColor(std::istream &aFile, SGCOLOR &aColor)
Define a number of macros to aid in repetitious code which is probably best expressed as a preprocess...