(using OSG 1.1)
I seem to be having some trouble with osgViewer.
I am using viewer's computeIntersections to get hit lists for 3
subgraphs of my scenegraph. The default behavior is that all three
calls to computeIntersections produce correct hit lists.
It fails only when the window has been resized away from the startup
dimensions. However, even after the window has been resized 2 of 3
hitlists are produced correctly. The exception is the HUD subgraph
which naturally contains a cameraNode(which implies a new projection
matrix etc).
viewer->computeIntersections( mouseX, mouseY, hud->getNode(),
*hudHitList ); // works incorrectly after resize away from original
dimensions
viewer->computeIntersections( mouseX, mouseY, georefObjects.get(),
*geoRefHitList ); // always works correctly
viewer->computeIntersections( mouseX, mouseY, planet.get(),
*planetHitList ); // always works correctly
The failure behavior is this. When the window is stretched, despite
the fact that the drawing is scaled correctly, attempts to compute
intersections fail in the following way: When I stretch the window, a
region smaller than, and within the original target drawn node, still
achieves hits. If I stretch vertically, this hit-able region seems to
shrink to a size smaller than, inside, and centered below the center
of, the *original* drawn node. Likewise if I stretch horizontally, the
"hitable" region is smaller than, inside, and centered left of the
center of the *original* drawn node.
The other two subgraphs intersect correctly upon window stretching,
seemingly in all locations, and with correct coordinates. Therefore it
seems that the failure is related to the fact that the failing
subgraph has cameraNode(w/ProjectionMatrix) at its root.
Its interesting to note that the original window dimensions at which
everything works correctly are not special. This is surprising to me
in that in implies that somehow the act of resizing produces the
inconsistency which exposes the failure.
It may be relevant to note that I am using the osgviewer inside of a
QTwindow, and thus not pure Producer. Relatedly, attempts to pass the
resize event from QT to the Viewer failed when trying to use
eventQueue::windowResize() and so I have produced otherwise acceptable
results using viewer->getCamera(0)->getRenderSurface()->setWindowRectangle(
int, int, int, int ).
again, this seems to work with no problems for the other two cases.
I forward to the HUD the resize event to prevent coordinate stretching
in the following way:
void Hud::resize( double heightArg, double widthArg )
{
height = heightArg/500; // 500 keeps drawing dims ~ 1
width = widthArg/500;
cameraNode->setProjectionMatrixAsOrtho2D( 0, width, 0, height ); //
Maintains x, y, scale (prevents streching)
build();
}
If anyone can offer any insight on this issue, or can share a solution
to a something similar, I'd be much obliged.
Thanks,
Andy Somerville
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/