Академический Документы
Профессиональный Документы
Культура Документы
#include <osgART/VideoLayer>
#include <osgART/PluginManager>
#include <osgART/VideoGeode>
#include <osgART/Utils>
#include <osgART/GeometryUtils>
#include <osgART/MarkerCallback>
#include <osgART/TransformFilterCallback>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgDB/FileUtils>
osgViewer::Viewer viewer;
// Open the video. This will not yet start the video stream but will
// get information about the format of the video which is essential
// for the connected tracker
video->open();
osg::ref_ptr<osgART::Tracker> tracker =
dynamic_cast<osgART::Tracker*>(osgART::PluginManager::instance()->get(_tracker_id));
if (!tracker.valid())
{
// Without tracker an AR application can not work. Quit if none found.
osg::notify(osg::FATAL) << "Could not initialize tracker plugin!" << std::endl;
exit(-1);
}
//++++++++++++++MAKER A
osg::ref_ptr<osg::MatrixTransform> arTransformA = new osg::MatrixTransform();
osgART::attachDefaultEventCallbacks(arTransformA.get(),markerA.get());
//++++++++++++++MAKER B
osg::ref_ptr<osg::MatrixTransform> arTransformB = new osg::MatrixTransform();
osgART::attachDefaultEventCallbacks(arTransformB.get(),markerB.get());
//+++++++++++++
osg::ref_ptr<osg::Group> videoBackground = createImageBackground(video.get());
videoBackground->getOrCreateStateSet()->setRenderBinDetails(0, "RenderBin");
cam->addChild(videoBackground.get());
root->addChild(cam.get());
video->start();
return viewer.run();
}
+++++++++++++++++++++++++++
#include <osgART/Foundation>
#include <osgART/VideoLayer>
#include <osgART/PluginManager>
#include <osgART/VideoGeode>
#include <osgART/Utils>
#include <osgART/GeometryUtils>
#include <osgART/MarkerCallback>
#include <osgART/TransformFilterCallback>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgDB/FileUtils>
osgViewer::Viewer viewer;
dynamic_cast<osgART::Video*>(osgART::PluginManager::instance()-
>get(_video_id));
// Open the video. This will not yet start the video stream but
will
// get information about the format of the video which is essential
// for the connected tracker
video->open();
osg::ref_ptr<osgART::Tracker> tracker =
dynamic_cast<osgART::Tracker*>(osgART::PluginManager::instance()-
>get(_tracker_id));
if (!tracker.valid())
{
// Without tracker an AR application can not work. Quit if
none found.
osg::notify(osg::FATAL) << "Could not initialize tracker
plugin!" << std::endl;
exit(-1);
}
//++++++++++++++MAKER A
osg::ref_ptr<osg::MatrixTransform> arTransformA = new
osg::MatrixTransform();
osgART::attachDefaultEventCallbacks(arTransformA.get(),markerA.get());
arTransformA->getOrCreateStateSet()->setRenderBinDetails(100,
"RenderBin");
cam->addChild(arTransformA.get());
osg::ref_ptr<osg::Group> videoBackground =
createImageBackground(video.get());
videoBackground->getOrCreateStateSet()->setRenderBinDetails(0,
"RenderBin");
cam->addChild(videoBackground.get());
root->addChild(cam.get());
video->start();
return viewer.run();