当前位置: 首页>>代码示例>>C++>>正文


C++ GroupPtr::setTransform方法代码示例

本文整理汇总了C++中GroupPtr::setTransform方法的典型用法代码示例。如果您正苦于以下问题:C++ GroupPtr::setTransform方法的具体用法?C++ GroupPtr::setTransform怎么用?C++ GroupPtr::setTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GroupPtr的用法示例。


在下文中一共展示了GroupPtr::setTransform方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: transformObject

ConstObjectPtr SOP_SceneCacheSource::transformObject( const IECore::Object *object, const Imath::M44d &transform, bool &hasAnimatedTopology, bool &hasAnimatedPrimVars, std::vector<InternedString> &animatedPrimVars )
{
	if ( const Primitive *primitive = IECore::runTimeCast<const Primitive>( object ) )
	{
		TransformOpPtr transformer = new TransformOp();
		transformer->inputParameter()->setValue( const_cast<Primitive*>( primitive ) ); // safe because we set the copy parameter
		transformer->copyParameter()->setTypedValue( true );
		transformer->matrixParameter()->setValue( new M44dData( transform ) );
		ObjectPtr result = transformer->operate();
		
		std::vector<std::string> &primVars = transformer->primVarsParameter()->getTypedValue();
		for ( std::vector<std::string>::iterator it = primVars.begin(); it != primVars.end(); ++it )
		{
			if ( std::find( animatedPrimVars.begin(), animatedPrimVars.end(), *it ) == animatedPrimVars.end() )
			{
				animatedPrimVars.push_back( *it );
				hasAnimatedPrimVars = true;
			}
		}
		
		return result;
	}
	else if ( const Group *group = IECore::runTimeCast<const Group>( object ) )
	{
		GroupPtr result = group->copy();
		MatrixTransformPtr matTransform = matrixTransform( transform );
		matTransform->matrix *= group->getTransform()->transform();
		result->setTransform( matTransform );
		return result;
	}
	else if ( const CoordinateSystem *coord = IECore::runTimeCast<const CoordinateSystem>( object ) )
	{
		CoordinateSystemPtr result = coord->copy();
		MatrixTransformPtr matTransform = matrixTransform( transform );
		matTransform->matrix *= coord->getTransform()->transform();
		result->setTransform( matTransform );
		return result;
	}
	
	return object;
}
开发者ID:pombredanne,项目名称:cortex,代码行数:41,代码来源:SOP_SceneCacheSource.cpp

示例2: transformObject

ConstObjectPtr SOP_SceneCacheSource::transformObject( const IECore::Object *object, const Imath::M44d &transform, Parameters &params )
{
	if ( const Primitive *primitive = IECore::runTimeCast<const Primitive>( object ) )
	{
		TransformOpPtr transformer = new TransformOp();
		transformer->inputParameter()->setValue( const_cast<Primitive*>( primitive ) ); // safe because we set the copy parameter
		transformer->copyParameter()->setTypedValue( true );
		transformer->matrixParameter()->setValue( new M44dData( transform ) );
		
		// add all Point and Normal prim vars to the transformation list, except for rest/Pref
		const PrimitiveVariableMap &variables = primitive->variables;
		std::vector<std::string> &primVars = transformer->primVarsParameter()->getTypedValue();
		primVars.clear();
		for ( PrimitiveVariableMap::const_iterator it = variables.begin(); it != variables.end(); ++it )
		{
			if ( despatchTypedData<TransformGeometricData, IECore::TypeTraits::IsGeometricTypedData, DespatchTypedDataIgnoreError>( it->second.data.get() ) )
			{
				// we don't want to alter rest/Pref because Houdini excepts these to be non-transforming prim vars
				if ( it->first == "rest" || it->first == "Pref" )
				{
					continue;
				}
				
				primVars.push_back( it->first );
				
				// add the transforming prim vars to the animated list
				if ( std::find( params.animatedPrimVars.begin(), params.animatedPrimVars.end(), it->first ) == params.animatedPrimVars.end() )
				{
					params.animatedPrimVars.push_back( it->first );
					params.hasAnimatedPrimVars = true;
				}
			}
		}
		
		return transformer->operate();
	}
	else if ( const Group *group = IECore::runTimeCast<const Group>( object ) )
	{
		GroupPtr result = group->copy();
		MatrixTransformPtr matTransform = matrixTransform( transform );
		if ( const Transform *transform = group->getTransform() )
		{
			matTransform->matrix *= transform->transform();
		}
		result->setTransform( matTransform );
		return result;
	}
	else if ( const CoordinateSystem *coord = IECore::runTimeCast<const CoordinateSystem>( object ) )
	{
		CoordinateSystemPtr result = coord->copy();
		MatrixTransformPtr matTransform = matrixTransform( transform );
		if ( const Transform *transform = coord->getTransform() )
		{
			matTransform->matrix *= transform->transform();
		}
		result->setTransform( matTransform );
		return result;
	}
	
	return object;
}
开发者ID:mattigruener,项目名称:cortex,代码行数:61,代码来源:SOP_SceneCacheSource.cpp

示例3: visualise

IECoreGL::ConstRenderablePtr StandardLightVisualiser::visualise( const IECore::InternedString &attributeName, const IECore::ObjectVector *shaderVector, IECoreGL::ConstStatePtr &state ) const
{
    if( !shaderVector || shaderVector->members().size() == 0 )
    {
        return NULL;
    }

    IECore::InternedString metadataTarget;
    const IECore::CompoundData *shaderParameters = NULL;
    if( const IECore::Shader *shader = IECore::runTimeCast<const IECore::Shader>( shaderVector->members().back().get() ) )
    {
        metadataTarget = attributeName.string() + ":" + shader->getName();
        shaderParameters = shader->parametersData();
    }
    else if( const IECore::Light *light = IECore::runTimeCast<const IECore::Light>( shaderVector->members().back().get() ) )
    {
        /// \todo Remove once all Light node derived classes are
        /// creating only shaders.
        metadataTarget = attributeName.string() + ":" + light->getName();
        shaderParameters = light->parametersData().get();
    }

    if( !shaderParameters )
    {
        return NULL;
    }

    ConstStringDataPtr type = Metadata::value<StringData>( metadataTarget, "type" );
    ConstM44fDataPtr orientation = Metadata::value<M44fData>( metadataTarget, "visualiserOrientation" );

    const Color3f color = parameter<Color3f>( metadataTarget, shaderParameters, "colorParameter", Color3f( 1.0f ) );
    const float intensity = parameter<float>( metadataTarget, shaderParameters, "intensityParameter", 1 );
    const float exposure = parameter<float>( metadataTarget, shaderParameters, "exposureParameter", 0 );

    const Color3f finalColor = color * intensity * pow( 2.0f, exposure );

    if( type && type->readable() == "area" )
    {
        const std::string textureName = parameter<std::string>( metadataTarget, shaderParameters, "textureNameParameter", "" );
        const bool flipNormal = parameter<bool>( metadataTarget, shaderParameters, "flipNormalParameter", 0 );
        const bool doubleSided = parameter<bool>( metadataTarget, shaderParameters, "doubleSidedParameter", 0 );
        const bool sphericalProjection = parameter<bool>( metadataTarget, shaderParameters, "sphericalProjectionParameter", 0 );

        M44f projectionTransform = parameter<M44f>( metadataTarget, shaderParameters, "projectionTransformParameter", M44f() );
        const std::vector<float> projectionTransformVector = parameter<std::vector<float> >( metadataTarget, shaderParameters, "projectionTransformParameter", std::vector<float>() );
        if( projectionTransformVector.size() == 16 )
        {
            projectionTransform = M44f( (float(*)[4])(&projectionTransformVector[0]) );
        }
        addAreaLightVisualiser( state, finalColor, textureName, flipNormal, doubleSided,
                                sphericalProjection, projectionTransform );
        return NULL;
    }

    GroupPtr result = new Group;

    const float locatorScale = parameter<float>( metadataTarget, shaderParameters, "locatorScaleParameter", 1 );
    Imath::M44f topTrans;
    if( orientation )
    {
        topTrans = orientation->readable();
    }
    topTrans.scale( V3f( locatorScale ) );
    result->setTransform( topTrans );

    if( type && type->readable() == "environment" )
    {
        const std::string textureName = parameter<std::string>( metadataTarget, shaderParameters, "textureNameParameter", "" );
        addEnvLightVisualiser( result, finalColor, textureName );
    }
    else
    {
        float coneAngle = parameter<float>( metadataTarget, shaderParameters, "coneAngleParameter", 0.0f );
        float penumbraAngle = parameter<float>( metadataTarget, shaderParameters, "penumbraAngleParameter", 0.0f );

        if( ConstStringDataPtr angleUnit = Metadata::value<StringData>( metadataTarget, "angleUnit" ) )
        {
            if( angleUnit->readable() == "radians" )
            {
                coneAngle *= 180.0 / M_PI;
                penumbraAngle *= 180 / M_PI;
            }
        }

        const std::string *penumbraType = NULL;
        ConstStringDataPtr penumbraTypeData = Metadata::value<StringData>( metadataTarget, "penumbraType" );
        if( penumbraTypeData )
        {
            penumbraType = &penumbraTypeData->readable();
        }


        float lensRadius = 0.0f;
        if( parameter<bool>( metadataTarget, shaderParameters, "lensRadiusEnableParameter", true ) )
        {
            lensRadius = parameter<float>( metadataTarget, shaderParameters, "lensRadiusParameter", 0.0f );
        }

        addBasicLightVisualiser( type, result, finalColor, coneAngle, penumbraAngle, penumbraType, lensRadius / locatorScale );
    }
//.........这里部分代码省略.........
开发者ID:HughMacdonald,项目名称:gaffer,代码行数:101,代码来源:StandardLightVisualiser.cpp


注:本文中的GroupPtr::setTransform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。