Re: [osg-users] Problem loading images when migrating to new OSGViewer

2010-09-30 Thread John Stokes
Robert,
 
   I tried setting the NearFarRatio to a smaller value, and everything rendered 
as desired. I ended up using:


Code:

viewer-getCamera()-setNearFarRatio(0.2);



 
 This satisfies all my current requirements, so I will keep in mind your good 
advice about the osgdepthpartition example if I need to render a more complex 
scene.

Thanks for your help!

John

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=32223#32223





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Problem loading images when migrating to new OSGViewer

2010-09-28 Thread John Stokes
Hi,

I've been migrating some code from OSG 0.9.9 to the latest stable release 
(2.8.3), and I've run into an issue when migrating from OSGProducer::viewer to 
OsgViewer::viewer. I have three models, an airplane.3ds model, a sky.3ds model, 
and a globe.osga model. All three models load correctly (the nodes returned 
from osgDB::readNodeFile are not NULL), but only the airplane model shows up 
when the viewer display is rendered.

The only functions that I needed to change from osgProducer to osgViewer were 
my initialization and update functions. I've made sure to replace osgProducer 
calls with equivalent osgViewer calls when I upgraded (see code below), but is 
there anything I might have missed? 



Code:


3DPlaneViewer::Initialize(){
osgViewer::Viewer* viewer = new osgViewer::Viewer();

//scene root
osg::Group* root = new osg::Group();

//load globe and add transform of globe to root group
osg::Node* globeNode = osgDB::readNodeFile(globe.osga);
osg::MatrixTransform* globeTransform = new osg::MatrixTransform(); 
globeTransform-addChild( globeNode );

//create group for globe and sky
osg::Group*terrainNodes = new Group();
terrainNodes-asGroup()-addChild( globeTransform );

//load airplane
osg::Node* airplaneNode = osgDB::readNodeFile(airplane.3ds);
//specify a location for plane on globe with lat, long, altitude
osg::Matrixd airplaneMatrix;
osg::EllipsoidModel* ellipse-computeLocalToWorldTransformFromLatLongHeight( 
osg::DegreesToRadians(20.0f),osg::DegreesToRadians(-30.0f), 
15000,airplaneMatrix );

//rotate airplane node
airplaneMatrix.preMult( airplaneMatrix.rotate( 
osg::Quat(osg::DegreesToRadians(180.0f), osg::Vec3f( 0, 0, 1 ) )));

//setup matrix wrapper node
osg::MatrixTransform* airplaneTransform = new osg::MatrixTransform(); 
airplaneTransform-getOrCreateStateSet()-setMode(GL_RESCALE_NORMAL,osg::StateAttribute::ON);
 
airplaneTransform-setMatrix(airplaneMatrix); 
airplaneTransform-addChild( airplaneNode );
terrainNodes-asGroup()-addChild( airplaneTransform );


//load and add the sky model
osg::Node* skyNode = osgDB::readNodeFile(sky.3DS);
osg::MatrixTransform* skyTransform = new osg::MatrixTransform();
skyTransform-addChild( skyNode );
terrainNodes-asGroup()-addChild( skyTransform );

root-addChild( terrainNodes );

//realize the scene in the viewer
viewer-setSceneData(root);
viewer-realize(); 

}

3DPlaneViewer::Update()
{

//removed calls to osgProducer::sync()
viewer-updateTraversal();

//do some other updates on other objects in the scene
viewer-frame();
}





Thanks,
John

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=32136#32136





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Problem loading images when migrating to new OSGViewer

2010-09-28 Thread John Stokes
Robert,

  Thank you for your insight. I did try loading my models with the standalone 
osgviewer and each of them loaded correctly as did the exported .osg using 
osgDB::writeNodeFile.

  I was testing out commenting out different sections, and I noticed that I had 
this piece of code that I left out in my last post:


Code:

OsgViewer* viewer = new osgViewer::Viewer();
viewer-getCamera()-setClearColor( osg::Vec4(0.2,0.2,1,1) );

//Replace osgProducer::viewer cull setting with new osgViewer setting
//old code: 
viewer-getCullSettings().setComputeNearFarMode(osgUtil::CullVisitor::DO_NOT_COMPUTE_NEAR_FAR);
viewer-getCamera()-setComputeNearFarMode(osgUtil::CullVisitor::DO_NOT_COMPUTE_NEAR_FAR);




When I comment out the updated setComputeNearFarMode line of code, my globe 
and sky models show up correctly but my plane model disappears. Is there a 
correct cull setting that I should be using to get everything to display? 

I tried using the COMPUTE_NEAR_FAR_USING_PRIMITIVES and 
COMPUTE_NEAR_FAR_USING_BOUNDING_VALUES with this call, but I'm not quite sure 
what bounding value I should be using or if I should be looking at another 
culling method.

Thanks,
John[/code]

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=32148#32148





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Legacy question about MFC and Producer::Viewer

2010-08-30 Thread John Stokes
Hello all,

  I realize that OSG has long since deprecated support for Producer::Viewer in 
favor of the Viewer class, but I am hoping that someone might be able to point 
me in the right direction.. 

  I am working on updating a display that use OSG 0.9.9 (and for other support 
reasons we can't reasonably upgrade to the latest version). We use the 
following code to create a viewer and attach a NodeTrackerManipulator object 
called CameraTracker to track events with a plane node.


Code:

MyCode::initializeViewer()
{
osgProducer::Viewer* viewer; 

viewer-setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS);

//perform other setup

nodeTracker = new CameraTracker();

unsigned int num = viewer-addCameraManipulator(nodeTracker);
viewer-selectCameraManipulator(num);
...
viewer-realize();
}

//NodeTrackerManipulator that handles mouse events
bool CameraTracker::handle(const GUIEventAdapter ea,GUIActionAdapter us)
{

_thrown = false;
switch(ea.getEventType())
{
case(GUIEventAdapter::PUSH):
{
flushMouseEventStack();
addMouseEvent(ea);
if (calcMovement()) us.requestRedraw();
us.requestContinuousUpdate(false);
_thrown = false;
return true;
}
}
}





The NodeTracker object receives events correctly in the initial implementation, 
but I have recently added a simple line of code to embed
the OSG Display inside an MFC dialog window:


Code:

if(m_mfcParentWndHandle != NULL)
{
//Attach OSG viewer display to an existing MFC dialog frame using HWND
viewer-getCameraConfig()-getCamera(0)-getRenderSurface()-setWindow(m_mfcParentWndHandle);
...
viewer-realize();
}




This new code segment attaches the display to the MFC parent correctly, and 
FRAME events still seem to be processed (so the display can be redrawn on 
frame()), but my NodeTrackerManipulator class doesn't receive mouse events 
anymore. 

I've looked at the old OSGMFC example, but it doesn't seem to address this 
particular situation. I've also tried capturing the MFC mouse events in the 
parent dialog, but I can't figure out how to create new GUIEventAdapter objects 
that can be passed to my handle function.

Does anyone with knowledge of MFC or this old implementation have a suggestion 
as to where to look next? 


Thanks,
John

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=31164#31164





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org