Custom cull visitor with osgEarth "rex-engine"

classic Classic list List threaded Threaded
3 messages Options
Emmanuel Emmanuel
Reply | Threaded
Open this post in threaded view
|

Custom cull visitor with osgEarth "rex-engine"

Hello everyone! I haven't been around for quite a long time now, but lately I started to use the VR-Vantage engine in a project, and that engine is based on OSG and osgEarth, so here I am now :-) The current task I'm trying to solve is the following: In our system, we have a camera which is actually quite far away from the terrain we are looking at (for instance, maybe 10 or 15km away). But this camera is using a very small FOV angle at the same time, so we get a highly zoomed in setup. And the idea is to ensure that we still get the highest possible quality display around the point we are looking at on the ground.

So basically, I'm building a custom CullVisitor, and in this cull visitor, I pretend that the "reference point" I'm using to compute the distance value for the LOD calculations is NOT my camera location, but instead, some point on the camera forward direction (I pointing this distance of that point from my camera position using a simple ray intersection system).

Here is the function of interest:

float scCullVisitor::getDistanceToViewPoint(const osg::Vec3 &vec, bool useLOD) const
{
// DEBUG_MSG("Inside scCullVisitor.");
// cf. http://forum.openscenegraph.org/viewtopic.php?t=8919&view=previous

if (!gIntf)
{
DEBUG_MSG("No engine interface in scCullVisitor.");
return DtOsgCullVisitor::getDistanceToViewPoint(vec, useLOD);
}

double dist = gIntf->scGetFocusPointDistance();

if (dist < 0.0)
{
// we use the previous distance in that case:
dist = _prevDist;
}

if (fabs(dist - _prevDist) > 1.0)
{
DEBUG_MSG("using focus distance: " << dist);
_prevDist = dist;
}

osg::Vec3 localViewPoint = getViewPointLocal() + getLookVectorLocal()*dist;

dist = (vec - localViewPoint).length();
if (useLOD)
{
dist *= getLODScale();
}

// DEBUG_MSG("Computed distance: " << dist);
return dist;
}

But here comes the problem:
* A similar implementation was apparently working fine for me a few years ago (cf. http://forum.openscenegraph.org/viewtopic.php?t=8919&view=previous)
* And actually it is still working as expected with the "old default" engine in osgEarth,
* Yet it seems this is not **working anymore** with the "newest rex-engine" implementation...

We already tried to investigate this issue with the help of the VT-MAK VR-Vantage support team, but so far, we couldn't clarify why the code above would not work as desired with the rex engine.

So i thought maybe I should ask the question here directly and someone can point us in the right direction to fix this issue ?

Thanks for your help !

Best regards,

PS: of course, please let me know if I didn't state the problem clearly enough here and/or you need for info on anything.

PPS: Sorry i'm having some trouble to display the code properly in the message... I hope that will be clear enough anyway.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Custom cull visitor with osgEarth "rex-engine"

Emmanuel,

Please refer you to the "osgearth_magnify" example in the osgEarth repo. It shows how to do this in two ways: 1) using OSG's built-in LODScale function; and 2) using a custom CullVisitor to manipulate the reference viewpoint.

You did not mention your OSG/osgEarth versions, but I can confirm that this works in osgEarth 2.10+ and also in the osgEarth 3.0 development branch.

Hope this helps!
Glenn Waldron / Pelican Mapping
Emmanuel Emmanuel
Reply | Threaded
Open this post in threaded view
|

Re: Custom cull visitor with osgEarth "rex-engine"

Hi Glenn,

Thanks for this very quick feedback ! :-)

So I'll check the osgearth_magnify example now to see how this works.

Have a great day!

Best regards,

Manu.