Re: [osg-users] [3rdparty] Use PNG as texture for terrain in osgEarth

2019-01-08 Thread Rodrigo Dias
So, I learned how to put HUD text, and I'm trying to understand the movement of 
the camera sending the camera's coordinates to this text. However, the three 
coordinates (heading, pitch and roll) are always 0 or pi, which seems more a 
rounding error than anything else. It seems the world is moving, instead of the 
camera, which I guess is the way that TrackballManipulator works. I want to 
move the camera around, using WASD keys and mouse movement, but still couldn't 
get it from the examples (like FirstPersonManipulator). I couldn't even manage 
to put the camera in a proper initial position! (Here's what I've tried so far: 
http://forum.openscenegraph.org/viewtopic.php?t=17623)

Other point is that, as you can see in the image below, the whole flat world is 
white, and Brazil is where it's supposed to be (southern and western 
hemispheres). But I'd like to have the world transparent instead of white, so 
only Brazil (or any selected country) would be visible.

[img]https://imgur.com/UVEGwuj[/img]

Here's my source code:


Code:
#include  // cout
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

using namespace std;
using namespace osg;
using namespace osgEarth;
using namespace osgEarth::Drivers;

osg::ref_ptr g_font = osgText::readFontFile("fonts/arial.ttf");

osg::Camera* createHUDCamera( double left, double right, double bottom, double 
top ) {
osg::ref_ptr camera = new osg::Camera;
camera->setReferenceFrame( osg::Transform::ABSOLUTE_RF );
camera->setClearMask( GL_DEPTH_BUFFER_BIT );
camera->setRenderOrder( osg::Camera::POST_RENDER );
camera->setAllowEventFocus( false );
camera->setProjectionMatrix( osg::Matrix::ortho2D(left, right, bottom, 
top) );
return camera.release();
}

osgText::Text* createText( const osg::Vec3& pos, const std::string& content, 
float size ) {
osg::ref_ptr text = new osgText::Text;
text->setFont( g_font.get() );
text->setCharacterSize( size );
text->setAxisAlignment( osgText::TextBase::XY_PLANE );
text->setPosition( pos );
text->setText( content, osgText::String::ENCODING_UTF8 );
return text.release();
}

Vec3d getHPRfromQuat(osg::Quat quat) {
double qx = quat.x();
double qy = quat.y();
double qz = quat.z();
double qw = quat.w();
double sqx = qx * qx;
double sqy = qy * qy;
double sqz = qz * qz;
double sqw = qw * qw;
double term1 = 2*(qx*qy+qw*qz);
double term2 = sqw+sqx-sqy-sqz;
double term3 = -2*(qx*qz-qw*qy);
double term4 = 2*(qw*qx+qy*qz);
double term5 = sqw - sqx - sqy + sqz;
double heading = atan2(term1, term2);
double pitch = atan2(term4, term5);
double roll = asin(term3);
return Vec3d( heading, pitch, roll );
}

int main (int argc, char** argv) {
// Cria o texto do HUD
osg::ref_ptr text1 = createText(osg::Vec3(10, 748, 
0),"Heading",10.0f);
osg::ref_ptr text2 = createText(osg::Vec3(10, 728, 
0),"Pitch",10.0f);
osg::ref_ptr text3 = createText(osg::Vec3(10, 708, 
0),"Roll",10.0f);

text1->setDataVariance(osg::Object::DYNAMIC); // pra poder mudar o 
texto depois
text2->setDataVariance(osg::Object::DYNAMIC); // pra poder mudar o 
texto depois
text3->setDataVariance(osg::Object::DYNAMIC); // pra poder mudar o 
texto depois

osg::ref_ptr textGeode = new osg::Geode;
textGeode->addDrawable( text1 );
textGeode->addDrawable( text2 );
textGeode->addDrawable( text3 );
osg::Camera* camera = createHUDCamera(0, 1024, 0, 768);
camera->addChild( textGeode.get() );
camera->getOrCreateStateSet()->setMode( GL_LIGHTING, 
osg::StateAttribute::OFF );

// Cria um Mapa na opção "projetado" para mostrar num plano (ao invés 
de num globo)
MapOptions mapOpt;
mapOpt.coordSysType() = MapOptions::CSTYPE_PROJECTED;
mapOpt.profile() = ProfileOptions("plate-carre");
osg::ref_ptr map = new Map(mapOpt);

// Adiciona uma camada de imagem/textura (vegetação do Brasil num 
GeoTiff)
{
GDALOptions gdal;
gdal.url() = "br_modified.tif";
//XMIN  XMAXYMINYMAX
//-74   -34.79  -33.84  5.37
osg::ref_ptr layer = new ImageLayer( "BR", gdal );
//layer->setOpacity(0.5);
printf("\nOpacity: %.2f\n",layer->getOpacity());
map->addLayer( layer );
}

// Adiciona uma camada de elevação (SRTM de um arquivo GeoTiff)
{
GDALOptions gdal;
gdal.url() = "BRalt.tif";
osg::ref_ptr layer = new ElevationLayer( 
"SRTM", gdal );
map->addLayer( layer );
}

// Cria um MapNode para renderizar este mapa
osg::ref_ptr mapNode = 

Re: [osg-users] Get Animation current time

2019-01-08 Thread Robert Osfield
Good to hear you've resolved the problems and got things working
really efficiently ;-)

On Tue, 8 Jan 2019 at 14:11, Diego Mancilla  wrote:
>
> Hello Robert,
>
> Thank you again.
>
>  It turns out that I forgot to initialize the _timeMultiplier variable on the 
> constructor of my AnimationPath class. Also I had a problem with some crazy 
> references retrieved wrongly: for some reason on a "for (auto e: stl_map)..." 
> loop, , was not getting the rigth address for the mapped value) so I 
> change the loop and everything works now.
>
>  When I use the original approach (filling control points on standard 
> AnimationPath) my code took about a minute per mobile object. Now, as the 
> data is referenced the time involved is almost zero.
>
> Cheers,
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=75430#75430
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Get Animation current time

2019-01-08 Thread Diego Mancilla
Hello Robert,

Thank you again.

 It turns out that I forgot to initialize the _timeMultiplier variable on the 
constructor of my AnimationPath class. Also I had a problem with some crazy 
references retrieved wrongly: for some reason on a "for (auto e: stl_map)..." 
loop, , was not getting the rigth address for the mapped value) so I 
change the loop and everything works now.

 When I use the original approach (filling control points on standard 
AnimationPath) my code took about a minute per mobile object. Now, as the data 
is referenced the time involved is almost zero.

Cheers,

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





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


Re: [osg-users] Can i use MatrixTransform to transform a HUD node?

2019-01-08 Thread Chen Gao
Well,Chris. Just as you assumed,my case is quite complicated. I have to make a 
growing up effect HUD, ie, dynamically scaled up one. Use Mt to scale the HUD 
node will never work since we set the camera ABSOLUTE_RF mode. Then i tried to 
use the setviewmatrix method to scale it up but this won't work,too. 

The only way I 've found working is to scale up the raw image passed to 
draw the pic. The drawable can be a texture or a drawpixels and i use the 
latter one. To enable dynamic effect, I have to use a custom NodeCallBack class 
to handle it. Each callback time I have to set and scale the image to the 
drawpixels to show a growing up scaled size.
   But since I saw the HUD content of your github link, I guess the 
SnapImage struct the author creates may be a new way to handle this job.I 'll 
try it in the next following days. Thank you,guy!|-) 
 

Chris Hanson wrote:
> 
> 
>   I was just trying to be thorough and complete because I wasn't clear on the 
> situation, so I was throwing all possibilities out there to see if that was 
> the reason I wasn't getting it.
> 
> 
>   Normally making a HUD is pretty straightforward ( 
> https://github.com/openscenegraph/OpenSceneGraph/tree/master/examples/osghud 
> (https://github.com/openscenegraph/OpenSceneGraph/tree/master/examples/osghud)
>  ) so I assumed this must be a more complex case. 
> 


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





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


Re: [osg-users] Can i use MatrixTransform to transform a HUD node?

2019-01-08 Thread Chen Gao
Yeah,Terry. #1 is the exactly the right way to use HUD. I've been trying these 
days to use MT transformation method to operate the child HUD node but it will 
never be able to control it because i found that I've used the following line 
of code:

camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); 

 When I looked up the detailed explanation of this code on the net,I 
realized that MT will never be working on it.If we want to control its 
position, we only have to and only need to use the camera node itself.That will 
be Ok.

   I haven't tried to delete this line code and then use MT to 
control the camera node, but I guess that will result in a bad effect and I 
haven't seen anyone on the net to use HUD this way. So |-) just don't care 
about it. 


Terry Welsh wrote:
> I have only done #1, where the HUD node is derived from osg::Camera. I
> set the view matrix and projection matrix to provide a simple box in
> which to render all HUD elements. The individual elements can be
> positioned within that box with MatrixTransforms.
> 
> It's not very hard to get this working. Try prototyping it with one
> osgText::Text element and one simple box or sphere under a
> MatrixTransform.
> 
> - Terry
> ___
> osg-users mailing list
> 
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 
>  --
> Post generated by Mail2Forum


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





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


Re: [osg-users] [3rdparty] Use PNG as texture for terrain in osgEarth

2019-01-08 Thread Rodrigo Dias


> If you feed the TIFF LWZ coder the same 4-bit data as the PNG is made form, I 
> would think it would code about as efficiently, even if the data is stored in 
> an 8-bit representation.


I used QGIS to convert from PNG to TIFF. The image only has 16 colors, so maybe 
it's QGIS fault. Later I may try to convert it to a smaller bit depth to save 
space (considering I want to use one map for each country in the world, that'll 
make some difference). But that's not a priority now.


> What is the bit depth of the TIFF?


8 bits as well.


> Have you told osgEarth how to scale the elevation from the TIFF file into 
> real world units?


It seems that's exactly what I need, but I don't know how to do it.

Thank you!

Cheers,
Rodrigo

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





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


Re: [osg-users] [3rdparty] Use PNG as texture for terrain in osgEarth

2019-01-08 Thread Chris Hanson
If you feed the TIFF LWZ coder the same 4-bit data as the PNG is made form,
I would think it would code about as efficiently, even if the data is
stored in an 8-bit representation. Forward-dictionary compression systems
work on how many unique symbols are found and if you make a 16m color image
with only 256 colors, it'll only take 256 symbol table entries to store.

I'm not sure why the TIFF wouldn't be displaying. What is the bit depth of
the TIFF? Have you told osgEarth how to scale the elevation from the TIFF
file into real world units? If it's an 8-bit TIFF, you are only feeding it
up to 256m of elevation which won't look like much for the Andes.

On Tue, Jan 8, 2019 at 12:32 PM Rodrigo Dias  wrote:

> Hi,
>
> Sorry, I didn't post the updated code:
>
>
> Code:
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
>
> using namespace std;
> using namespace osg;
> using namespace osgEarth;
> using namespace osgEarth::Drivers;
>
> int main (int argc, char** argv) {
> MapOptions mapOpt;
> mapOpt.coordSysType() = MapOptions::CSTYPE_PROJECTED;
> mapOpt.profile() = ProfileOptions("plate-carre");
> osg::ref_ptr map = new Map(mapOpt);
> {
> GDALOptions gdal;
> gdal.url() = "br_modified.tif";
> osg::ref_ptr layer = new ImageLayer( "BR",
> gdal );
> map->addLayer( layer );
> }
> {
> GDALOptions gdal;
> gdal.url() = "BRalt.tif";
> osg::ref_ptr layer = new ElevationLayer(
> "SRTM", gdal );
> map->addLayer( layer );
> }
> osg::ref_ptr mapNode = new MapNode( map );
> osgViewer::Viewer viewer;
> viewer.setSceneData( mapNode.get() );
> viewer.setCameraManipulator( new osgGA::TrackballManipulator );
> while ( !viewer.done() ) {
> viewer.frame();
> }
> return 0;
> }
>
>
>
>
> As you can see, I guess I should be seeing some elevation by now, since my
> image is a square around Brazil, and it includes a good portion of the
> Andes mountain range (with higher pixels closer to white, and sea level in
> black).
>
> The texture file is 4392x4392 pixels (1.6 MB on PNG/4-bit-depth and 2.6 MB
> on TIFF/LZW/8-bit-depth, the difference seems due to bit depth, and I'm not
> sure if I can use a 4-bit TIFF, but that's ok by now; I'll also try tiling
> later). The elevation file is 588x588 pixels (70 kB). Both TIFFs are
> GeoTIFFs.
>
> What I'm trying to accomplish is this:
> https://www.youtube.com/watch?v=vVm_qWeB9wg
>
> Thank you!
>
> Cheers,
> Rodrigo
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=75423#75423
>
>
>
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


-- 
Chris 'Xenon' Hanson, omo sanza lettere. xe...@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  facebook.com/alphapixel (775)
623-PIXL [7495]
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [forum] CMake can't find libraries

2019-01-08 Thread Rodrigo Dias
Hi,

Well, I formatted my computer and installed a new Debian version (9.6). 
Installed a fresh copy of OSG, but still got the same error. Probably there's 
some variable missing, but since nobody tells us which variable it is, I said 
"f*** cmake" and compiled from command line. I've tried adding an OSG_ROOT 
variable, pointing to /usr/local, /usr/local/lib and /usr/local/lib64. None 
worked.

This command line works:


Code:
g++ main.cpp -lOpenThreads -losg -losgDB -losgUtil -losgViewer -o main



Even this works:


Code:
g++ main.cpp -losg -losgDB -losgViewer -o main



Thank you!

Cheers,
Rodrigo

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





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


Re: [osg-users] [3rdparty] Use PNG as texture for terrain in osgEarth

2019-01-08 Thread Rodrigo Dias
Hi,

Sorry, I didn't post the updated code:


Code:
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

using namespace std;
using namespace osg;
using namespace osgEarth;
using namespace osgEarth::Drivers;

int main (int argc, char** argv) {
MapOptions mapOpt;
mapOpt.coordSysType() = MapOptions::CSTYPE_PROJECTED;
mapOpt.profile() = ProfileOptions("plate-carre");
osg::ref_ptr map = new Map(mapOpt);
{
GDALOptions gdal;
gdal.url() = "br_modified.tif";
osg::ref_ptr layer = new ImageLayer( "BR", gdal );
map->addLayer( layer );
}
{
GDALOptions gdal;
gdal.url() = "BRalt.tif";
osg::ref_ptr layer = new ElevationLayer( 
"SRTM", gdal );
map->addLayer( layer );
}
osg::ref_ptr mapNode = new MapNode( map );
osgViewer::Viewer viewer;
viewer.setSceneData( mapNode.get() );
viewer.setCameraManipulator( new osgGA::TrackballManipulator );
while ( !viewer.done() ) {
viewer.frame();
}
return 0;
}




As you can see, I guess I should be seeing some elevation by now, since my 
image is a square around Brazil, and it includes a good portion of the Andes 
mountain range (with higher pixels closer to white, and sea level in black).

The texture file is 4392x4392 pixels (1.6 MB on PNG/4-bit-depth and 2.6 MB on 
TIFF/LZW/8-bit-depth, the difference seems due to bit depth, and I'm not sure 
if I can use a 4-bit TIFF, but that's ok by now; I'll also try tiling later). 
The elevation file is 588x588 pixels (70 kB). Both TIFFs are GeoTIFFs.

What I'm trying to accomplish is this: 
https://www.youtube.com/watch?v=vVm_qWeB9wg

Thank you!

Cheers,
Rodrigo

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





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


Re: [osg-users] Can i use MatrixTransform to transform a HUD node?

2019-01-08 Thread Chris Hanson
>
> Chris, I assumed your first idea. AR labels never crossed my mind.
> Maybe Chen can tell us if I made the right assumption.
>

  I was just trying to be thorough and complete because I wasn't clear on
the situation, so I was throwing all possibilities out there to see if that
was the reason I wasn't getting it.

  Normally making a HUD is pretty straightforward (
https://github.com/openscenegraph/OpenSceneGraph/tree/master/examples/osghud
) so I assumed this must be a more complex case.

-- 
Chris 'Xenon' Hanson, omo sanza lettere. xe...@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  facebook.com/alphapixel (775)
623-PIXL [7495]
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [3rdparty] Use PNG as texture for terrain in osgEarth

2019-01-08 Thread Chris Hanson
How big is the TIFF and the PNG? They use similar compression methods (PNG
is ZIP/Deflate and compressed TIFF is usually LZW and can also use
ZIP/Deflate) so you ought to be able to get them fairly close in size. What
are the total pixel dimensions of the image? Your best result might not be
from using a single large, untiled image. Most of the time you will have
better performance (but larger file size) by pre-tiling the image into a
TileMap Set like a MapBox Tile set (stored as an SQLite database file,
usually).

There probably is a trick to apply georeferencing (like a World File) to a
PNG file through GDAL, but it's just not usually done or a good idea. This
may be a case where you're asking the wrong question. Tell us what you're
trying to accomplish in the larger sense so we can make sure you're
attacking the correct problem.

As far as Elevation -- have you added an elevation data source layer? The
code you referenced adds elevation data from a local file but yours does
not. It would look something like this:

// Add an elevationlayer (SRTM from a local GeoTiff file){
GDALOptions gdal;
gdal.url() = "c:/data/srtm.tif";
ElevationLayer* layer = new ElevationLayer( "SRTM", gdal );
map->addElevationLayer( layer );}


You can also use TileMap Sets hosted either as a file on your local disk,
or served up over the Internet from an HTTP Tile Map Server. Pelican
Mapping operates the ReadyMap server for this purpose and you can use it at
no charge for low-traffic testing and development purposes but it needs to
be licensed for production use.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [forum] CMake can't find libraries

2019-01-08 Thread Luis Izquierdo Mesa
Hi Rodrigo. I have exactly the same problem, with the same book in this page. I 
am using Ubuntu 18.04. I am able to compile osg but not to run the exmple in 
page 44.

... 


Thank you!

Cheers,
Luis

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





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


Re: [osg-users] Get Animation current time

2019-01-08 Thread Robert Osfield
HI Diego,

I can point you in the right direction but I can't sit beside you and
walk through your code in a debugger.  When figuring out a crash this
is what is needed.

The only thing I can add is that using raw C pointer is generally a
red flag and one should be very cautious about doing so.  The OSG uses
a combination of ref_ptr<> that using ref counting to retain ownership
and observer_ptr<> to hold a pointer where no ownership is intended
(it's a form of weak_ptr<>,)   For you app it might be that either
might be appropriate, it's your application I can't make these
judgements for you.

Robert.

On Mon, 7 Jan 2019 at 19:30, Diego Mancilla  wrote:
>
> Hello Robert,
>
> Thank you very much for you complete response.
>
>  I'm trying to do what you suggest and have my on 
> AnimationPath/AnimationPathCallback classes that handle my data. But I 
> stumble into a problem.
>
>  When I subclass AnimationPath and AnimationPathCallback I have no problems. 
> But when I wrote my own classes, from scratch my application crashes.
>
>  In order to achieve what I want, I pass a pointer to a custom data container 
> class to my AnimationPath class (I called it MobilesAnimationPath) from my 
> main application. I tried to keep most part of the architecture of 
> AnimationPath, but I eliminate the TimeControlPointMap container. So, now my 
> class generates the control points from the data pointed from custom data 
> pointer class.
>
>
> So, for instance, my custom Path class looks like this:
>
>
> Code:
> #include "MobileObject.h"
> #include 
> #include 
>
> using namespace osg;
>
> class MobilesAnimationPath: public virtual osg::Object
> {
> public:
> MobilesAnimationPath();
> MobilesAnimationPath(const MobilesAnimationPath &, const osg::CopyOp 
> & copyop = osg::CopyOp::SHALLOW_COPY);
> MobilesAnimationPath(MobileObject & mobile);
>
> META_Object(osg, MobilesAnimationPath); //Visual Studio complains 
> about this line, but compiles... : "function definition for META_Object not 
> found"
>
> enum LoopMode
> {
> SWING,
> LOOP,
> NO_LOOPING
> };
>
> void setLoopMode(LoopMode loopMode);
> LoopMode getLoopMode() const;
>
> virtual bool getInterpolatedControlPoint(double time, 
> osg::AnimationPath::ControlPoint & cp) const;
>
> double getFirstTime() const;
> double getLastTime() const;
> double getPeriod() const;
>
> protected:
> ~MobilesAnimationPath(){};
>
> private:
> MobileObject * _mobile;
> LoopMode _loopMode;
>
> };
>
>
>
> And the implementation.
>
>
> Code:
> #include "MobilesAnimationPath.h"
>
> MobilesAnimationPath::MobilesAnimationPath()
> :_loopMode(NO_LOOPING)
> ,_mobile(nullptr)
> {
> }
>
>
> MobilesAnimationPath::MobilesAnimationPath(const MobilesAnimationPath& ap, 
> const osg::CopyOp& copyop)
> :osg::Object(ap, copyop)
> ,_loopMode(ap._loopMode)
> ,_mobile(ap._mobile)
> {
> }
>
> MobilesAnimationPath::MobilesAnimationPath(MobileObject & mobile)
> :_loopMode(NO_LOOPING)
> {
> _mobile = 
> }
>
> void MobilesAnimationPath::setLoopMode(LoopMode loopMode)
> {
> _loopMode = loopMode;
> }
>
> MobilesAnimationPath::LoopMode MobilesAnimationPath::getLoopMode() const
> {
> return _loopMode;
> }
>
> double MobilesAnimationPath::getFirstTime() const
> {
> if (_mobile != nullptr)
> {
> if (_mobile->dataLoaded())
> {
> return _mobile->getFirstTime();
> }
> }
> return 0.0;
> }
>
> double MobilesAnimationPath::getLastTime() const
> {
> if (_mobile != nullptr)
> {
> if (_mobile->dataLoaded())
> {
> return _mobile->getLastTime();
> }
> }
> return 0.0;
> }
>
> double MobilesAnimationPath::getPeriod() const
> {
> if (_mobile != nullptr)
> {
> if (_mobile->dataLoaded())
> {
> return _mobile->getFirstTime() - 
> _mobile->getLastTime();
> }
> }
> return 0.0;
> }
>
> bool MobilesAnimationPath::getInterpolatedControlPoint(double time, 
> osg::AnimationPath::ControlPoint & cp) const
> {
> if (_mobile == nullptr) return false;
> if (!_mobile->dataLoaded()) return false;
>
> // at this point _mobile points something thats not nullptr but 
> returns garbage...
>
> switch (_loopMode)
> {
> case(SWING):
> {
> double modulated_time = (time - getFirstTime()) / 
> (getPeriod()*2.0);
> double fraction_part = modulated_time - floor(modulated_time);
> if (fraction_part > 0.5) fraction_part = 1.0 - fraction_part;
>
> time = getFirstTime() + (fraction_part*2.0) *