本文整理汇总了C++中sceneplug::ScenePath类的典型用法代码示例。如果您正苦于以下问题:C++ ScenePath类的具体用法?C++ ScenePath怎么用?C++ ScenePath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ScenePath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pathFromSelectionIdWalk
bool pathFromSelectionIdWalk( GLuint selectionId, ScenePlug::ScenePath &path ) const
{
if( m_selectionId == selectionId )
{
path.push_back( m_name );
return true;
}
else
{
for( std::vector<SceneGraph *>::const_iterator it = m_children.begin(), eIt = m_children.end(); it != eIt; ++it )
{
/// \todo Should be able to prune recursion based on knowledge that child
/// selection ids are always greater than parent selection ids.
if( (*it)->pathFromSelectionIdWalk( selectionId, path ) )
{
if( m_name != IECore::InternedString() )
{
path.push_back( m_name );
}
return true;
}
}
}
return false;
}
示例2: pathFromSelectionId
bool pathFromSelectionId( GLuint selectionId, ScenePlug::ScenePath &path ) const
{
path.clear();
const bool result = pathFromSelectionIdWalk( selectionId, path );
std::reverse( path.begin(), path.end() );
return result;
}
示例3: scopedContext
virtual task *execute()
{
ContextPtr context = new Context( *m_context );
context->set( ScenePlug::scenePathContextName, m_scenePath );
Context::Scope scopedContext( context );
m_scenePlug->transformPlug()->getValue();
m_scenePlug->boundPlug()->getValue();
m_scenePlug->attributesPlug()->getValue();
m_scenePlug->objectPlug()->getValue();
ConstInternedStringVectorDataPtr childNamesData = m_scenePlug->childNamesPlug()->getValue();
const vector<InternedString> &childNames = childNamesData->readable();
set_ref_count( 1 + childNames.size() );
ScenePlug::ScenePath childPath = m_scenePath;
childPath.push_back( InternedString() ); // space for the child name
for( vector<InternedString>::const_iterator it = childNames.begin(), eIt = childNames.end(); it != eIt; it++ )
{
childPath[m_scenePath.size()] = *it;
SceneTraversalTask *t = new( allocate_child() ) SceneTraversalTask( m_scenePlug, m_context, childPath );
spawn( *t );
}
wait_for_all();
return 0;
}
示例4: operator
void operator()( const tbb::blocked_range<int> &range ) const
{
for( int i=range.begin(); i!=range.end(); ++i )
{
ScenePlug::ScenePath childScenePath = m_parent.m_scenePath;
childScenePath.push_back( m_childNames[i] );
SceneProceduralPtr sceneProcedural = new SceneProcedural( m_parent, childScenePath );
m_childProcedurals[ i ] = sceneProcedural;
}
}
示例5: applySelectionWalk
void applySelectionWalk( const PathMatcher &selection, const ScenePlug::ScenePath &path, bool check )
{
const unsigned m = check ? selection.match( path ) : 0;
m_selected = m & Filter::ExactMatch;
ScenePlug::ScenePath childPath = path;
childPath.push_back( IECore::InternedString() ); // space for the child name
for( std::vector<SceneGraph *>::const_iterator it = m_children.begin(), eIt = m_children.end(); it != eIt; ++it )
{
childPath.back() = (*it)->m_name;
(*it)->applySelectionWalk( selection, childPath, m & Filter::DescendantMatch );
}
}
示例6: computeSet
GafferScene::ConstPathMatcherDataPtr BranchCreator::computeSet( const IECore::InternedString &setName, const Gaffer::Context *context, const ScenePlug *parent ) const
{
ConstPathMatcherDataPtr inputSetData = inPlug()->set( setName );
ConstCompoundDataPtr mapping = boost::static_pointer_cast<const CompoundData>( mappingPlug()->getValue() );
if( !mapping->readable().size() )
{
return inputSetData;
}
ScenePlug::ScenePath parentPath = mapping->member<InternedStringVectorData>( g_parentKey )->readable();
ConstPathMatcherDataPtr branchSetData = computeBranchSet( parentPath, setName, context );
if( !branchSetData )
{
return inputSetData;
}
const PathMatcher &branchSet = branchSetData->readable();
if( branchSet.isEmpty() )
{
return inputSetData;
}
const CompoundData *forwardMapping = mapping->member<CompoundData>( g_forwardMappingKey );
PathMatcherDataPtr outputSetData = inputSetData->copy();
PathMatcher &outputSet = outputSetData->writable();
vector<InternedString> outputPrefix( parentPath );
for( PathMatcher::RawIterator pIt = branchSet.begin(), peIt = branchSet.end(); pIt != peIt; ++pIt )
{
const ScenePlug::ScenePath &branchPath = *pIt;
if( !branchPath.size() )
{
continue; // Skip root
}
assert( branchPath.size() == 1 );
const InternedStringData *outputName = forwardMapping->member<InternedStringData>( branchPath[0], /* throwExceptions = */ true );
outputPrefix.resize( parentPath.size() + 1 );
outputPrefix.back() = outputName->readable();
outputSet.addPaths( branchSet.subTree( *pIt ), outputPrefix );
pIt.prune(); // We only want to visit the first level
}
return outputSetData;
}
示例7: pathToString
void ScenePlug::pathToString( const ScenePlug::ScenePath &path, std::string &s )
{
if( !path.size() )
{
s = "/";
}
else
{
s.clear();
for( ScenePlug::ScenePath::const_iterator it = path.begin(), eIt = path.end(); it != eIt; it++ )
{
s += "/" + it->string();
}
}
}
示例8: path
void path( ScenePlug::ScenePath &p )
{
if( !m_parent )
{
return;
}
m_parent->path( p );
p.push_back( m_name );
}
示例9: stringToPath
void ScenePlug::stringToPath( const std::string &s, ScenePlug::ScenePath &path )
{
typedef boost::tokenizer<boost::char_separator<char> > Tokenizer;
Tokenizer tokenizer( s, boost::char_separator<char>( "/" ) );
for( Tokenizer::const_iterator it = tokenizer.begin(), eIt = tokenizer.end(); it != eIt; it++ )
{
path.push_back( *it );
}
}
示例10: updateShadersWalk
void InteractiveRender::updateShadersWalk( const ScenePlug::ScenePath &path )
{
/// \todo Keep a track of the hashes of the shaders at each path,
/// and use it to only update the shaders when they've changed.
ConstCompoundObjectPtr attributes = inPlug()->attributes( path );
// terminate recursion for invisible locations
ConstBoolDataPtr visibility = attributes->member<BoolData>( SceneInterface::visibilityName );
if( visibility && ( !visibility->readable() ) )
{
return;
}
ConstObjectVectorPtr shader = attributes->member<ObjectVector>( "shader" );
if( shader )
{
std::string name;
ScenePlug::pathToString( path, name );
CompoundDataMap parameters;
parameters["exactscopename"] = new StringData( name );
{
EditBlock edit( m_renderer.get(), "attribute", parameters );
for( ObjectVector::MemberContainer::const_iterator it = shader->members().begin(), eIt = shader->members().end(); it != eIt; it++ )
{
const StateRenderable *s = runTimeCast<const StateRenderable>( it->get() );
if( s )
{
s->render( m_renderer.get() );
}
}
}
}
ConstInternedStringVectorDataPtr childNames = inPlug()->childNames( path );
ScenePlug::ScenePath childPath = path;
childPath.push_back( InternedString() ); // for the child name
for( vector<InternedString>::const_iterator it=childNames->readable().begin(); it!=childNames->readable().end(); it++ )
{
childPath[path.size()] = *it;
updateShadersWalk( childPath );
}
}
示例11: expandWalk
bool SceneView::expandWalk( const GafferScene::ScenePlug::ScenePath &path, size_t depth, PathMatcher &expanded, PathMatcher &selected )
{
bool result = false;
ConstInternedStringVectorDataPtr childNamesData = preprocessedInPlug<ScenePlug>()->childNames( path );
const vector<InternedString> &childNames = childNamesData->readable();
if( childNames.size() )
{
// expand ourselves to show our children, and make sure we're
// not selected - we only want selection at the leaf levels of
// our expansion.
result |= expanded.addPath( path );
result |= selected.removePath( path );
ScenePlug::ScenePath childPath = path;
childPath.push_back( InternedString() ); // room for the child name
for( vector<InternedString>::const_iterator cIt = childNames.begin(), ceIt = childNames.end(); cIt != ceIt; cIt++ )
{
childPath.back() = *cIt;
if( depth == 1 )
{
// at the bottom of the expansion - just select the child
result |= selected.addPath( childPath );
}
else
{
// continue the expansion
result |= expandWalk( childPath, depth - 1, expanded, selected );
}
}
}
else
{
// we have no children, just make sure we're selected to mark the
// leaf of the expansion.
result |= selected.addPath( path );
}
return result;
}
示例12:
const TransformTool::Selection &CameraTool::cameraSelection()
{
if( !m_cameraSelectionDirty )
{
return m_cameraSelection;
}
m_cameraSelection = TransformTool::Selection();
ScenePlug::ScenePath cameraPath = this->cameraPath();
if( !cameraPath.empty() )
{
m_cameraSelection = TransformTool::Selection(
scenePlug(),
cameraPath,
view()->getContext()
);
}
m_cameraSelectionDirty = false;
return m_cameraSelection;
}
示例13: collapseSelection
void SceneView::collapseSelection()
{
PathMatcher &selection = const_cast<GafferScene::PathMatcherData *>( m_sceneGadget->getSelection() )->writable();
std::vector<string> toCollapse;
selection.paths( toCollapse );
if( !toCollapse.size() )
{
return;
}
GafferScene::PathMatcherData *expandedData = expandedPaths();
PathMatcher &expanded = expandedData->writable();
for( vector<string>::const_iterator it = toCollapse.begin(), eIt = toCollapse.end(); it != eIt; ++it )
{
/// \todo It would be nice to be able to get ScenePaths out of
/// PathMatcher::paths() directly.
ScenePlug::ScenePath path;
ScenePlug::stringToPath( *it, path );
if( !expanded.removePath( path ) )
{
if( path.size() <= 1 )
{
continue;
}
selection.removePath( path );
path.pop_back(); // now the parent path
expanded.removePath( path );
selection.addPath( path );
}
}
// See comment in expandSelection().
getContext()->changedSignal()( getContext(), "ui:scene:expandedPaths" );
// See comment in expandSelection().
transferSelectionToContext();
}
示例14: writeLocation
void SceneWriter::writeLocation( const GafferScene::ScenePlug *scene, const ScenePlug::ScenePath &scenePath, Context *context, IECore::SceneInterface *output, double time ) const
{
context->set( ScenePlug::scenePathContextName, scenePath );
ConstCompoundObjectPtr attributes = scene->attributesPlug()->getValue();
for( CompoundObject::ObjectMap::const_iterator it = attributes->members().begin(), eIt = attributes->members().end(); it != eIt; it++ )
{
output->writeAttribute( it->first, it->second.get(), time );
}
if( scenePath.empty() )
{
ConstCompoundObjectPtr globals = scene->globalsPlug()->getValue();
output->writeAttribute( "gaffer:globals", globals.get(), time );
}
ConstObjectPtr object = scene->objectPlug()->getValue();
if( object->typeId() != IECore::NullObjectTypeId && scenePath.size() > 0 )
{
output->writeObject( object.get(), time );
}
Imath::Box3f b = scene->boundPlug()->getValue();
output->writeBound( Imath::Box3d( Imath::V3f( b.min ), Imath::V3f( b.max ) ), time );
if( scenePath.size() )
{
Imath::M44f t = scene->transformPlug()->getValue();
Imath::M44d transform(
t[0][0], t[0][1], t[0][2], t[0][3],
t[1][0], t[1][1], t[1][2], t[1][3],
t[2][0], t[2][1], t[2][2], t[2][3],
t[3][0], t[3][1], t[3][2], t[3][3]
);
output->writeTransform( new IECore::M44dData( transform ), time );
}
ConstInternedStringVectorDataPtr childNames = scene->childNamesPlug()->getValue();
ScenePlug::ScenePath childScenePath = scenePath;
childScenePath.push_back( InternedString() );
for( vector<InternedString>::const_iterator it=childNames->readable().begin(); it!=childNames->readable().end(); it++ )
{
childScenePath[scenePath.size()] = *it;
SceneInterfacePtr outputChild = output->child( *it, SceneInterface::CreateIfMissing );
writeLocation( scene, childScenePath, context, outputChild.get(), time );
}
}
示例15: pathScope
bool GafferScene::SceneAlgo::exists( const ScenePlug *scene, const ScenePlug::ScenePath &path )
{
ScenePlug::PathScope pathScope( Context::current() );
ScenePlug::ScenePath p; p.reserve( path.size() );
for( ScenePlug::ScenePath::const_iterator it = path.begin(), eIt = path.end(); it != eIt; ++it )
{
pathScope.setPath( p );
ConstInternedStringVectorDataPtr childNamesData = scene->childNamesPlug()->getValue();
const vector<InternedString> &childNames = childNamesData->readable();
if( find( childNames.begin(), childNames.end(), *it ) == childNames.end() )
{
return false;
}
p.push_back( *it );
}
return true;
}