Overview
This driver will load the Makland terrain database and create an F-16 entity on start, attach the main observer to it, and then move the F16 a small amount each time that it's ticked. This example adds a driver via a plugin.
Expected Result
Example Driver Plugin Result
Example details
The example driver's onStart() method loads the database first.
It then creates a new entity facade and tells it to use the f-16_Falcon Visual Definition.
Using the coordinate system information provided by the loaded terrain database, the driver provides an initial position and orientation in the coordinate system of the database.
The current observer is then attached to the newly created entity, and reset to provide a perspective view.
The driver manager ticks the example driver by calling its onTick() method. The onTick() method updates the driver's local kinematic member variables and then passes them on to the entity facade.
The driver is stopped by the driver manager callings its onStop() method. This cleans up the entity facade allocated on the heap.
The example driver is created, added to the driver manager, and started in the main program.
{
de.driverManager().addDriver(driver);
de.driverManager().startDriver(driver);
The plugin registers the install function to be called after the DtDe has been initialized.
if (de.isInMasterMode())
{
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/exampleDriverPlugin_stealth.bat (on Windows) or ./bin64/exampleDriverPlugin_stealth.sh (on Linux). Press the "s" key to get away from the entity and see the HAT line. For more information about running examples, please see Running Applications and Examples.
Example Source Files
exampleDriver.h
#pragma once
#include <string>
{
public:
virtual const std::string&
className()
const;
protected:
protected:
};
exampleDriver.cxx
#ifdef SIM_IS_SHIP
#endif
using namespace makVrv;
: makVrv::
DtDriver(am,
"DtExampleDriver")
, myExampleSimEngine(0)
{
}
{
}
{
static std::string name = "DtExampleDriver";
return name;
}
{
maklandPath += "/terrains/Makland.mtf";
{
#ifdef SIM_IS_SHIP
#endif
}
{
}
#ifdef SIM_IS_SHIP
#else
#endif
return true;
}
{
{
}
return true;
}
{
{
}
return true;
}
{
driverManager().inputDriver().currentObserver();
std::set<std::string> displayNames;
displayNames.insert(entityName);
}
{
}
exampleSimEngine.h
#pragma once
#include <matrix/vlTaitBryan.h>
#include <matrix/vlVector.h>
#include <string>
namespace makVrv
{
class DtEntity3dFacade;
class DtEntityHATLineFacade;
class DtDe;
}
{
public:
bool tick(
double simTime);
protected:
#ifdef SIM_IS_SHIP
virtual void repositionShip(DtVector position, DtTaitBryan ori, double dT);
#else
#endif
protected:
#ifdef SIM_IS_SHIP
DtVector myLastPosition;
#endif
};
exampleSimEngine.cxx
#include <vrvCore/DtWakeModelAgent.hpp>
#include <vrvCore/DtSceneObjectAgent.hpp>
#include <matrix/LibMatrix.h>
using namespace makVrv;
: myDe(de)
, myEntityFacade(0)
, myEntityIndicator(0)
, myEntityInfoWidget(0)
, myEntityDisplayName("")
, myEntityInfoWidgetPinnedFlag(false)
, myPosition()
, myOrientation()
, myLastUpdateTime(0.0)
, myEntityHATLineFacade(0)
, myHeading(0.0)
, myLastCommLineTime(0.0)
#ifdef SIM_IS_SHIP
, myOrbitCenter(-9500.0, 17200.0, 10.0)
, myAngularVelocity(0.006)
, myClockAngle(0.0)
, myRadius(5000.0)
, myRoll(0.0)
, myLastPosition(-9500.0, 22200.0, 10.)
#else
, myOrbitCenter(2000.0, 1400.0, 350.0)
, myAngularVelocity(0.1)
, myClockAngle(0.0)
, myRadius(1000.0)
, myRoll(0.6)
#endif
{
}
{
#ifdef SIM_IS_SHIP
#else
#endif
DtSharedSettingsManager::instance(
myDe), elementId,
true);
#ifdef SIM_IS_SHIP
wakeModelAgent->setSprayEnabled(true);
wakeModelAgent->setBowSprayOffset(58.);
wakeModelAgent->setSpraySizeScale(3.);
wakeModelAgent->setNumHullSprays(5);
wakeModelAgent->setHullSprayStart(-155.);
wakeModelAgent->setHullSprayEnd(30.);
wakeModelAgent->setPropWashEnabled(true);
wakeModelAgent->setShipLength(300.);
wakeModelAgent->setBeamWidth(16.);
wakeModelAgent->setDraft(10.);
wakeModelAgent->setSprayVelocityScale(0.65);
wakeModelAgent->setBowWaveScale(1.);
wakeModelAgent->setBowSize(2.);
wakeModelAgent->setBowWaveOffset(70.);
wakeModelAgent->setSternWaveOffset(-60.);
wakeModelAgent->setWakeOffset(0.);
wakeModelAgent->setPropWashOffset(-75.);
wakeModelAgent->setPropWashFadeTime(30.);
wakeModelAgent->setMaxBowWaveAmplitude(5.);
wakeModelAgent->setHullSpraySizeScale(1.);
wakeModelAgent->setHullSprayVelocityScale(0.4);
wakeModelAgent->setHullSprayVerticalOffset(1.);
#else
#endif
DtStateVisualizer::EntityVisualizerType);
#ifndef SIM_IS_SHIP
#endif
mySignalConnections += selectMgr.signal_entityInfoToggled.connect(
boost::bind(
return true;
}
{
{
{
}
{
}
}
return true;
}
{
if (idList.size() == 0)
{
return 0;
}
if (updater)
{
}
return 0;
}
{
{
}
return true;
}
{
widgetSignaler);
if (active)
{
}
else
{
}
}
{
{
DtOverlayGroupManager::instance(myDe);
DtStateVisualizer::EntityVisualizerType);
}
{
}
}
{
DtReferenceEllipsoid refEllip(DtWGS84);
DtGeodeticCoord geod(&refEllip);
DtVector localp;
DtTaitBryan hpr;
const char* entityFormatString =
"Marking :%s\n"
"Heading :%.2f Deg\n"
"Lat|Lon :%.2fN %.fE\n"
"Alt. :%.1f m above sea level";
std::string buffer;
buffer.resize(1024, '0');
{
int charsWritten = sprintf(
const_cast<char*>(buffer.c_str()), entityFormatString,
DtRad2Deg(geod.lat()),
DtRad2Deg(geod.lon()),
);
buffer.resize(charsWritten, '0');
}
return DtUnicode::fromUtf8(buffer);
}
{
double now = simTime;
#ifdef SIM_IS_SHIP
#else
#endif
myLastUpdateTime = now;
}
#ifdef SIM_IS_SHIP
void DtExampleSimEngine::repositionShip(DtVector position, DtTaitBryan ori, double dt)
#else
#endif
{
if (coordConverter->
type() == DtCoordinateConverter::Geocentric)
{
DtGeodeticCoord geod(DtDeg2Rad(10.0), DtDeg2Rad(60.0), 0.0);
}
else
{
}
myEntityFacade->setOrientation(myOrientation);
myEntityFacade->setPosition(myPosition);
#ifdef SIM_IS_SHIP
DtVector vecDiff;
DtVector localVel;
DtVector velocity;
DtVecSub(position, myLastPosition, vecDiff);
myEntityFacade->setVelocity(DtVector64To32(velocity));
myLastPosition = position;
#endif
}
{
DtSelectionManager::IdSet::const_iterator i = sel.begin();
DtSelectionManager::IdSet::const_iterator e = sel.end();
{
{
}
}
}
exampleDriverPlugin.h
#pragma once
#ifdef _WIN32
#ifdef EXAMPLEDRIVERPLUGIN_EXPORTS
#define DT_DLL_EXAMPLEDRIVERPLUGIN __declspec ( dllexport )
#else
#define DT_DLL_EXAMPLEDRIVERPLUGIN __declspec ( dllimport )
#endif
#else
#define DT_DLL_EXAMPLEDRIVERPLUGIN
#endif
#define DT_DE_PLUGIN_EXPORT_MACRO DT_DLL_EXAMPLEDRIVERPLUGIN
exampleDriverPlugin.cxx
using namespace makVrv;
{
}
{
{
}
}
{
return true;
}
[<< Examples] [Home] [Top of Page]