00001 #include "AbstractCurve.h"
00002 #include "Curve.h"
00003 #include "XMLNode.h"
00004
00005 namespace RenderTools {
00006
00007 AbstractCurve::AbstractCurve( void ):
00008 Rendernode( ),
00009 m_interpolationType( LINEAR ),
00010 m_closed( false ){
00011 }
00012
00013 AbstractCurve::~AbstractCurve( void ){
00014
00015 }
00016
00017 PropertyPtr AbstractCurve::create( const XMLNodePtr & xml ){
00018 if( xml ){
00019 string type = xml->getChild( "type" )->getAttrib<string>( "value" );
00020 if( type == "Vec2" ){
00021 CurvePtr p( new Curve< Vec2 >() );
00022 p->setName( xml );
00023 p->createProperties();
00024 p->setProperties( xml, false );
00025 return( dynamic_pointer_cast< AbstractProperty, AbstractCurve >( p ) );
00026 }
00027 else if( type == "Vec3" ){
00028 CurvePtr p( new Curve< Vec3 >() );
00029 p->setName( xml );
00030 p->createProperties();
00031 p->setProperties( xml, false );
00032 return( dynamic_pointer_cast< AbstractProperty, AbstractCurve >( p ) );
00033 }
00034 else if( type == "Vec4" ){
00035 CurvePtr p( new Curve< Vec4 >() );
00036 p->setName( xml );
00037 p->createProperties();
00038 p->setProperties( xml, false );
00039 return( dynamic_pointer_cast< AbstractProperty, AbstractCurve >( p ) );
00040 }
00041 }
00042 CurvePtr p( new Curve< Vec3 >() );
00043 p->setName( xml );
00044 p->createProperties();
00045 p->setProperties( xml, false );
00046 return( dynamic_pointer_cast< AbstractProperty, AbstractCurve >( p ) );
00047 }
00048
00049 const string AbstractCurve::getTypeName( bool ofComponent ) const {
00050 return( "AbstractCurve" );
00051 }
00052
00053 void AbstractCurve::createProperties( void ){
00054 Rendernode::createProperties();
00055 createProperty( this, "type", & m_type );
00056 createProperty( this, "interpolation", InterpolationTypeStruct( & m_interpolationType ), getInterpolationTypeEnums() );
00057 createProperty( this, "subdivision", & m_subdiv );
00058 createProperty( this, "closed", BooleanStruct( & m_closed ) );
00059 }
00060
00061 void AbstractCurve::onInitialize( void ){
00063 update( true );
00064 }
00065
00066 void AbstractCurve::setInterpolationType( InterpolationType t, bool send ){
00067 m_interpolationType = t;
00069 }
00070
00071 void AbstractCurve::setSubdivision( unsigned int s, bool send ){
00072 m_subdiv = s;
00074 }
00075
00076 void AbstractCurve::setClosed( bool state, bool send ){
00077 m_closed = state;
00079 }
00080
00081
00082 };
00083
00084