[osg-users] questions about developing drivers for osg/osgEarth

Chris Hanson xenon at alphapixel.com
Thu Sep 19 07:29:49 PDT 2019


You're still describing what you're trying to to do solve the problem, but
not what the problem is.


Your solution seems to involve a traveling dynamic piece of geospatial
data. But generally, geospatial data is not traveling or dynamic. So,
you're possibly fighting limitations in the design of the subsystem you are
choosing to use.

Moving markers are typically represented with other osgEarth entities like
symbology, which are suited to being dynamically updated. Can you describe
what the data displayed really represents and how it is supposed to appear
in the final result?

Is this a vehicle position marker? Is it a dynamic sensor feed from a UAV
painted onto the terrain? Knowing what you're actually trying to accomplish
gives us a much better chance of suggesting a successful solution than
trying to guess what you want based upon your description of how you tried
to solve it.

On Thu, Sep 19, 2019 at 7:36 AM speterson at idealaero.com <
speterson at idealaero.com> wrote:

> Hi Chris,
>
>
>
> Well just trying to get something simple to work first so let’s just
> continue with what I was attempting with that code I posted before.
>
>
>
> There will be a periodic chunk of data that comes in.  This data will be
> programmically used to generate a bitmap or bitmap array in memory.  Goal
> is to not use tmp files or files at all.  Take the image generated and
> geospatially place it onto a layer in osgEarth.  There will be a shader
> applied to the image to alter the information to show a type of animation,
> this can be ignored for now as I don’t have an issue doing this.  Every so
> often an update with different data will come in and a new image will be
> created and it will replace the one currently displayed on the layer in
> osgEarth.  This could happen quite a few times but the updates will not
> need to be fast, only ever 15-30 min but I been doing updates in seconds
> for testing.
>
>
>
> That’s the process of what I am doing, in my code I gave I replaced the
> image with just a yellow filled bitmap, and removed the bitmap creation and
> reading completely and just used the color yellow.  To mimic the change of
> new data I ramped the alpha channel data up and attempting to update the
> layer information with the new image with ramped up alpha channel.  Ofc
> this is just for testing the data we will actually be processing will build
> complex figures onto the image with specific colors so the shader can
> process and do it’s work accordingly.  Goal of the shader is to take
> processing out of the osg processing loop to cause simplistic and repeated
> animations.
>
>
>
> Things I have tried before:
>
>
>
> Building a TileSourceDriver this seemed to work except it would leave LOD
> artifacts of old data on some tiles after the image updates and I would
> have to manually pan the earth, zoom in and out until some buffer cleared
> before going back so it would cause a total refresh of all data.  I could
> never find a method that would trigger a GL refresh of every tile at ever
> LOD correctly,  the layer data seemed to be correct but the GL buffer data
> could not be forced for some reason.
>
>
>
> Another method I tried was build a driver based off the VisibleLayer and
> use the OGRFeatureSource to put my image data onto a layer.  I could never
> get my image to show unless I made it a texture which would be fine but
> when I changed the data for the texture I could not find a way to update
> the layer to redraw.  I just can’t wrap my head around what callbacks to
> use or which update calls to use.  I abandoned this idea when I read I
> could apply shaders to my images directly without applying my image as a
> texture.
>
>
>
> And here we are with my code I supplied.  I have gotten the data to update
> shaders to work everything works with this method however cludgy it is, but
> again could only get the update to happen if I removed and added layers
> instead of trying to update the layer via some callback or call I am
> missing.  Ofc this is not working as my code and osg seem to conflict each
> other and I get an error on layer removal or addition, I have tried
> mutex’ing my operation loop but might be using that wrong as well.
>
>
>
> I was going to go back and try my layer removal and adding idea onto the
> OGRFeature work using textures but figured would be waste of time being it
> seems the layer removal and adding is causing the issue.
>
>
>
> I hope this give a good in-depth background of my efforts an what I am
> trying to accomplish and look forward to any suggestions you can provide to
> steer me in the right direction.
>
>
>
> Thanks again in advance.
>
>
>
> Shannon
>
>
>
>
>
> *From:* osg-users [mailto:osg-users-bounces at lists.openscenegraph.org] *On
> Behalf Of *Chris Hanson
> *Sent:* Wednesday, September 18, 2019 6:40 PM
> *To:* OpenSceneGraph Users <osg-users at lists.openscenegraph.org>
> *Subject:* Re: [osg-users] questions about developing drivers for
> osg/osgEarth
>
>
>
> Could you explain your actual goal with specifics? It's hard to recommend
> a method that will be successful when we don't know what success even looks
> like.
>
>
>
> If you give is some detailed info we can probably recommend something
> specific.
>
>
>
> On Wed, Sep 18, 2019 at 3:41 PM speterson at idealaero.com <
> speterson at idealaero.com> wrote:
>
> Hi Chis,
>
>
>
> Any examples on how to do this?  I tried that so many ways and gave up.  I
> could never get anything to update at all.
>
>
>
> I have been having a hard time finding any examples on how to do this, so
> any help would be great.
>
>
>
> Thanks
>
>
>
> *From:* osg-users [mailto:osg-users-bounces at lists.openscenegraph.org] *On
> Behalf Of *Chris Hanson
> *Sent:* Wednesday, September 18, 2019 4:35 PM
> *To:* OpenSceneGraph Users <osg-users at lists.openscenegraph.org>
> *Subject:* Re: [osg-users] questions about developing drivers for
> osg/osgEarth
>
>
>
> You kind of seem to be going about this a difficult way.
>
>
>
> Is dynamically altering a surface texture layer really the best way to add
> an arrow to the scene?
>
>
>
> It seems like you're trying to use a screwdriver to hammer nails.
>
>
>
> Is it not more effective to use some kind of symbology and render passes
> to overlay it onto the surface without testing or rewriting the Z buffer?
>
>
>
>
>
> On Wed, Sep 18, 2019 at 2:57 PM speterson at idealaero.com <
> speterson at idealaero.com> wrote:
>
> Hello again,
>
>
>
> I have gotten some of the things I want done somewhat working.
>
>
>
> I am now having an issue attempting to get a layer to update within a
> system thread I made.
>
>
>
> First off I built all this using the Simple Ocean plugin code as my base
> line.  I then added a way to get a simple yellow box to show where I wanted
> programically with osgEarth.  I do have shader code working but what I need
> help with now is updating my layer ever so often with new data for my
> shaders to run on.
>
>
>
> Below is my simple function that my thread runs,  layer is a valid layer
> that is displayed named “newlayer”.
>
>
>
> The code runs and ramps up the alpha channel for a while (sometimes few
> seconds, sometimes minutes) and starts the ramp again with almost
> transparent, but eventually I get a read access violation in
> osg/NodeVisitor.cpp line 107.
>
>
>
> Can anyone look and hint to what might be causing this issue?
>
>
>
> It is almost as if my code and osg code are conflicting with some pointer
> somewhere and I am not sure how to mutex my code correctly.  Maybe it is my
> thread?  I am using a std::thread to run this function on.  Am I updating
> my layer wrong completely by removing and adding a new one?
>
>
>
> Thanks in advance.
>
>
>
> void mysimpleocean::mylayer_redraw(osg::ref_ptr<osgEarth::ImageLayer>
> layer) {
>
>     int width = 200;
>
>     int height = 200;
>
>
>
>     double wlon = -104.00;
>
>     double nlat = 49.00;
>
>     double elon = -96.00;
>
>     double slat = 45.00;
>
>
>
>     int target_height = 200;
>
>     int target_width = 200;
>
>
>
>     double geoTransform[6];
>
>     geoTransform[0] = wlon;
>
>     geoTransform[1] = (elon - wlon) / width;
>
>     geoTransform[2] = 0.00;
>
>     geoTransform[3] = nlat;
>
>     geoTransform[4] = 0.00;
>
>     geoTransform[5] = (slat - nlat) / height;
>
>
>
>     GDALAllRegister();
>
>     GDALDataset* nmemDS;
>
>     osgEarth::SpatialReference* srs = const_cast<osgEarth::
> SpatialReference*>(_map->getProfile()->getSRS());
>
>     GDALRasterBand* bandRed;
>
>     GDALRasterBand* bandGreen;
>
>     GDALRasterBand* bandBlue;
>
>     GDALRasterBand* bandAlpha;
>
>     osgEarth::Drivers::GDALOptions gdaloptions;
>
>     osg::ref_ptr<osgEarth::Drivers::GDALOptions::ExternalDataset> eds;
>
>     Threading::Mutex _mutex;
>
>     osg::ref_ptr<osgEarth::ImageLayer> tlayer;
>
>
>
>   int alpha = 143;
>
>   while (true) {
>
>     nmemDS = (GDALDataset*)GDALCreate(GDALGetDriverByName("MEM"), "",
> 200, 200, 0, GDT_Byte, nullptr);
>
>     GDALSetProjection(nmemDS, srs->getWKT().c_str());
>
>     GDALSetGeoTransform(nmemDS, geoTransform);
>
>
>
>     nmemDS->AddBand(GDT_Byte, nullptr);
>
>     nmemDS->AddBand(GDT_Byte, nullptr);
>
>     nmemDS->AddBand(GDT_Byte, nullptr);
>
>     nmemDS->AddBand(GDT_Byte, nullptr);
>
>
>
>     bandRed = nmemDS->GetRasterBand(1);
>
>     bandGreen = nmemDS->GetRasterBand(2);
>
>     bandBlue = nmemDS->GetRasterBand(3);
>
>     bandAlpha = nmemDS->GetRasterBand(4);
>
>
>
>     BYTE* rrowbuff = new BYTE[width];
>
>     BYTE* growbuff = new BYTE[width];
>
>     BYTE* browbuff = new BYTE[width];
>
>     BYTE* arowbuff = new BYTE[width];
>
>
>
>     for (int y = 0; y < height; y++) {
>
>       for (int x = 0; x < width; x++) {
>
>         rrowbuff[x] = (BYTE)255;
>
>         growbuff[x] = (BYTE)253;
>
>         browbuff[x] = (BYTE)143;
>
>         arowbuff[x] = (BYTE)alpha;
>
>
>
>       }
>
>       CPLErr rerr = bandRed->RasterIO(GF_Write, 0, 0, target_width,
> target_height, rrowbuff, target_width * ((elon - wlon) / target_width),
> target_height * abs((slat - nlat) / target_height), GDT_Byte, 4, 0);
>
>       CPLErr gerr = bandGreen->RasterIO(GF_Write, 0, 0, target_width,
> target_height, growbuff, target_width * ((elon - wlon) / target_width),
> target_height * abs((slat - nlat) / target_height), GDT_Byte, 4, 0);
>
>       CPLErr berr = bandBlue->RasterIO(GF_Write, 0, 0, target_width,
> target_height, browbuff, target_width * ((elon - wlon) / target_width),
> target_height * abs((slat - nlat) / target_height), GDT_Byte, 4, 0);
>
>       CPLErr aerr = bandAlpha->RasterIO(GF_Write, 0, 0, target_width,
> target_height, arowbuff, target_width * ((elon - wlon) / target_width),
> target_height * abs((slat - nlat) / target_height), GDT_Byte, 4, 0);
>
>     }
>
>
>
>     alpha = alpha + 10;
>
>     if (alpha > 255)
>
>       alpha = alpha - 255;
>
>
>
>     eds = new osgEarth::Drivers::GDALOptions::ExternalDataset(nmemDS, true
> );
>
>     gdaloptions.externalDataset() = eds;
>
>
>
>     tlayer = dynamic_cast<osgEarth::ImageLayer*>(_map->getLayerByName(
> "newlayer"));
>
>
>
>     tlayer->setDataVariance(osg::Object::DYNAMIC);
>
>     tlayer->getOrCreateStateSet()->setDataVariance(osg::Object::DYNAMIC);
>
>
>
>     // tlayer->disable("");
>
>     Threading::ScopedMutexLock exclusiveLock(_mutex);
>
>     _map->removeLayer(tlayer);
>
>
>
>     layer = new osgEarth::ImageLayer("newlayer", gdaloptions);
>
>
>
>     layer->setDataVariance(osg::Object::DYNAMIC);
>
>     layer->getOrCreateStateSet()->setDataVariance(osg::Object::DYNAMIC);
>
>
>
>     _map->addLayer(layer);
>
>
>
>     delete rrowbuff;
>
>     delete growbuff;
>
>     delete browbuff;
>
>     delete arowbuff;
>
>
>
>     Sleep(2000);
>
>
>
>   }
>
> }
>
> *From:* Shannon Peterson
> *Sent:* Friday, August 30, 2019 3:27 PM
> *To:* 'osg-users at lists.openscenegraph.org' <
> osg-users at lists.openscenegraph.org>
> *Subject:* questions about developing drivers for osg/osgEarth
>
>
>
> I have a few questions about how to build a driver to do some specific
> tasks in osgEarth.
>
>
>
> Simple example.
>
> Using simple ocean as an example replace the texture piece with
> geo-spacial image and then build a shader to add effect to the image.
>
> Ie. Arrowed line that changes color in towards the direction a path should
> be followed start to end.
>
>
>
> The shader piece can be figured out by us working with the shader code.
>
>
>
> The part I am having issues with is adding an arrow image or geometry
> polygon of an arrow to the map at the position I need it at to run the
> shader effect on.
>
>
>
> Is this the correct place to aske this sort of question or is there a
> different mailing list or thread I should use to get help with getting this
> designed.
>
>
>
> Thank you in advance
>
>
>
> Shannon Peterson
>
> speterson at idealaero.com
>
> The information contained in this email and any attachments is intended
> only for the personal and confidential use of the intended recipients. This
> email message may be or may contain privileged and confidential
> communications. If the reader of this e-mail is not an intended recipient,
> you are hereby notified that you have received this communication in error
> and that any retention, review, use, dissemination, distribution or copying
> of this communication or the information contained herein is strictly
> prohibited. If you have received this communication in error, please notify
> the sender immediately and delete the original message and all attachments
> from your system. The recipient should check this email and any attachments
> for the presence of viruses. The company accepts no liability for any
> damage caused, directly or indirectly, by any virus transmitted in this
> email. This communication may also contain data subject to U.S. export
> laws. If so, that data subject to the International Traffic in Arms
> Regulation (ITAR) cannot be disseminated, distributed or copied to foreign
> nationals, residing in the U.S. or abroad, absent the express prior
> approval of the U.S. Department of State. If you have received this
> communication in error, please notify the sender by reply e-mail and
> destroy the e-mail message and any physical copies made of the
> communication. Thank you.
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
>
>
> --
>
> Chris 'Xenon' Hanson, omo sanza lettere. Xenon at AlphaPixel.com
> http://www.alphapixel.com/
>
> Training • Consulting • Contracting
>
> 3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4
> • GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
>
> Legal/IP • Forensics • Imaging • UAVs • GIS • GPS •
> osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile •
> iPhone/iPad/iOS • Android
>
> @alphapixel <https://twitter.com/alphapixel> facebook.com/alphapixel (775)
> 623-PIXL [7495]
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
>
>
> --
>
> Chris 'Xenon' Hanson, omo sanza lettere. Xenon at AlphaPixel.com
> http://www.alphapixel.com/
>
> Training • Consulting • Contracting
>
> 3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4
> • GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
>
> Legal/IP • Forensics • Imaging • UAVs • GIS • GPS •
> osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile •
> iPhone/iPad/iOS • Android
>
> @alphapixel <https://twitter.com/alphapixel> facebook.com/alphapixel (775)
> 623-PIXL [7495]
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


-- 
Chris 'Xenon' Hanson, omo sanza lettere. Xenon at AlphaPixel.com
http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 •
GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging • UAVs • GIS • GPS •
osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile •
iPhone/iPad/iOS • Android
@alphapixel <https://twitter.com/alphapixel> facebook.com/alphapixel (775)
623-PIXL [7495]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20190919/c06d49fb/attachment.html>


More information about the osg-users mailing list