Hi Gordon,
I tried to port the Producer code to osgViewer, but some methods
are becoming hard to replace (see details bellow).
Any replacement suggestions?
Thanks,
Bruno
---------------------------------------------
//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
//ISSUE #1: getGlobalStateSet() equivalent not found
//in osgViewer::Viewer
viewer_obj->getGlobalStateSet()->setMode( GL_FOG,
osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON );
//ISSUE #2: getProjectionMatrixAsFrustum() is the closest
//method in osg::Camera, but it doesn't accept
//the d_xshear and d_yshear values
camera_obj->getLensParams(d_left, d_right, d_bottom,
d_top, d_nearClip, d_farClip, d_xshear, d_yshear);
//ISSUE #3: osg::Camera::setProjectionMatrixAsFrustum()
//seems to be the best replacement, but once more
//the d_xshear and d_yshear values are not supported
camera_obj->setLensFrustum( d_left, d_right, d_bottom,
d_top, d_near, d_far, d_xshear, d_yshear );
//ISSUE #4: osgViewer::Viewer::addSlave() was used
//as replacement
viewer_obj->getCameraConfig()->addCamera( name, camera_obj );
//ISSUE #5: replaced by osg::Camera::setViewport()
camera_obj->setProjectionRectangle ( x, y, width, height );
//ISSUE #6: setLensAutoAspect() equivalent not found in
//osg::Camera
camera_obj->setLensAutoAspect(true);
//ISSUE #7: osg::Camera::setProjectionMatrixAsPerspective() was
//the closest method found
camera_obj->setLensPerspective( f_hfov, f_vfov, f_near, f_far );
//ISSUE #8: osg::Camera::setProjectionMatrix() was
//the closest method found
camera_obj->setOffset( matrix.ptr() );
//ISSUE #9: no equivalent method for setSceneDecorator() was found
viewer_obj->setSceneDecorator( hud );
//ISSUE #10: no equivalent method for setViewByMatrix() was found
viewer_obj->setViewByMatrix( Producer::Matrix( matrixd.ptr() ) );
//ISSUE #11: no equivalent method for update() was found
viewer_obj->update();
//ISSUE #12: no equivalent method for frame() was found
camera_obj->frame( false );
//ISSUE #13: no equivalent method for setUseFrameBlock()
//was found
osgDB::Registry::instance()->getOrCreateDatabasePager()
->setUseFrameBlock(true);
//ISSUE #14: equivalent class of SceneHandlerList not found
for(SceneHandlerList::iterator itr = viewer_obj->_shvec.begin();
itr != viewer_obj->_shvec.end(); ++itr)
{
osgDB::Registry::instance()->getOrCreateDatabasePager()->
setCompileGLObjectsForContextID(
(*itr)->getSceneView()->getState()->getContextID(), false );
}
> ------------------------------
>
> Date: Fri, 25 Jul 2008 08:20:35 -0400
> From: "Gordon Tomlinson"
> Subject: Re: [osg-users] Moving from Producer to osgViewer
> To: "'OpenSceneGraph Users'"
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset="us-ascii"
>
> Have you tried ?
>
> It took us not more than a couple days to move away form producer in our
> apps
>
> Some things a little different and you pick up those up quickly when you
> convert
>
>
>
> -----Original Message-----
> From: Bruno
> Carneiro de Castro
> Sent: Friday, July 25, 2008 7:40 AM
> To: [email protected]
> Subject: [osg-users] Moving from Producer to osgViewer
>
> 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 osgViewer?
>
> Thanks,
> Bruno
>
> -----------------------------
>
> //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->setLensAutoAspect(true);
>
> 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() ) );
>
> viewer_obj->update();
>
> camera_obj->frame( false );
>
> osgDB::Registry::instance()->getOrCreateDatabasePager()-
>>setUseFrameBlock(true);
>
> for(SceneHandlerList::iterator itr = viewer_obj->_shvec.begin(); itr !=
> viewer_obj->_shvec.end(); ++itr) {
> osgDB::Registry::instance()->getOrCreateDatabasePager()->
> setCompileGLObjectsForContextID(
> (*itr)->getSceneView()->getState()->getContextID(), false ); }
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org