Re: [osg-users] osgQt & osgEarth not working with 0 margin in Qlayout

2019-05-29 Thread David Bobavid
Hi,

I have played around with this a bit more, and it seems that after setting the 
margins to 0, the timer update calling upadte() doesn't properly called the 
paintEvent on the widget.

If I make my own slot for the timer's timeout and call the _viewer->frame() on 
my own, it works just fine.

Just posting in case anyone else comes across this issue.

Cheers,
David

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=76149#76149





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] osgQt & osgEarth not working with 0 margin in Qlayout

2019-05-16 Thread David Bobavid
Hi,

I've come across an issue I'm sort of confused about, and hopefully someone can 
help figure it out. 

I'm using osgQt & osgEarth 2.10 & osg 3.6.3 with Qt 5.12 on Windows 10. It all 
seems to work, and I'm following the osgQt Viewer example for setting up my 
program. My osg widget, when added to my frame, has the default margin and 
spacing, so when I set it to my central widget (in a QMainWidget) it has a gray 
border. However, when I set the margins to 0, it won't draw the map at all, and 
it shows some artifacts around the edge of the widget. 

This is what I'm doing:

Code:

OsgViewerQWidget::OsgViewerQWidget(QWidget* parent /*= 0*/, Qt::WindowFlags f 
/*= 0*/, QStatusBar* statusBar /*= 0*/)
: QWidget(parent, f)
{
 _map = new osgEarth::Map();

// add a TMS imagery layer: 
osgEarth::Drivers::TMSOptions imagery;
imagery.url() = "http://readymap.org/readymap/tiles/1.0.0/7/;;
_map->addLayer(new osgEarth::ImageLayer("ReadyMap Imagery", imagery));

// add a TMS elevation layer:
osgEarth::Drivers::TMSOptions elevation;
elevation.url() = "http://readymap.org/readymap/tiles/1.0.0/116/;;
_map->addLayer(new osgEarth::ElevationLayer("ReadyMap Elevation", elevation));

graticuleLayer = new osgEarth::Util::GeodeticGraticule();
_map->addLayer(graticuleLayer);

// That's it, the map is ready; now create a MapNode to render the Map:
_mapNode = new osgEarth::MapNode(_map);

_mapNode->setNodeMask(0x1);

setThreadingModel(osgViewer::ViewerBase::SingleThreaded);

// disable the default setting of viewer.done() by pressing Escape.
setKeyEventSetsDone(0);

QWidget* widget1 = AddViewWidget(CreateGraphicsWindow(0, 0, 100, 100), 
_mapNode, statusBar);

QGridLayout* grid = new QGridLayout;
setLayout(grid);

grid->setSpacing(0);
//grid->setContentsMargins(0, 0, 0, 0);   // with this line commented out, 
it works, with it in, it doesn't work... but, why?!
grid->addWidget(widget1);

connect(&_timer, SIGNAL(timeout()), this, SLOT(update()));
_timer.start(10);
}

osgQt::GraphicsWindowQt* OsgViewerQWidget::CreateGraphicsWindow(int x, int y, 
int w, int h, const std::string& name /*= ""*/, bool windowDecoration /*= 
false*/)
{
osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
osg::ref_ptr traits = new 
osg::GraphicsContext::Traits;
traits->windowName = name;
traits->windowDecoration = windowDecoration;
traits->x = x;
traits->y = y;
traits->width = w;
traits->height = h;
traits->doubleBuffer = true;
traits->alpha = ds->getMinimumNumAlphaBits();
traits->stencil = ds->getMinimumNumStencilBits();
traits->sampleBuffers = ds->getMultiSamples();
traits->samples = ds->getNumMultiSamples();

return new osgQt::GraphicsWindowQt(traits.get());
}

QWidget* OsgViewerQWidget::AddViewWidget(osgQt::GraphicsWindowQt* gw, 
osg::ref_ptr scene, QStatusBar *statusBar)
{
osgViewer::View* view = new osgViewer::View;
addView(view);

osg::Camera* camera = view->getCamera();
camera->setGraphicsContext(gw);

// need to do this to make lines show up... o_O  Thanks's Glenn!
osgEarth::Util::GLUtils::setGlobalDefaults(camera->getOrCreateStateSet());

const osg::GraphicsContext::Traits* traits = gw->getTraits();

camera->setClearColor(osg::Vec4(0.2, 0.2, 0.6, 1.0));
camera->setViewport(new osg::Viewport(0, 0, traits->width, traits->height));

// set the draw and read buffers up for a double buffered window with rendering 
going to back buffer
camera->setDrawBuffer(GL_BACK);
camera->setReadBuffer(GL_BACK);

camera->setProjectionMatrixAsPerspective(30.0f, 
static_cast(traits->width) / static_cast(traits->height), 1.0f, 
1.0f);

view->setSceneData(scene);
view->addEventHandler(new osgViewer::StatsHandler);
view->addEventHandler(new 
osgGA::StateSetManipulator(view->getCamera()->getOrCreateStateSet()));
view->addEventHandler(new osgViewer::ThreadingHandler());
view->addEventHandler(new osgViewer::LODScaleHandler());
view->addEventHandler(new osgViewer::ScreenCaptureHandler());

earthManip = new osgEarth::Util::EarthManipulator;
view->setCameraManipulator(earthManip);

ldBuffer = new osgEarth::Util::LogarithmicDepthBuffer;
ldBuffer->install(camera);

gw->setTouchEventsEnabled(true);
return gw->getGLWidget();
}




So it seems to go wrong in my constructor, when I set the grid layout content 
margins to 0. Otherwise this works just fine. I set the margin to 0, and it 
doesn't show anything. 

Any ideas will be greatly appreciated.

Thank you!
David

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=76113#76113





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] adding object models in osgEarth best practices

2019-05-03 Thread David Bobavid
Hi Nick,

Thanks - I'll give it a try! 

Cheers,
David

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75946#75946





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] adding object models in osgEarth best practices

2019-05-02 Thread David Bobavid
Hi Eran,

Ok, thanks! I'll look into that.

Last question (I think) for now... I'm trying to set my cow's orientation. From 
what you have suggested previously, would I add another MatrixTransform node 
with the rotations set into it? 

Or should I add a PositionAttitudeTransform instead? If so, are there some 
helper classes that I can use that will create the Quat properly based on my 
heading, pitch and roll? I've been looking through the headers and cannot seem 
to find something that will help.

Thank you again!

Cheers,
David

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75944#75944





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] adding object models in osgEarth best practices

2019-05-02 Thread David Bobavid
Hi Eran,

So, it looks like if I zoom in *a lot* I do see my cow... I was playing around 
with it again and tried getting in real close, and setting the scale much 
larger again, and it's showing up. I guess it's a very small model, and I 
wasn't really looking close enough for it, either.

Thank you again for your help!

Cheers,
David

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75942#75942





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] adding object models in osgEarth best practices

2019-05-02 Thread David Bobavid
Hi Eran,

Yes, sure... this is what I'm doing:

First to load my map:

Code:

_map = new osgEarth::Map();

osgEarth::Drivers::GDALOptions basemap;
basemap.url() = "I:/Dev/QtOsgTest1/data/world.tif";
_map->addLayer(new ImageLayer(ImageLayerOptions("basemap", basemap)));

_mapNode = new osgEarth::MapNode(_map);





Then later to load the model:

Code:


auto model = osgDB::readNodeFile("I:/Dev/QtOsgTest1/data/cow.osg");
if (!model) {
qDebug() << "Oh shit, model didn't load!";
}

auto transform = new osg::MatrixTransform;
transform->setMatrix(osg::Matrix::scale(100, 100, 100));
if (!transform->addChild(model)) {
qDebug() << "Failed adding model to matrix transform";
}

auto geoTransform = new osgEarth::GeoTransform;
geoTransform->setTerrain(_mapNode->getTerrain());
if 
(!geoTransform->setPosition(osgEarth::GeoPoint(_mapNode->getMapSRS()->getGeographicSRS(),
 -100, 52, 1000))) {
qDebug() << "Setting position failed";
}

if (!geoTransform->addChild(transform)) {
qDebug() << "Adding matrix transform to geotransform failed";
}

_mapNode->addChild(geoTransform);




I don't see the model show up, but I also don't see any of my error statements, 
either. 

Thanks again,
david

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75941#75941





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] adding object models in osgEarth best practices

2019-05-02 Thread David Bobavid
Hi Eran,

Ok, dumb follow up - I'm trying to add the geoTransform to my mapnode, and 
nothing is showing up. Is there something else I should be doing to add this 
transformed model to my map node?

(Sorry, total newb with osg/osgearth, here)

Thanks again,
David

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75938#75938





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] adding object models in osgEarth best practices

2019-05-02 Thread David Bobavid
Hi Eran,

Great, thanks so much. I'll give that a shot!

Cheers,
David

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75937#75937





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] adding object models in osgEarth best practices

2019-05-02 Thread David Bobavid
Hi,

I'm new to OSG and OSGEarth, and I did some googling, but still have some 
trouble finding out the proper way to do this.

So I have an osgEarth program, and I want to add some entity models, such as 
planes, moving around my globe. While I'm good with loading a .earth file for 
the terrain, or adding the textures/elevation data through code, I'm having 
some trouble adding models.

>From the examples (such as the osgearth_annotation), it seems like models are 
>added by way of Styles:

Code:

Style style;
style.getOrCreate()->autoScale() = true;
style.getOrCreate()->url()->setLiteral("../data/red_flag.osg.50.scale");
ModelNode* modelNode = new ModelNode(mapNode, style); 
modelNode->setPosition(GeoPoint(geoSRS, -100, 52));
annoGroup->addChild(modelNode);




Which seems to work all right. I have tried adding another model, such as the 
cow.osg that comes with the osg data, and it doesn't look so good. For 
starters, it's very small, even with the scaling. I tried setting a new scale, 
but it didn't seem to help:

Code:

Style style;
style.getOrCreate()->autoScale() = true;
style.getOrCreate()->url()->setLiteral("../data/cow.osg");
style.getOrCreate()->scale() = 4000;
ModelNode* modelNode = new ModelNode(mapNode, style); 
modelNode->setPosition(GeoPoint(geoSRS, -100, 52));
annoGroup->addChild(modelNode);




The cow seems to the same size (tiny!) and even when I zooom in, it's still 
super small. Also, I tried setting the heading:

Code:

Style style;
style.getOrCreate()->autoScale() = true;
style.getOrCreate()->url()->setLiteral("../data/red_flag.osg.50.scale");
style.getOrCreate()->heading() = 180;
ModelNode* modelNode = new ModelNode(mapNode, style); 
modelNode->setPosition(GeoPoint(geoSRS, -100, 52));
annoGroup->addChild(modelNode);




And in this case, it seems like the model is 180degrees from where it was 
facing, not 180 from North.

So - what is the best way to go about adding a model and orienting it properly? 
Is this styles approach the correct way? I have seen some reference in another 
post about an osgEarthUtil::ObjectPlacer, but that class doesn't seem to exist 
any more.


Thank you!

Cheers,
David

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75923#75923





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org