本文整理汇总了C++中osg::observer_ptr类的典型用法代码示例。如果您正苦于以下问题:C++ observer_ptr类的具体用法?C++ observer_ptr怎么用?C++ observer_ptr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了observer_ptr类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onMapModelChanged
void onMapModelChanged( const MapModelChange& change )
{
osg::ref_ptr<TerrainEngineNode> safeNode = _node.get();
if ( safeNode.valid() )
safeNode->onMapModelChanged( change );
}
示例2: onMapInfoEstablished
void onMapInfoEstablished( const MapInfo& mapInfo ) {
_node->onMapInfoEstablished( mapInfo );
}
示例3: onMapModelChanged
void onMapModelChanged( const MapModelChange& change ) {
_node->onMapModelChanged( change );
}
示例4: onMapInfoEstablished
void onMapInfoEstablished( const MapInfo& mapInfo )
{
osg::ref_ptr<TerrainEngineNode> safeNode = _node.get();
if ( safeNode.valid() )
safeNode->onMapInfoEstablished( mapInfo );
}
示例5: instance
SlideEventHandler* SlideEventHandler::instance() { return s_seh.get(); }
示例6: onMapModelChanged
void onMapModelChanged( const MapModelChange& change )
{
osg::ref_ptr<TerrainEngineNode> safeNode;
if (_node.lock(safeNode))
safeNode->onMapModelChanged( change );
}
示例7: onMapInfoEstablished
void onMapInfoEstablished( const MapInfo& mapInfo )
{
osg::ref_ptr<TerrainEngineNode> safeNode;
if (_node.lock(safeNode))
safeNode->onMapInfoEstablished( mapInfo );
}
示例8: play
void SDLAudioSink::play()
{
if (_started)
{
if (_paused)
{
SDL_PauseAudio(0);
_paused = false;
}
return;
}
_started = true;
_paused = false;
osg::notify(osg::NOTICE)<<"SDLAudioSink()::startPlaying()"<<std::endl;
osg::notify(osg::NOTICE)<<" audioFrequency()="<<_audioStream->audioFrequency()<<std::endl;
osg::notify(osg::NOTICE)<<" audioNbChannels()="<<_audioStream->audioNbChannels()<<std::endl;
osg::notify(osg::NOTICE)<<" audioSampleFormat()="<<_audioStream->audioSampleFormat()<<std::endl;
SDL_AudioSpec specs = { 0 };
SDL_AudioSpec wanted_specs = { 0 };
wanted_specs.freq = _audioStream->audioFrequency();
wanted_specs.channels = _audioStream->audioNbChannels();
wanted_specs.silence = 0;
wanted_specs.samples = 1024;
wanted_specs.callback = soundReadCallback;
wanted_specs.userdata = this;
wanted_specs.format = 0;
#if SDL_MAJOR_VERSION>=2
switch(_audioStream->audioSampleFormat())
{
case(osg::AudioStream::SAMPLE_FORMAT_U8): { wanted_specs.format = AUDIO_U8; OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_U8"<<std::endl; break;}
case(osg::AudioStream::SAMPLE_FORMAT_S16): { wanted_specs.format = AUDIO_S16SYS; OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_S16"<<std::endl; break; }
case(osg::AudioStream::SAMPLE_FORMAT_S24): { OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_S24 NOT Supported by SDL."<<std::endl; break; }
case(osg::AudioStream::SAMPLE_FORMAT_S32): { wanted_specs.format = AUDIO_S32SYS; OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_S32"<<std::endl; break; }
case(osg::AudioStream::SAMPLE_FORMAT_F32): { wanted_specs.format = AUDIO_F32SYS; OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_F32"<<std::endl; break; }
}
#else
switch(_audioStream->audioSampleFormat())
{
case(osg::AudioStream::SAMPLE_FORMAT_U8): { wanted_specs.format = AUDIO_U8; OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_U8"<<std::endl; break;}
case(osg::AudioStream::SAMPLE_FORMAT_S16): { wanted_specs.format = AUDIO_S16SYS; OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_S16"<<std::endl; break; }
case(osg::AudioStream::SAMPLE_FORMAT_S24): { OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_S24 NOT Supported by SDL1.x."<<std::endl; break; }
case(osg::AudioStream::SAMPLE_FORMAT_S32): { OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_S32 NOT Supported by SDL1.x"<<std::endl; break; }
case(osg::AudioStream::SAMPLE_FORMAT_F32): { OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_F32 NOT Supported by SDL1.x"<<std::endl; break; }
}
#endif
if (wanted_specs.format!=0)
{
if (SDL_OpenAudio(&wanted_specs, &specs) < 0)
throw "SDL_OpenAudio() failed (" + std::string(SDL_GetError()) + ")";
SDL_PauseAudio(0);
}
else
{
throw "SDL_OpenAudio() does not support audio format";
}
}
示例9: handle
bool MovieEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor* /*nv*/)
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::MOVE):
{
if(_currentImageStream.valid() && (ea.getModKeyMask() & osgGA::GUIEventAdapter::MODKEY_SHIFT))
{
float scalar = (ea.getXnormalized()+1) / 2.0;
_currentImageStream->seek(scalar * _currentImageStream->getLength());
}
}
break;
case(osgGA::GUIEventAdapter::RELEASE):
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
osgUtil::LineSegmentIntersector::Intersections intersections;
bool foundIntersection = view==0 ? false : view->computeIntersections(ea, intersections);
if (foundIntersection)
{
// use the nearest intersection
const osgUtil::LineSegmentIntersector::Intersection& intersection = *(intersections.begin());
osg::Drawable* drawable = intersection.drawable.get();
osg::Geometry* geometry = drawable ? drawable->asGeometry() : 0;
if (geometry) {
osg::Texture* tex = geometry->getStateSet() ? dynamic_cast<osg::Texture*>(geometry->getStateSet()->getTextureAttribute(0, osg::StateAttribute::TEXTURE)) : NULL;
if (tex) {
osg::ImageStream* is = dynamic_cast<osg::ImageStream*>(tex->getImage(0));
if (is)
{
setColor(_currentGeometry.get(), osg::Vec4(0.7, 0.7, 0.7, 1.0));
_currentGeometry = geometry;
setColor(_currentGeometry.get(), osg::Vec4(1,1,1,1));
_currentImageStream = is;
if (is->getStatus() == osg::ImageStream::PLAYING)
{
is->pause();
}
else
{
is->play();
}
}
}
}
}
break;
}
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (!_currentImageStream.valid())
return false;
if (ea.getKey()=='p')
{
osg::ImageStream::StreamStatus playToggle = _currentImageStream->getStatus();
if (playToggle != osg::ImageStream::PLAYING)
{
std::cout<< _currentImageStream.get() << " Play"<<std::endl;
_currentImageStream->play();
}
else
{
// playing, so pause
std::cout<< _currentImageStream.get() << " Pause"<<std::endl;
_currentImageStream->pause();
}
return true;
}
else if (ea.getKey()=='r')
{
std::cout<< _currentImageStream.get() << " Restart"<<std::endl;
_currentImageStream->rewind();
_currentImageStream->play();
return true;
}
else if (ea.getKey()=='>')
{
std::cout << _currentImageStream.get() << " Seeking"<<std::endl;
_currentImageStream->seek(_currentImageStream->getCurrentTime() + 1.0);
return true;
}
else if (ea.getKey()=='L')
{
if ( _currentImageStream->getLoopingMode() == osg::ImageStream::LOOPING)
{
std::cout<< _currentImageStream.get() << " Toggle Looping Off"<<std::endl;
_currentImageStream->setLoopingMode( osg::ImageStream::NO_LOOPING );
}
else
{
std::cout<< _currentImageStream.get() << " Toggle Looping On"<<std::endl;
//.........这里部分代码省略.........