本文整理汇总了C++中osg::RenderInfo::getCurrentCamera方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderInfo::getCurrentCamera方法的具体用法?C++ RenderInfo::getCurrentCamera怎么用?C++ RenderInfo::getCurrentCamera使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::RenderInfo
的用法示例。
在下文中一共展示了RenderInfo::getCurrentCamera方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
virtual void operator () (osg::RenderInfo& renderInfo) const
{
if (!_frameCapture)
{
OSG_NOTICE<<"No FrameCamera assigned"<<std::endl;
return;
}
unsigned int frameNumber = renderInfo.getState()->getFrameStamp()->getFrameNumber();
CameraNumMap::const_iterator itr = _cameraNumMap.find(renderInfo.getCurrentCamera());
std::string outputFileName = (itr!=_cameraNumMap.end()) ?
_frameCapture->getOutputFileName(itr->second, frameNumber) :
_frameCapture->getOutputFileName(frameNumber);
OSG_NOTICE<<"outputFileName="<<outputFileName<<std::endl;
osg::Camera* camera = renderInfo.getCurrentCamera();
osg::Viewport* viewport = camera ? camera->getViewport() : 0;
if (viewport)
{
OSG_NOTICE<<"Doing read of ="<<viewport->x()<<", "<<viewport->y()<<", "<<viewport->width()<<", "<<viewport->height()<<" with pixelFormat=0x"<<std::hex<<_pixelFormat<<std::dec<<std::endl;
glReadBuffer(camera->getDrawBuffer());
osg::ref_ptr<osg::Image> image = new osg::Image;
image->readPixels(viewport->x(),viewport->y(),viewport->width(),viewport->height(),
_pixelFormat, GL_UNSIGNED_BYTE, 1);
if (_flip) image->flipVertical();
osgDB::writeImageFile(*image, outputFileName);
}
}
示例2: operator
virtual void operator () (osg::RenderInfo& renderInfo) const
{
mTexture->copyTexImage2D(*renderInfo.getState(), 0, 0, mWidth, mHeight);
// Callback removes itself when done
if (renderInfo.getCurrentCamera())
renderInfo.getCurrentCamera()->setInitialDrawCallback(NULL);
}
示例3: operator
virtual void operator () (osg::RenderInfo& renderInfo) const
{
int w = renderInfo.getCurrentCamera()->getViewport()->width();
int h = renderInfo.getCurrentCamera()->getViewport()->height();
mTexture->copyTexImage2D(*renderInfo.getState(), 0, 0, w, h);
// Callback removes itself when done
if (renderInfo.getCurrentCamera())
renderInfo.getCurrentCamera()->setInitialDrawCallback(NULL);
}
示例4: operator
void Camera::DrawCallback::operator () (osg::RenderInfo& renderInfo) const
{
if (renderInfo.getCurrentCamera())
{
operator()(*(renderInfo.getCurrentCamera()));
}
else
{
OSG_WARN<<"Error: Camera::DrawCallback called without valid camera."<<std::endl;
}
}
示例5: operator
virtual void operator()( osg::RenderInfo& renderInfo ) const
{
osg::Viewport* viewport = renderInfo.getCurrentCamera()->getViewport();
if ( viewport ) TwWindowSize( viewport->width(), viewport->height() );
updateEvents();
TwDraw();
}
示例6: operator
virtual void operator()(osg::RenderInfo& renderInfo) const
{
osg::GraphicsOperation* graphicsOperation = renderInfo.getCurrentCamera()->getRenderer();
osgViewer::Renderer* renderer = dynamic_cast<osgViewer::Renderer*>(graphicsOperation);
if (renderer != nullptr)
{
// Disable normal OSG FBO camera setup because it will undo the MSAA FBO configuration.
renderer->setCameraRequiresSetUp(false);
}
}
示例7: operator
void KinectCallback::operator () ( osg::RenderInfo& info ) const {
if (!m_done) {
osg::Camera* camera = info.getCurrentCamera();
ColorCloudPtr cloud = computePointCloud(camera, depthbufferimg.get(), colorbufferimg.get());
KinectCallback* this2 = const_cast<KinectCallback*>(this);
this2->m_done = true;
this2->m_cloud = cloud;
}
}
示例8:
void
SkyDrawable::drawImplementation(osg::RenderInfo& renderInfo) const
{
osg::Camera* camera = renderInfo.getCurrentCamera();
#ifndef SL_USE_CULL_MASK
//Check if this is the target camera
if (_contextNode->getTargetCamera() == camera)
#endif
{
if ( camera)
{
renderInfo.getState()->disableAllVertexArrays();
_SL->initialize( renderInfo );
// convey the sky box size (far plane) to SL:
double fovy, ar, znear, zfar;
_SL->setCamera(camera);
camera->getProjectionMatrixAsPerspective(fovy, ar, znear, zfar);
_SL->setSkyBoxSize( zfar < 100000.0 ? zfar : 100000.0 );
// invoke the user callback if it exists
if (_SL->getCallback())
_SL->getCallback()->onDrawSky(_SL->getAtmosphereWrapper());
// draw the sky.
_SL->getAtmosphere()->DrawSky(
true,
_SL->getSRS()->isGeographic(),
_SL->getSkyBoxSize(),
true,
false );
// Dirty the state and the program tracking to prevent GL state conflicts.
renderInfo.getState()->dirtyAllVertexArrays();
renderInfo.getState()->dirtyAllAttributes();
#if 0
#if OSG_VERSION_GREATER_OR_EQUAL(3,4,0)
osg::GLExtensions* api = renderInfo.getState()->get<osg::GLExtensions>();
#else
osg::GL2Extensions* api = osg::GL2Extensions::Get(renderInfo.getState()->getContextID(), true);
#endif
api->glUseProgram((GLuint)0);
renderInfo.getState()->setLastAppliedProgramObject(0L);
#endif
renderInfo.getState()->apply();
}
}
}
示例9: drawImplementation
/**
* Draws a bin. Most of this code is copied from osgUtil::RenderBin::drawImplementation.
* The modifications are (a) skipping code to render child bins, (b) setting a bin-global
* projection matrix in orthographic space, and (c) calling our custom "renderLeaf()" method
* instead of RenderLeaf::render()
*/
void drawImplementation( osgUtil::RenderBin* bin, osg::RenderInfo& renderInfo, osgUtil::RenderLeaf*& previous )
{
osg::State& state = *renderInfo.getState();
unsigned int numToPop = (previous ? osgUtil::StateGraph::numToPop(previous->_parent) : 0);
if (numToPop>1) --numToPop;
unsigned int insertStateSetPosition = state.getStateSetStackSize() - numToPop;
if (bin->getStateSet())
{
state.insertStateSet(insertStateSetPosition, bin->getStateSet());
}
// apply a window-space projection matrix.
const osg::Viewport* vp = renderInfo.getCurrentCamera()->getViewport();
if ( vp )
{
//TODO see which is faster
osg::ref_ptr<osg::RefMatrix>& m = _ortho2D.get();
if ( !m.valid() )
m = new osg::RefMatrix();
m->makeOrtho2D( vp->x(), vp->x()+vp->width()-1, vp->y(), vp->y()+vp->height()-1 );
state.applyProjectionMatrix( m.get() );
//osg::ref_ptr<osg::RefMatrix> rm = new osg::RefMatrix( osg::Matrix::ortho2D(
// vp->x(), vp->x()+vp->width()-1,
// vp->y(), vp->y()+vp->height()-1 ) );
//state.applyProjectionMatrix( rm.get() );
}
// render the list
osgUtil::RenderBin::RenderLeafList& leaves = bin->getRenderLeafList();
for(osgUtil::RenderBin::RenderLeafList::reverse_iterator rlitr = leaves.rbegin();
rlitr!= leaves.rend();
++rlitr)
{
osgUtil::RenderLeaf* rl = *rlitr;
renderLeaf( rl, renderInfo, previous );
previous = rl;
}
if ( bin->getStateSet() )
{
state.removeStateSet(insertStateSetPosition);
}
}
示例10: operator
virtual void operator () (osg::RenderInfo& renderInfo) const
{
// osg::notify(osg::NOTICE)<<"Camera callback"<<std::endl;
cout << "callbck\n";
osg::Camera * camera = renderInfo.getCurrentCamera();
osg::Viewport * viewport = camera ? camera->getViewport() : 0;
osg::Image * image = new osg::Image();
if( viewport )
{
cout << "take screenshot "<< viewport->width() << " " << viewport->height() << endl;
image->readPixels(int(viewport->x()),int(viewport->y()),int(viewport->width()),int(viewport->height()),GL_RGBA,GL_UNSIGNED_BYTE);
// osgDB::writeImageFile( *image, string("out.png") );
}
else
cout << "error with viewport\n";
}
示例11: drawPatches
void
TileDrawable::drawPrimitivesImplementation(osg::RenderInfo& renderInfo) const
{
if ( _drawPatch )
{
drawPatches( renderInfo );
}
else
{
const osg::Camera* camera = renderInfo.getCurrentCamera();
bool renderColor =
//(camera->getRenderOrder() != osg::Camera::PRE_RENDER) ||
((camera->getClearMask() & GL_COLOR_BUFFER_BIT) != 0L);
drawSurface( renderInfo, renderColor );
}
}
示例12: operator
void operator () ( osg::RenderInfo& info ) const {
if (!m_done) {
osg::Camera* camera = info.getCurrentCamera();
FinalDrawCallback* this2 = const_cast<FinalDrawCallback*>(this);
// MatrixXf rangeData = computeDepthImage(camera, depthbufferimg);
// ofstream outfile("depth.txt");
// outfile << rangeData << endl;
// outfile.close();
ColorCloudPtr cloud = computePointCloud(camera, depthbufferimg.get(), colorbufferimg.get());
pcl::io::savePCDFileBinary("q.pcd", *cloud);
this2->m_done = true;
cout << "writing depth image" << endl;
}
}
示例13:
void
CloudsDrawable::drawImplementation(osg::RenderInfo& renderInfo) const
{
osg::Camera* camera = renderInfo.getCurrentCamera();
#ifndef SL_USE_CULL_MASK
if(_contextNode->getTargetCamera() == camera)
#endif
{
if ( _SL->ready())
{
osg::State* state = renderInfo.getState();
// adapt the SL shaders so they can accept OSG uniforms:
osgEarth::NativeProgramAdapterCollection& adapters = _adapters[ state->getContextID() ]; // thread safe.
if ( adapters.empty() )
{
adapters.push_back( new osgEarth::NativeProgramAdapter(state, _SL->getAtmosphere()->GetSkyShader()) );
adapters.push_back( new osgEarth::NativeProgramAdapter(state, _SL->getAtmosphere()->GetBillboardShader()) );
adapters.push_back( new osgEarth::NativeProgramAdapter(state, _SL->getAtmosphere()->GetStarShader()) );
adapters.push_back( new osgEarth::NativeProgramAdapter(state, _SL->getAtmosphere()->GetPrecipitationShader()) );
//adapters.push_back(new osgEarth::NativeProgramAdapter(state, _SL->getAtmosphere()->GetAtmosphericLimbShader()) );
SL_VECTOR(unsigned) handles = _SL->getAtmosphere()->GetActivePlanarCloudShaders();
for(int i=0; i<handles.size(); ++i)
adapters.push_back( new osgEarth::NativeProgramAdapter(state, handles[i]) );
}
adapters.apply( state );
// invoke the user callback if it exists
if (_SL->getCallback())
_SL->getCallback()->onDrawClouds(_SL->getAtmosphereWrapper());
renderInfo.getState()->disableAllVertexArrays();
_SL->getAtmosphere()->DrawObjects( true, true, true );
// Restore the GL state to where it was before.
state->dirtyAllVertexArrays();
state->dirtyAllAttributes();
state->apply();
}
}
}
示例14: operator
virtual void operator () (osg::RenderInfo& renderInfo) const
{
if (!_snapImage) return;
osg::notify(osg::NOTICE)<<"Camera callback"<<std::endl;
osg::Camera* camera = renderInfo.getCurrentCamera();
osg::Viewport* viewport = camera ? camera->getViewport() : 0;
osg::notify(osg::NOTICE)<<"Camera callback "<<camera<<" "<<viewport<<std::endl;
if (viewport && _image.valid())
{
_image->readPixels(int(viewport->x()),int(viewport->y()),int(viewport->width()),int(viewport->height()),
GL_RGBA,
GL_UNSIGNED_BYTE);
osgDB::writeImageFile(*_image, _filename);
osg::notify(osg::NOTICE)<<"Taken screenshot, and written to '"<<_filename<<"'"<<std::endl;
}
_snapImage = false;
}
示例15: getExtensions
// After 1.2, param 1 changed from State to RenderInfo.
// Warning: Version was still 1.2 on dev branch long after the 1.2 release,
// and finally got bumped to 1.9 in April 2007.
void
QueryGeometry::drawImplementation( osg::RenderInfo& renderInfo ) const
{
unsigned int contextID = renderInfo.getState()->getContextID();
osg::Drawable::Extensions* ext = getExtensions( contextID, true );
osg::Camera* cam = renderInfo.getCurrentCamera();
// Add callbacks if necessary.
if (!cam->getPostDrawCallback())
{
RetrieveQueriesCallback* rqcb = new RetrieveQueriesCallback( ext );
cam->setPostDrawCallback( rqcb );
ClearQueriesCallback* cqcb = new ClearQueriesCallback;
cqcb->_rqcb = rqcb;
cam->setPreDrawCallback( cqcb );
}
// Get TestResult from Camera map
TestResult* tr;
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock( _mapMutex );
tr = &( _results[ cam ] );
}
// Add TestResult to RQCB.
RetrieveQueriesCallback* rqcb = dynamic_cast<
RetrieveQueriesCallback* >( cam->getPostDrawCallback() );
if (!rqcb)
{
osg::notify( osg::FATAL ) << "osgOQ: QG: Invalid RQCB." << std::endl;
return;
}
rqcb->add( tr );
// Issue query
if (!tr->_init)
{
ext->glGenQueries( 1, &(tr->_id) );
tr->_contextID = contextID;
tr->_init = true;
}
osg::notify( osg::DEBUG_INFO ) <<
"osgOQ: QG: Querying for: " << _oqnName << std::endl;
ext->glBeginQuery( GL_SAMPLES_PASSED_ARB, tr->_id );
osg::Geometry::drawImplementation( renderInfo );
ext->glEndQuery( GL_SAMPLES_PASSED_ARB );
tr->_active = true;
osg::notify( osg::DEBUG_INFO ) <<
"osgOQ: QG. OQNName: " << _oqnName <<
", Ctx: " << contextID <<
", ID: " << tr->_id << std::endl;
#ifdef _DEBUG
{
GLenum err;
if ((err = glGetError()) != GL_NO_ERROR)
osg::notify( osg::FATAL ) <<
"osgOQ: QG: OpenGL error: " << err << "." << std::endl;
}
#endif
}