Overview
This DtDistributedDraw driver owns a DtExampleDrawObject, and is responsible for keeping track of the draw object's state and creating or destroying it when the driver is started or stopped.
Expected Result
Distributed Draw Result
Example details
DtExampleDrawObject is the implementation of the distributed draw object. When a DtExampleDrawObjectAgent is created on the master, an exampleDrawObject is created locally on each display engine.
Building the Example
VR-Vantage includes pre-built versions of the example plug-in. To build it yourself, follow the instructions at Building VR-Vantage Examples, Applications, and Plug-ins.
Running the Example
This example is a plug-in. You can run it by running ./bin64/exampleDistributedDraw_stealth.bat and ./bin64/exampleDistributedDraw_slave.bat (on Windows) or ./bin64/exampleDistributedDraw_stealth.sh and ./bin64/exampleDistributedDraw_slave.sh (on Linux). In Vantage, load Ground_DB II terrain than from the "Observer Views" panel click on "import and append views" and select "exampleDrawObjectsGroundDbView.osrx" then click on "remoteGraphicsView". If you also started "exampleDistributedDraw_slave", connect the remote display engine by first enabling from the menu "view->Display Engine Configuration Editor Panel". In the "Display Engine Configuration Editor Panel" click on "Connect To Display Engine", set the host name (leave it to localhost if you are running both on the same PC), click connect. Press the "F" key to create a sphere and see it display on both window.
For more information about running examples, please see Running Applications and Examples.
Example Source Files
DtExampleModel.cxx
#ifndef DtDistributedDrawDriver_H_
#define DtDistributedDrawDriver_H_
#include "DtExampleDrawObjectAgent.hpp"
using namespace makVrv;
{
public:
const std::string& instanceName);
virtual const std::string& className() const;
virtual void drawRandomSphere();
protected:
virtual bool onStart();
virtual bool onStop();
virtual void slot_displayEngineAdded(
const DtDeRecord& igRecord );
virtual bool onTick();
virtual void updateSphere();
DtExampleDrawObjectAgent* myDrawAgent;
double mySphereX, mySphereY, mySphereZ;
bool mySphereInScene;
};
#endif
DtExampleModel.h
#ifndef DtExampleDrawObject_H_
#define DtExampleDrawObject_H_
#include <osg/Node>
#include <string>
namespace makVrv
{
class DtExampleDrawObject
{
public:
void drawSphere(
double x,
double y,
double z,
double r);
protected:
osg::ref_ptr<osg::Node>
myNode;
};
}
#endif
DtExampleModelInstance.cxx
DtExampleModelInstance.h
#include <functional>
using namespace makVrv;
static vrvSignalsLib::connection postInitializeConnection;
{
{
}
}
{
return true;
}
{
postInitializeConnection.disconnect();
if ( obsFrame )
{
}
}
DtExampleModelManager.cxx
#include <osg/Group>
#include <osg/Node>
#include <osg/Geode>
#include <osg/ShapeDrawable>
#include <osg/Material>
namespace makVrv
{
: myDe(de)
, myNode()
{
}
DtExampleDrawObject::~DtExampleDrawObject()
{
if (myNode.valid())
{
removeChildFromAllRoots();
}
}
void DtExampleDrawObject::removeChildFromAllRoots()
{
const DtModelSetRealizationManager& manager = myDe.sharedState().modelSetRealizationManager();
DtModelSetRealizationManager::ModelSetRealizations::const_iterator iter = manager.modelSetRealizations().begin();
DtModelSetRealizationManager::ModelSetRealizations::const_iterator end = manager.modelSetRealizations().end();
while (iter != end)
{
if (iter->second)
{
((DtOsgRenderer&)myDe.renderer()).removeNodeFromRoot( myNode.get(),
DtOsgRenderer::visualizerTypeRoot( iter->first, 0 ) );
}
++iter;
}
myNode = 0;
}
void DtExampleDrawObject::drawSphere(double x, double y, double z, double r)
{
if (myNode.valid())
{
removeChildFromAllRoots();
myNode = 0;
}
osg::Geode* geode = new osg::Geode;
geode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(x,y,z), r)));
myNode = geode;
osg::Material* mat = new osg::Material();
mat->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(0.25f, 0.40f, 0.55f, 1.0f));
mat->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(0.5f, 0.8f, 0.35f, 1.0f));
geode->getOrCreateStateSet()->setAttributeAndModes(mat);
const DtModelSetRealizationManager& manager = myDe.sharedState().modelSetRealizationManager();
DtModelSetRealizationManager::ModelSetRealizations::const_iterator iter = manager.modelSetRealizations().begin();
DtModelSetRealizationManager::ModelSetRealizations::const_iterator end = manager.modelSetRealizations().end();
while (iter != end)
{
if (iter->second)
{
((DtOsgRenderer&)myDe.renderer()).addNodeToRoot( myNode.get(),
DtOsgRenderer::visualizerTypeRoot( iter->first, 0 ) );
}
++iter;
}
}
}
DtExampleModelManager.h
#include <stdlib.h>
: DtDriver(agentManager, instanceName)
, myDrawAgent(0)
, mySphereInScene(false)
, mySphereX(0.0)
, mySphereY(0.0)
, mySphereZ(0.0)
{
setAutoStart(true);
myUserControllableFlag = false;
}
{
}
{
static std::string name("DtDistributedDrawDriver");
return name;
}
{
{
}
return true;
}
{
{
}
return true;
}
{
return true;
}
{
if (DtDriver::myStartedFlag)
{
}
}
{
}
{
}
[<< Examples] [Home] [Top of Page]