00001 #include <stdio.h>
00002 #include "VrmlCoordinate3.h"
00003 #include "VrmlStack.h"
00004 #include "Utility.h"
00005
00006
00007
00008
00009
00010
00011 VrmlCoordinate3::VrmlCoordinate3()
00012 {
00013 }
00014
00015
00016
00017
00018
00019
00020 VrmlCoordinate3::VrmlCoordinate3( const VrmlCoordinate3& right )
00021 {
00022 assert( false );
00023 }
00024
00025
00026
00027
00028
00029
00030 VrmlCoordinate3::~VrmlCoordinate3()
00031 {
00032 this->points.clear();
00033 }
00034
00035
00036
00037
00038
00039
00040 const Vector4& VrmlCoordinate3::GetCoordinate( const int i ) const
00041 {
00042 #ifdef _DEBUG
00043 int size = points.size();
00044 assert( size > i );
00045
00046 #endif
00047 assert( points[ i ].Magnitude() < 1000.0 );
00048 return this->points[ i ];
00049 }
00050
00051
00052
00053
00054
00055
00056 void VrmlCoordinate3::Parse( char*& buffer )
00057 {
00058 EatWhite( buffer );
00059 char pointIndicator[ 80 ] = "";
00060 sscanf( buffer, "%s", pointIndicator );
00061 assert( strcmp( pointIndicator, "point" ) == 0 );
00062 buffer += strlen( pointIndicator );
00063 EatWhite( buffer );
00064 assert( *buffer == '[' );
00065 buffer++;
00066
00067 while( *buffer != ']' )
00068 {
00069 float x;
00070 float y;
00071 float z;
00072 sscanf( buffer, "%e%e%e", &x, &y, &z );
00073
00074
00075 Vector4 vector( x, y, z );
00076 assert( vector.Magnitude() < 1000.0 );
00077 this->points.push_back( vector );
00078
00079 int size = points.size();
00080
00081 int position = strcspn( buffer, ",]" );
00082 buffer += position;
00083 if( *buffer == ',' )
00084 {
00085 buffer++;
00086 }
00087 EatWhite( buffer );
00088 }
00089 buffer++;
00090 EatWhite( buffer );
00091 buffer++;
00092 }
00093
00094
00095
00096
00097
00098
00099 void VrmlCoordinate3::Render( VrmlStack& stack ) const
00100 {
00101 int size = points.size();
00102 stack.vrmlCoordinate3 = this;
00103 }