Hi all,

I've written a 2D viewer that displays geospatial imagery in an orthographic
projection using a WGS-1984 geodetic projection so the units are in degrees.

I am placing text labels with their character size specified in
SCREEN_COORDS.  When I zoom in very close, the quality of the text starts to
suffer b/c the glyph quads are so small that they are losing precision when
rendering.  Placing a MatrixTransform above the text to position it locally
reduces the visual problems but there are still some present.

The main problem I have is that the text cannot be selected if I zoom in
close.  I can see the text fine, but clicking on it doesn't result in a hit
b/c the intersections are all done using floats and the text glyphs are
extermely small because of the autosizing.

I found a potential solution using the latest version of OpenSceneGraph
which places the text in an orthographic HUD camera and positions it at the
correct space on the earth using the callback at the end of this email.
Intersections work well and the text looks very crisp.

We are currently using OpenSceneGraph 1.2 and are rolling our own viewer
using SceneView and IntersectVisitor (NOT IntersectionVisitor) in our
application and cannot update this spiral due to time constraints.
IntersectVisitor does not seem to work correctly in picking items placed in
a CameraNode in the 1.2 version.

Does anyone have any suggestions on how I could fix this issue using
OpenSceneGraph 1.2 and does the solution I found for using the latest
version of OSG make sense or I am missing something painfully obvious?

Thanks!

Jason

struct HudTextUpdateCallback : public osg::Drawable::UpdateCallback
{
public:
  HudTextUpdateCallback(double lon, double lat, Viewer* viewer)
  {
    _viewer = viewer;
    _lon = lon;
    _lat = lat;
  }

  virtual void update(osg::NodeVisitor* nv, osg::Drawable* drawable)
  {
    Text* text = dynamic_cast<Text*>(drawable);
    if (text)
    {
      CameraHelper h;
      h.setCamera(_viewer->getCamera());

      osg::Vec3 object(_lon,0,_lat);
      osg::Vec3 window;

      h.projectObjectIntoWindow(object, window);
      text->setPosition(osg::Vec3(window.x(), window.y(), 0.0));
    }
  }

  double _lon;
  double _lat;
  Viewer *_viewer;
};
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to