00001 #include <assert.h> 00002 #include "debug/debug.h" 00003 #include <stdio.h> 00004 #include "utility.h" 00005 #include "VrmlShape.h" 00006 00007 //============================================================================= 00008 // Parse 00009 // 00010 // Description: Parses the shape node from a file 00011 //============================================================================= 00012 VrmlShape::~VrmlShape() 00013 { 00014 m_Appearance->Release(); 00015 m_Geometry->Release(); 00016 } 00017 00018 //============================================================================= 00019 // Parse 00020 // 00021 // Description: Parses the shape node from a file 00022 //============================================================================= 00023 void VrmlShape::Parse( char*& buffer ) 00024 { 00025 EatWhite( buffer ); 00026 while( *buffer != '}' ) 00027 { 00028 Keyword keyword = VrmlNode::GetKeyword( buffer ); 00029 if( keyword == VRML_Geometry ) 00030 { 00031 Keyword keyword = VrmlNode::GetKeyword( buffer ); 00032 EatWhite( buffer ); 00033 buffer++; 00034 VrmlNode* node = VrmlNode::ParseNode( keyword, buffer ); 00035 this->m_Geometry = node; 00036 this->m_Geometry->AddRef(); 00037 } 00038 else if( keyword == VRML_AppearanceLower ) 00039 { 00040 Keyword keyword = VrmlNode::GetKeyword( buffer ); 00041 EatWhite( buffer ); 00042 buffer++; 00043 VrmlNode* node = VrmlNode::ParseNode( keyword, buffer ); 00044 this->m_Appearance = node; 00045 this->m_Appearance->AddRef(); 00046 } 00047 else 00048 { 00049 printf( "VrmlGroup::Parse - Unknown keyword\n" ); 00050 IJG_Assert( false ); 00051 } 00052 EatWhite( buffer ); 00053 } 00054 00055 //advance past the '}' 00056 EatWhite( buffer ); 00057 buffer++; 00058 } 00059 00060 //============================================================================= 00061 // Render 00062 // 00063 // Description: Reners the node to the stack 00064 //============================================================================= 00065 void VrmlShape::Render( VrmlStack& stack ) const 00066 { 00067 if( this->m_Appearance != NULL ) 00068 { 00069 this->m_Appearance->Render( stack ); 00070 } 00071 00072 if( this->m_Geometry != NULL ) 00073 { 00074 this->m_Geometry->Render( stack ); 00075 } 00076 } 00077 00078 //============================================================================= 00079 // RenderOpenGL 00080 // 00081 // Description: renders this VRML object to OpenGl 00082 //============================================================================= 00083 void VrmlShape::RenderOpenGl( VrmlStack& stack ) const 00084 { 00085 if( this->m_Appearance != NULL ) 00086 { 00087 this->m_Appearance->RenderOpenGl( stack ); 00088 } 00089 00090 if( this->m_Geometry != NULL ) 00091 { 00092 this->m_Geometry->RenderOpenGl( stack ); 00093 } 00094 } 00095 00096 //============================================================================= 00097 // RenderToIGS 00098 // 00099 // Description: renders this VRML object to the faster to process 00100 // IanGraphicsSystem 00101 //============================================================================= 00102 IGS_Object* VrmlShape::RenderToIGS( VrmlStack& stack ) const 00103 { 00104 IGS_Object* returnMe = NULL; 00105 00106 if( this->m_Appearance != NULL ) 00107 { 00108 this->m_Appearance->RenderToIGS( stack ); 00109 } 00110 00111 if( this->m_Geometry != NULL ) 00112 { 00113 returnMe = this->m_Geometry->RenderToIGS( stack ); 00114 } 00115 return returnMe; 00116 }