本文整理汇总了C++中osg::NodeVisitor::getTraversalNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeVisitor::getTraversalNumber方法的具体用法?C++ NodeVisitor::getTraversalNumber怎么用?C++ NodeVisitor::getTraversalNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::NodeVisitor
的用法示例。
在下文中一共展示了NodeVisitor::getTraversalNumber方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
void
OcclusionQueryNode::traverseQuery( const osg::Camera* camera, osg::NodeVisitor& nv )
{
bool issueQuery;
{
const int curFrame = nv.getTraversalNumber();
OpenThreads::ScopedLock<OpenThreads::Mutex> lock( _frameCountMutex );
int& lastQueryFrame = _frameCountMap[ camera ];
if ( issueQuery = (curFrame - lastQueryFrame >= _queryFrameCount) )
lastQueryFrame = curFrame;
}
if (issueQuery)
_queryGeode->accept( nv );
}
示例2: traverse
void SoundNode::traverse(osg::NodeVisitor &nv)
{
// continue only if the visitor actually is a cull visitor
if (nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
{
// Make sure we only execute this once during this frame.
// There could be two or more culls for stereo/multipipe...
if (!m_sound_state.valid()) {
// call the inherited method
osg::notify(osg::DEBUG_INFO) << "SoundNode::traverse() No soundstate attached to soundnode" << std::endl;
Node::traverse(nv);
return;
}
if ( m_sound_state.valid() && nv.getTraversalNumber() != m_last_traversal_number && nv.getFrameStamp())
{
m_last_traversal_number = nv.getTraversalNumber();
// retrieve the current time
double t = nv.getFrameStamp()->getReferenceTime();
double time = t - m_last_time;
if(time >= m_sound_manager->getUpdateFrequency()) {
osg::Matrix m;
m = osg::computeLocalToWorld(nv.getNodePath());
osg::Vec3 pos = m.getTrans();
m_sound_state->setPosition(pos);
//Calculate velocity
osg::Vec3 velocity(0,0,0);
if (m_first_run) {
m_first_run = false;
m_last_time = t;
m_last_pos = pos;
}
else {
velocity = pos - m_last_pos;
m_last_pos = pos;
m_last_time = t;
velocity /= time;
}
if(m_sound_manager->getClampVelocity()) {
float max_vel = m_sound_manager->getMaxVelocity();
float len = velocity.length();
if ( len > max_vel) {
velocity.normalize();
velocity *= max_vel;
}
}
m_sound_state->setVelocity(velocity);
//Get new direction
osg::Vec3 dir(0,1,0);
dir = dir * m;
dir.normalize();
m_sound_state->setDirection(dir);
// Only do occlusion calculations if the sound is playing
if (m_sound_state->getPlay() && m_occlude_callback.valid())
m_occlude_callback->apply(m_sound_manager->getListenerMatrix(), pos, m_sound_state.get());
} // if
}
} // if cullvisitor
// call the inherited method
Node::traverse(nv);
}