

// headers
#include <osgGA/TrackballManipulator>
#include <osg/Drawable>
#include <osg/Timer>
#include <osgProducer/Viewer>
#include <osgCal/CoreModel>
#include <osgCal/Model>
  
//... 
// a lot of omitted code!
//...

//
// osgCal stuffs
//
// 1. create a core model, the template
osgCal::CoreModel *core = new osgCal::CoreModel("dummy");
load(core); //< loading some data into it
  
// 2. create a concrete model using the core template
osgCal::Model *model = new osgCal::Model();
model->create(core);

osgCal::Model *model_2 = new osgCal::Model();
model_2->create(core);
    
// 3. set the first animation in loop mode, 
//    weight 1, and starting just now
model->startLoop(0, 1.0f, 0.0f);
model_2->startLoop(1, 1.0f, 0.0f);
  
model_2->setTimeScale(1.5f);
  
// 4. add to scene graph 
osg::ref_ptr<osg::Group> escena = new osg::Group();
escena->addChild(model);
escena->addChild(model_2);
  
//
// Porducer/OSG roducer stuffs
//
// 5. construct the viewer.
osgProducer::Viewer viewer;
  
// 6. set up the value with sensible default event handlers.
//    see, viewer/model glue!
viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS);
viewer.setSceneData(escena.get());
unsigned int pos = viewer.addCameraManipulator(new MyManipulator(model));
viewer.selectCameraManipulator(pos);
viewer.realize();

// 7. main loop 
while ( !viewer.done() ) {
  viewer.sync();
  viewer.update();
  viewer.frame();
}
viewer.sync();
return 0;

