[osg-users] Moving from Producer to osgViewer

Bruno Carneiro de Castro carneirocastro at gmail.com
Fri Jul 25 04:39:58 PDT 2008

Hi all

I'm moving an app from Producer to osgViewer and have doubts about the
equivalence between some Producer methods vs. osgViewer methods.

May you help me, indicating the methods more suitable to change in the
Producer code fragment below, in order to get it working under



//variables (just to contextualize)

osgProducer::Viewer* viewer_obj;

Producer::Camera *camera_obj;

int x, y, width, height;

double d_left, d_right, d_bottom, d_top, d_nearClip,
d_farClip, d_xshear, d_yshear;

float f_near, f_far, f_hfov, f_vfov;

osg::Matrix matrix;

osg::Matrixd matrixd;

std::string name = "My Camera";

osg::Group* hud;

//methods that need conversion

viewer_obj->getGlobalStateSet()->setMode( GL_FOG,
osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON );

camera_obj->getLensParams(d_left, d_right, d_bottom,
d_top, d_nearClip, d_farClip, d_xshear, d_yshear);

camera_obj->setLensFrustum( d_left, d_right, d_bottom,
d_top, d_near, d_far, d_xshear, d_yshear );

viewer_obj->getCameraConfig()->addCamera( name, camera_obj );

camera_obj->setProjectionRectangle ( x, y, width, height );


camera_obj->setLensPerspective( f_hfov, f_vfov, f_near, f_far );

camera_obj = viewer_obj->getCameraConfig()->
findCamera( name.c_str() );

camera_obj->setOffset( matrix.ptr() );

viewer_obj->setSceneDecorator( hud );

viewer_obj->setViewByMatrix( Producer::Matrix( matrixd.ptr() ) );


camera_obj->frame( false );


for(SceneHandlerList::iterator itr = viewer_obj->_shvec.begin();
itr != viewer_obj->_shvec.end(); ++itr)
    (*itr)->getSceneView()->getState()->getContextID(), false );

More information about the osg-users mailing list