[osg-users] Text Intersecting Earth

Robert Osfield robert.osfield at gmail.com
Wed Oct 17 01:13:40 PDT 2007


Hi Jeffrey,

In the 2.x series of the OSG there is an osgfadetext example that uses
a ClusterCullingCallback to cull the text when its on the far side of
the earth, and disables depth test when its on the front side - this
sounds similar to your needs.

Robert.

On 10/16/07, Jeffrey M Short <jshort8 at csc.com> wrote:
>
> Hi,
>
> First off I'm using OSG 1.0.
>
> I am creating an application that has globe viewing features.  The user can
> add an location object at a given Latitude, Longitude and Altitude.  Then a
> 3d model and a text label is placed at that location.  Both the model node
> and the text geode are placed under a MatrixTransform with the matrix set
> using the
> osg::EllipsoidModel->computeLocalToWorldTransformFromLatLongHeight.  The
> text uses SCREEN_COORDS as the CharacterSizeMode and uses SCREEN as the
> AxisAlignment.
>
> The problem is that the text is intersects the earth when viewed from
> certain viewpoints.  I would like to draw the earth first, then draw all
> the text, but only draw any particular text geode if and only if the
> location is not clipped by the Earth.
>
>
> My first attempt was as follow:
>      I set the text geode depth test to osg::Depth::ALWAYS.
>
>      I added a custom osg::Drawable::CullCallback to the text geodes.  In
> the callback's virtual bool cull(osg::NodeVisitor* nv, osg::Drawable*
> drawable, osg::State*) const function I got the eye location and the text
> location in Earth Centered Cartesian Coordinates.  Then if the dot product
> of these 2 position vectors is < 0, return true so the text is culled.
>
>
> One problem I encountered here was getting the eye location from
> CullVisitor::getEyePoint().  This function seems to return the EyePoint in
> local coordinates.  I tried using the
> osg::computeLocalToWorld(nv->getNodePath()) matrix to transform the
> EyePoint to Earth Centered coordinates but that didn't work.  I had
> transform osg::Vec4(EyePoint, 1) by the inverse of
> osg::EllipoidModel::computeLocalToWorldTransformFromXYZ to get the job
> done.
>
> This method works but only when the camera is targeted at the center of the
> earth and it only works for locations with 0 altitude (imagine a location
> on the "other side" of the Earth from where you are viewing.  If the
> location has a large enough altitude you could still see it).
>
> Any suggestions on a better way to accomplish this?
>
> Thanks
>      Jeff
>
>
>
> Computer Sciences Corporation
> Registered Office: 2100 East Grand Avenue, El Segundo California 90245, USA
> Registered in USA No: C-489-59
>
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> This is a PRIVATE message. If you are not the intended recipient, please
> delete without copying and kindly advise us by e-mail of the mistake in
> delivery.
> NOTE: Regardless of content, this e-mail shall not operate to bind CSC to
> any order or other contract unless pursuant to explicit written agreement
> or government initiative expressly permitting the use of e-mail for such
> purpose.
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



More information about the osg-users mailing list