本文整理汇总了C++中GroupPtr::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ GroupPtr::addChild方法的具体用法?C++ GroupPtr::addChild怎么用?C++ GroupPtr::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GroupPtr
的用法示例。
在下文中一共展示了GroupPtr::addChild方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addBasicLightVisualiser
void StandardLightVisualiser::addBasicLightVisualiser( ConstStringDataPtr type, GroupPtr &output, Color3f multiplier, float coneAngle, float penumbraAngle, const std::string *penumbraType, float lensRadius )
{
bool indicatorFaceCamera = false;
if( !type || type->readable() == "point" )
{
output->addChild( const_pointer_cast<IECoreGL::Renderable>( pointRays() ) );
indicatorFaceCamera = true;
}
else if( type->readable() == "spot" )
{
float innerAngle = 0;
float outerAngle = 0;
if( !penumbraType || *penumbraType == "inset" )
{
outerAngle = coneAngle;
innerAngle = coneAngle - 2.0f * penumbraAngle;
}
else if( *penumbraType == "outset" )
{
outerAngle = coneAngle + 2.0f * penumbraAngle;
innerAngle = coneAngle ;
}
else if( *penumbraType == "absolute" )
{
outerAngle = coneAngle;
innerAngle = penumbraAngle;
}
output->addChild( const_pointer_cast<IECoreGL::Renderable>( spotlightCone( innerAngle, outerAngle, lensRadius ) ) );
output->addChild( const_pointer_cast<IECoreGL::Renderable>( ray() ) );
}
else if( type->readable() == "distant" )
{
for ( int i = 0; i < 3; i++ )
{
IECoreGL::GroupPtr rayGroup = new IECoreGL::Group();
Imath::M44f trans;
trans.rotate( V3f( 0, 0, 2.0 * M_PI / 3.0 * i ) );
trans.translate( V3f( 0, 0.4, 0.5 ) );
rayGroup->addChild( const_pointer_cast<IECoreGL::Renderable>( ray() ) );
rayGroup->setTransform( trans );
output->addChild( rayGroup );
}
}
output->addChild( const_pointer_cast<IECoreGL::Renderable>( colorIndicator( multiplier, indicatorFaceCamera ) ) );
}
示例2: addEnvLightVisualiser
void StandardLightVisualiser::addEnvLightVisualiser( GroupPtr &output, Color3f multiplier, const std::string &textureName )
{
IECoreGL::GroupPtr sphereGroup = new IECoreGL::Group();
Imath::M44f trans;
trans.scale( V3f( 1, 1, -1 ) );
trans.rotate( V3f( -0.5 * M_PI, -0.5 * M_PI, 0 ) );
sphereGroup->setTransform( trans );
IECoreGL::SpherePrimitivePtr sphere = new IECoreGL::SpherePrimitive();
sphereGroup->addChild( sphere );
IECore::CompoundObjectPtr parameters = new CompoundObject;
parameters->members()["lightMultiplier"] = new Color3fData( multiplier );
parameters->members()["previewOpacity"] = new FloatData( 1 );
parameters->members()["mapSampler"] = new StringData( textureName );
parameters->members()["defaultColor"] = new Color3fData( Color3f( textureName == "" ? 1.0f : 0.0f ) );
sphereGroup->getState()->add(
new IECoreGL::ShaderStateComponent( ShaderLoader::defaultShaderLoader(), TextureLoader::defaultTextureLoader(), IECoreGL::Shader::defaultVertexSource(), "", environmentLightDrawFragSource(), parameters )
);
sphereGroup->getState()->add(
new IECoreGL::DoubleSidedStateComponent( false )
);
output->addChild( sphereGroup );
}
示例3: doOperation
ObjectPtr CurveExtrudeOp::doOperation( const CompoundObject * operands )
{
CurvesPrimitive * curves = m_curvesParameter->getTypedValue<CurvesPrimitive>();
assert( curves );
assert( curves->arePrimitiveVariablesValid() );
GroupPtr group = new Group();
const IntVectorData * verticesPerCurve = curves->verticesPerCurve();
assert( verticesPerCurve );
unsigned numCurves = verticesPerCurve->readable().size();
unsigned vertexOffset = 0;
unsigned varyingOffset = 0;
for ( unsigned curveIndex = 0; curveIndex < numCurves; curveIndex++ )
{
int numVertices = curves->variableSize( PrimitiveVariable::Vertex, curveIndex );
PatchMeshPrimitivePtr patchMesh = buildPatchMesh( curves, curveIndex, vertexOffset, varyingOffset );
assert( patchMesh );
group->addChild( patchMesh );
vertexOffset += numVertices;
varyingOffset += curves->variableSize( PrimitiveVariable::Varying, curveIndex );
}
assert( group->children().size() == numCurves );
return group;
}
示例4: convertAndAddPrimitive
void FromHoudiniGroupConverter::convertAndAddPrimitive( GU_Detail *geo, GA_PrimitiveGroup *group, GroupPtr &result, const CompoundObject *operands, const std::string &name ) const
{
GU_Detail childGeo( geo, group );
for ( GA_GroupTable::iterator<GA_ElementGroup> it=childGeo.primitiveGroups().beginTraverse(); !it.atEnd(); ++it )
{
it.group()->clear();
}
childGeo.destroyAllEmptyGroups();
PrimitivePtr child = IECore::runTimeCast<Primitive>( doDetailConversion( &childGeo, operands ) );
if ( child )
{
if ( name != "" )
{
child->blindData()->member<StringData>( "name", false, true )->writable() = name;
}
result->addChild( child );
}
}
示例5: doConversion
ObjectPtr FromHoudiniGroupConverter::doConversion( ConstCompoundObjectPtr operands ) const
{
GU_DetailHandleAutoReadLock readHandle( handle() );
const GU_Detail *geo = readHandle.getGdp();
if ( !geo )
{
return 0;
}
size_t numResultPrims = 0;
size_t numOrigPrims = geo->getNumPrimitives();
GroupPtr result = new Group();
if ( operands->member<const IntData>( "groupingMode" )->readable() == NameAttribute )
{
GA_ROAttributeRef attributeRef = geo->findPrimitiveAttribute( "name" );
if ( attributeRef.isInvalid() || !attributeRef.isString() )
{
GU_Detail ungroupedGeo( (GU_Detail*)geo );
GA_PrimitiveGroup *ungrouped = static_cast<GA_PrimitiveGroup*>( ungroupedGeo.createInternalElementGroup( GA_ATTRIB_PRIMITIVE, "FromHoudiniGroupConverter__ungroupedPrimitives" ) );
ungrouped->toggleRange( ungroupedGeo.getPrimitiveRange() );
VisibleRenderablePtr renderable = 0;
doGroupConversion( &ungroupedGeo, ungrouped, renderable, operands );
if ( renderable )
{
Group *group = runTimeCast<Group>( renderable );
if ( group )
{
const Group::ChildContainer &children = group->children();
for ( Group::ChildContainer::const_iterator it = children.begin(); it != children.end(); ++it )
{
result->addChild( *it );
}
}
else
{
result->addChild( renderable );
}
}
return result;
}
GU_Detail groupGeo( (GU_Detail*)geo );
AttributePrimIdGroupMap groupMap;
regroup( &groupGeo, groupMap, attributeRef );
for ( AttributePrimIdGroupMapIterator it=groupMap.begin(); it != groupMap.end(); ++it )
{
convertAndAddPrimitive( &groupGeo, it->second, result, operands, it->first.first );
}
}
else
{
for ( GA_GroupTable::iterator<GA_ElementGroup> it=geo->primitiveGroups().beginTraverse(); !it.atEnd(); ++it )
{
GA_PrimitiveGroup *group = static_cast<GA_PrimitiveGroup*>( it.group() );
if ( group->getInternal() || group->isEmpty() )
{
continue;
}
VisibleRenderablePtr renderable = 0;
numResultPrims += doGroupConversion( geo, group, renderable, operands );
if( !renderable )
{
continue;
}
renderable->blindData()->member<StringData>( "name", false, true )->writable() = group->getName().toStdString();
result->addChild( renderable );
}
if ( numOrigPrims == numResultPrims )
{
return result;
}
GU_Detail ungroupedGeo( (GU_Detail*)geo );
GA_PrimitiveGroup *ungrouped = static_cast<GA_PrimitiveGroup*>( ungroupedGeo.createInternalElementGroup( GA_ATTRIB_PRIMITIVE, "FromHoudiniGroupConverter__ungroupedPrimitives" ) );
for ( GA_GroupTable::iterator<GA_ElementGroup> it=geo->primitiveGroups().beginTraverse(); !it.atEnd(); ++it )
{
*ungrouped |= *static_cast<GA_PrimitiveGroup*>( it.group() );
}
ungrouped->toggleRange( ungroupedGeo.getPrimitiveRange() );
if ( ungrouped->isEmpty() )
{
return result;
}
VisibleRenderablePtr renderable = 0;
doGroupConversion( &ungroupedGeo, ungrouped, renderable, operands );
if ( renderable )
{
result->addChild( renderable );
}
//.........这里部分代码省略.........
示例6: doConversion
ObjectPtr FromHoudiniGroupConverter::doConversion( ConstCompoundObjectPtr operands ) const
{
GroupPtr result = new Group();
if ( operands->member<const IntData>( "groupingMode" )->readable() == NameAttribute )
{
DetailSplitterPtr splitter = new DetailSplitter( handle() );
std::vector<std::string> children;
splitter->values( children );
if ( children.empty() )
{
doUnnamedConversion( GU_DetailHandleAutoReadLock( handle() ).getGdp(), result, operands );
return result;
}
for ( std::vector<std::string>::iterator it = children.begin(); it != children.end(); ++it )
{
const std::string &name = *it;
GU_DetailHandle childHandle = splitter->split( name );
if ( childHandle.isNull() )
{
continue;
}
GU_DetailHandleAutoReadLock readHandle( childHandle );
const GU_Detail *childGeo = readHandle.getGdp();
ObjectPtr child = doDetailConversion( childGeo, operands );
if ( !child )
{
// this happens when mismatched primitives share the same name
doUnnamedConversion( childGeo, result, operands, name );
}
else if ( VisibleRenderablePtr renderable = IECore::runTimeCast<VisibleRenderable>( child ) )
{
if ( name != "" )
{
renderable->blindData()->member<StringData>( "name", false, true )->writable() = name;
}
result->addChild( renderable );
}
}
}
else
{
GU_DetailHandleAutoReadLock readHandle( handle() );
const GU_Detail *geo = readHandle.getGdp();
if ( !geo )
{
return 0;
}
size_t numResultPrims = 0;
size_t numOrigPrims = geo->getNumPrimitives();
for ( GA_GroupTable::iterator<GA_ElementGroup> it=geo->primitiveGroups().beginTraverse(); !it.atEnd(); ++it )
{
GA_PrimitiveGroup *group = static_cast<GA_PrimitiveGroup*>( it.group() );
if ( group->getInternal() || group->isEmpty() )
{
continue;
}
VisibleRenderablePtr renderable = 0;
numResultPrims += doGroupConversion( geo, group, renderable, operands );
if( !renderable )
{
continue;
}
renderable->blindData()->member<StringData>( "name", false, true )->writable() = group->getName().toStdString();
result->addChild( renderable );
}
if ( numOrigPrims == numResultPrims )
{
return result;
}
GU_Detail ungroupedGeo( (GU_Detail*)geo );
GA_PrimitiveGroup *ungrouped = static_cast<GA_PrimitiveGroup*>( ungroupedGeo.createInternalElementGroup( GA_ATTRIB_PRIMITIVE, "FromHoudiniGroupConverter__ungroupedPrimitives" ) );
for ( GA_GroupTable::iterator<GA_ElementGroup> it=geo->primitiveGroups().beginTraverse(); !it.atEnd(); ++it )
{
*ungrouped |= *static_cast<GA_PrimitiveGroup*>( it.group() );
}
ungrouped->toggleRange( ungroupedGeo.getPrimitiveRange() );
if ( ungrouped->isEmpty() )
{
return result;
}
VisibleRenderablePtr renderable = 0;
doGroupConversion( &ungroupedGeo, ungrouped, renderable, operands );
if ( renderable )
{
result->addChild( renderable );
}
}
//.........这里部分代码省略.........