00001 #include <stdio.h> 00002 #include "utility.h" 00003 #include "VrmlRotation.h" 00004 #include "VrmlTransform.h" 00005 #include "VrmlScale.h" 00006 #include "VrmlScaleOrientation.h" 00007 #include "VrmlStack.h" 00008 #include "VrmlTranslation.h" 00009 00010 //============================================================================= 00011 // Parse 00012 // 00013 // Description: Parses the transform node from the file 00014 //============================================================================= 00015 void VrmlTransform::Parse( char*& buffer ) 00016 { 00017 EatWhite( buffer ); 00018 while( *buffer != '}' ) 00019 { 00020 Keyword keyword = VrmlNode::GetKeyword( buffer ); 00021 00022 EatWhite( buffer ); 00023 if( IsNodeType( keyword ) ) 00024 { 00025 buffer ++; 00026 } 00027 00028 //IAN IMPROVE: change this to a case statement 00029 if( keyword == VRML_Children ) 00030 { 00031 this->m_Children.Parse( buffer ); 00032 } 00033 else if( keyword == VRML_Rotation ) 00034 { 00035 VrmlRotation rotation; 00036 rotation.Parse( buffer ); 00037 this->m_Matrix *= rotation.Matrix(); 00038 } 00039 else if( keyword == VRML_Scale ) 00040 { 00041 VrmlScale scale; 00042 scale.Parse( buffer ); 00043 this->m_Matrix *= scale.Matrix(); 00044 } 00045 else if( keyword == VRML_ScaleOrientation ) 00046 { 00047 VrmlScaleOrientation scaleOrientation; 00048 scaleOrientation.Parse( buffer ); 00049 this->m_Matrix *= scaleOrientation.Matrix(); 00050 } 00051 else if( keyword == VRML_Translation ) 00052 { 00053 VrmlTranslation translation; 00054 translation.Parse( buffer ); 00055 this->m_Matrix *= translation.Matrix(); 00056 } 00057 else 00058 { 00059 assert( false ); 00060 printf( "VrmlGroup::Parse - Unknown keyword\n" ); 00061 } 00062 EatWhite( buffer ); 00063 } 00064 00065 //advance past the '}' 00066 EatWhite( buffer ); 00067 buffer++; 00068 } 00069 00070 //============================================================================= 00071 // Render 00072 // 00073 // Description: Renders the vrml node to the stack 00074 //============================================================================= 00075 void VrmlTransform::Render( VrmlStack& stack ) const 00076 { 00077 stack.m_Matrix = this->m_Matrix; 00078 this->m_Children.Render( stack ); 00079 } 00080 00081 //============================================================================= 00082 // RenderOpenGl 00083 // 00084 // Description: Renders this node to OpenGL 00085 //============================================================================= 00086 void VrmlTransform::RenderOpenGl( VrmlStack& stack ) const 00087 { 00088 VrmlStack substack = stack; 00089 substack.m_Matrix *= this->m_Matrix; 00090 this->m_Children.RenderOpenGl( substack ); 00091 } 00092 00093 //============================================================================= 00094 // RenderToIGS 00095 // 00096 // Description: renders this VRML object to the faster to process 00097 // IanGraphicsSystem 00098 //============================================================================= 00099 IGS_Object* VrmlTransform::RenderToIGS( VrmlStack& stack ) const 00100 { 00101 VrmlStack substack = stack; 00102 substack.m_Matrix *= this->m_Matrix; 00103 return this->m_Children.RenderToIGS( substack ); 00104 }