[osg-users] questions about developing drivers for osg/osgEarth
Chris Hanson
xenon at alphapixel.com
Wed Sep 18 16:39:30 PDT 2019
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]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20190918/eb995aa7/attachment-0001.html>
More information about the osg-users
mailing list