Last active
October 26, 2021 11:54
-
-
Save gwaldron/b04fc956a6efba047267c69ed914a1e0 to your computer and use it in GitHub Desktop.
ImageSequence example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <osgViewer/Viewer> | |
#include <osgEarth/Notify> | |
#include <osgEarth/EarthManipulator> | |
#include <osgEarth/MapNode> | |
#include <osg/ImageSequence> | |
#include <osgDB/ReadFile> | |
#include <osgEarth/ImageLayer> | |
using namespace osgEarth; | |
using namespace osgEarth::Util; | |
class SequenceLayer : public ImageLayer | |
{ | |
public: | |
struct Options : public ImageLayer::Options { | |
META_LayerOptions(osgEarth, Options, ImageLayer::Options); | |
//virtual Config getConfig() const { return ImageLayer::Options::getConfig(); } | |
private: | |
void fromConfig(const Config&) { } | |
}; | |
META_Layer(osgEarth, SequenceLayer, Options, ImageLayer, SequenceLayer); | |
void init() override { | |
ImageLayer::init(); | |
_image1 = osgDB::readRefImageFile("../data/icon.png"); | |
_image2 = osgDB::readRefImageFile("../data/placemark32.png"); | |
setProfile(Profile::create(Profile::GLOBAL_GEODETIC)); | |
setAsyncLoading(true); | |
} | |
GeoImage createImageImplementation(const TileKey& key, ProgressCallback* c) const override { | |
osg::ImageSequence* seq = new osg::ImageSequence(); | |
seq->addImage(_image1); | |
seq->addImage(_image2); | |
seq->setLoopingMode(seq->LOOPING); | |
seq->setLength(2.0); | |
seq->play(); | |
return GeoImage(seq, key.getExtent()); | |
} | |
osg::ref_ptr<osg::Image> _image1, _image2; | |
}; | |
int | |
main(int argc, char** argv) | |
{ | |
osgEarth::initialize(); | |
osg::ArgumentParser arguments(&argc,argv); | |
osgViewer::Viewer viewer(arguments); | |
viewer.setCameraManipulator( new EarthManipulator(arguments) ); | |
osg::ref_ptr<Map> map = new Map(); | |
map->addLayer(new SequenceLayer()); | |
auto mapNode = new MapNode(map.get()); | |
viewer.setSceneData( mapNode ); | |
return viewer.run(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment