osgearth icon indicating copy to clipboard operation
osgearth copied to clipboard

Draping - draped 3D model has incorrect bounds

Open quentinBdr opened this issue 2 years ago • 5 comments

I'm using osgearth v3.3 on windows 10, GL3 profile. My application is build under a Qt QOpenGLWidget and features also ImGui. Here is the capabilities : image

The problem is I have an object that is a LocalGeometryNode (also tried w/ FeatureNode) and when wanting to drape the underlying geometry on the surface through an AltitudeSymbol w/ TECHNIQUE_DRAPE, I get no error but everything disapear on screen. I've tried w/ TECHNIQUE_MAP and TECHNIQUE_SCENE but the geometry does not clamp. Only w/ TECHNIQUE_DRAPE and TECHNIQUE_GPU I get the defect. Still, after everything disapear, when I zoom or pan I see osgearth log that it is loading tiles, just like it is working fine, but no display.

I get these log before everything goes away : image

Before draping : image

After Draping : image

Have any clue on what's happening ? :)

quentinBdr avatar Jul 01 '22 07:07 quentinBdr

Can you provide an earth file that reproduces the issue?

gwaldron avatar Jul 26 '22 16:07 gwaldron

Normally I do drape from the API, but I get the same result with a model used in the earth file provided :

<map name="Default map" type="geocentric" version="2">

  <options>
    <!-- Setup the spatial reference system. -->
    <profile/>
	<!-- Setup the network proxy for remote access. -->
	<proxy/>
	<!-- Setup the cache method. -->
	<cache>
	  <driver>filesystem</driver>
	  <path>G:/EARTH/cache</path>
	</cache>
	<!-- Setup cache policy. -->
	<cache_policy>
	  <usage>read_write</usage>
	</cache_policy>
	<!-- Setup terrain. -->
	<terrain>
	  <driver>rex</driver>
	  <gpu_tessellation>false</gpu_tessellation>
	  <range_mode>PIXEL_SIZE_ON_SCREEN</range_mode>
	  <min_tile_range_factor>10</min_tile_range_factor>
	</terrain>
  </options>

  <Annotations>
    <Model>
        <position srs="wgs84" lat="43" long="0"/>
        <style>
            model: "G:/EARTH/data/3dmodel/platforms/rafale.osgb";
            model-scale: 20;
            altitude-clamping:  terrain-drape;
        </style>
    </Model>
  </Annotations>
  
</map>

quentinBdr avatar Jul 26 '22 17:07 quentinBdr

You problem may have to do with QOpenGLWidget which uses an FBO that OpenSceneGraph doesn't know about. Try setting you main camera's default FBO like so (from your Qt paint function)... from memory:

void MyQOpenGLWidget::paintGL()
{
   viewer->getCamera()->getGraphicsContext()->setDefaultFboId(defaultFramebufferObject());
   ...

gwaldron avatar Jul 26 '22 18:07 gwaldron

Nice it does the trick thanks ! Although the model appears a bit croped somehow : image image

Any idea on that behavior ?

quentinBdr avatar Jul 27 '22 07:07 quentinBdr

I noticed that as well. The idea of draping a 3D model is a little odd, so the use case has not really been tested much. I will mark this as a defect and we can look into it.

gwaldron avatar Jul 27 '22 12:07 gwaldron

Closing as stale - if someone wants to post sample code to reproduce, we'll look at it anew.

gwaldron avatar Nov 07 '23 20:11 gwaldron