コード例 #1
0
void IECoreRI::SXRendererImplementation::setOption( const std::string &name, IECore::ConstDataPtr value )
{
	if( name.compare( 0, 3, "ri:" )==0 || name.compare( 0, 3, "sx:" )==0 )
	{
		switch( value->typeId() )
		{
			case IntDataTypeId :
				SxSetOption( m_stateStack.top().context.get(), name.c_str() + 3, SxInt, (void *)&(static_cast<const IntData *>( value.get() )->readable() ) );
				break;
			case FloatDataTypeId :
				SxSetOption( m_stateStack.top().context.get(), name.c_str() + 3, SxFloat, (void *)&(static_cast<const FloatData *>( value.get() )->readable() ) );
				break;
			case StringDataTypeId :
				{
					const char *s = static_cast<const StringData *>( value.get() )->readable().c_str();
					SxSetOption( m_stateStack.top().context.get(), name.c_str() + 3, SxString, &s );
					break;	
				}
			default :
				msg( Msg::Warning, "IECoreRI::SXRendererImplementation::setOption", format( "Unsupport type \"%s\"." ) % value->typeName() );
		}
	}
	else if( name.compare( 0, 5, "user:"******"IECoreRI::SXRendererImplementation::setOption", format( "Unsupport type \"%s\"." ) % value->typeName() );
		}
	}
	else if( name.find_first_of( ":" )!=string::npos )
	{
		// ignore options prefixed for some other renderer
	}
	else
	{
		msg( Msg::Warning, "IECoreRI::SXRendererImplementation::setOption", format( "Unknown option \"%s\"." ) % name );
	}
}
コード例 #2
0
ファイル: ColorTexture.cpp プロジェクト: Shockspot/cortex
void ColorTexture::construct( unsigned int width, unsigned int height, IECore::ConstDataPtr r,
	IECore::ConstDataPtr g, IECore::ConstDataPtr b, IECore::ConstDataPtr a )
{
	if( r->typeId() != g->typeId() ||
		r->typeId() != b->typeId() ||
		( a && (r->typeId() != a->typeId()) ) )
	{
		throw Exception( "Channel types do not match." );
	}

	if( r->typeId()==UCharVectorData::staticTypeId() )
	{
		castConstruct<UCharVectorData>( width, height, r, g, b, a );
	}
	else if( r->typeId()==CharVectorData::staticTypeId() )
	{
		castConstruct<CharVectorData>( width, height, r, g, b, a );
	}
	else if( r->typeId()==UIntVectorData::staticTypeId() )
	{
		castConstruct<UIntVectorData>( width, height, r, g, b, a );
	}
	else if( r->typeId()==IntVectorData::staticTypeId() )
	{
		castConstruct<IntVectorData>( width, height, r, g, b, a );
	}
	else if( r->typeId()==HalfVectorData::staticTypeId() )
	{
		castConstruct<HalfVectorData>( width, height, r, g, b, a );
	}
	else if( r->typeId()==FloatVectorData::staticTypeId() )
	{
		castConstruct<FloatVectorData>( width, height, r, g, b, a );
	}
	else if( r->typeId()==DoubleVectorData::staticTypeId() )
	{
		castConstruct<DoubleVectorData>( width, height, r, g, b, a );
	}
	else {
		throw Exception( boost::str( boost::format( "Unsupported channel type \"%s\"." ) % r->typeName() ) );
	}
}