Hi,
I'm pretty new to using OSG and had a small question.
I've recently been working on a plane sensor simulation app. I have a 3D
view displaying the world, from the plane's sensor pov, showing terrain and
targets on the ground moving, etc. As a new feature I'm adding configurable
visual aid cues to the targets. Cue types range from a simple box to
background color inverted area around the target. I am working on adding the
cues in the overlay layer.
Hence, I'm trying to use projectObjectIntoWindow() in order to translate the
target's world positions to their positions on the overlay layer so I can
build the cues using those coordinates. Here's a code snippet on how I use
this function:
// start of code snippet
osg::Vec3 targetLoc;
bool projectIntoOverlay =
_sceneView->projectObjectIntoWindow(targetXForm->getPosition(), targetLoc);
if(!projectIntoOverlay)
LOG(warn, "Projection of Target world co-ordinates onto the Overlay
window failed. \n");
LOG(info, "Target position on Window: X: %s, Y: %s, Z: %s\n") << targetLoc.x()
<< targetLoc.y() << targetLoc.z() ;
// end of code snippet
The function seems to work fine and returns true every time, however the
targetLoc.x/y/z values I'm receiving seem rather odd. My x/y values are
around -8000 where as my z value is around -1. Example values from
targetXForm->getPosition(), which is the current target's
osg::PositionAttitudeTransform pointer, are something like 7846, 8634,
273.986 for x, y, z.
Could the problem be that targetXForm->getPosition is not the actual world
coords and some sort of local coords? or is the ProjectObjectIntoWindow()
returning correct values but they need to be converted somehow to give me
the range I was expecting (from -1 to 1)?
Any help or links to examples would be much appreciated.
Thanks,
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/