This driver will load the Ground_DB II 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.
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.
The plugin registers the install function to be called after the DtDe has been initialized.
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.
#pragma once
#include <matrix/vlTaitBryan.h>
#include <matrix/vlVector.h>
#include <string>
{
class DtEntity3dFacade;
class DtEntityHATLineFacade;
class DtDe;
class DtCoordinateSystem;
}
{
public:
bool tick(
double simTime);
protected:
bool pinAllLabels);
#ifdef SIM_IS_SHIP
virtual void repositionShip(DtVector position, DtTaitBryan ori, double dT);
#else
#endif
protected:
#ifdef SIM_IS_SHIP
DtVector myLastPosition;
#endif
};
Contains makVrv:DtSelectionManager class.
Base class to provide boost signal/slot management.
makVrv::DtEntityHATLineFacade * myEntityHATLineFacade
Definition exampleDriver/DtExampleSimEngine.h:123
DtTaitBryan myOrientation
Definition exampleDriver/DtExampleSimEngine.h:128
double myRadius
Definition exampleDriver/DtExampleSimEngine.h:143
makVrv::DtCoordinateSystem * myCoordinateSystem
Definition exampleDriver/DtExampleSimEngine.h:150
DtExampleSimEngine(makVrv::DtDe &de)
double myLastUpdateTime
Definition exampleDriver/DtExampleSimEngine.h:138
makVrv::DtEntity3dFacade * myEntityFacade
Definition exampleDriver/DtExampleSimEngine.h:120
double myLastCommLineTime
Definition exampleDriver/DtExampleSimEngine.h:137
makVrv::vrvSignalsLib::connection myMouseLeaveConnection
Definition exampleDriver/DtExampleSimEngine.h:153
double myHeading
Definition exampleDriver/DtExampleSimEngine.h:135
std::string myEntityDisplayName
Definition exampleDriver/DtExampleSimEngine.h:125
virtual void setEntityInfoWidgetActive(bool active)
Sets whether the entity info widget is displayed or not.
makVrv::DtDe & myDe
Definition exampleDriver/DtExampleSimEngine.h:118
double myRoll
Definition exampleDriver/DtExampleSimEngine.h:144
makVrv::DtEntityInfoWidget * myEntityInfoWidget
Definition exampleDriver/DtExampleSimEngine.h:122
makVrv::DtSignalConnectionManager mySignalConnections
Definition exampleSimEngine.h:143
virtual ~DtExampleSimEngine()
DTOR.
virtual void setHoverSignalsActive(bool active)
void slot_infoLabelsArePinned(const makVrv::DtSelectionManager::IdSet &pinOrUnpinList, bool pinAllLabels)
DtVector myPosition
Definition exampleDriver/DtExampleSimEngine.h:129
double myClockAngle
Definition exampleDriver/DtExampleSimEngine.h:142
virtual void updatePosition(double simTime)
Updates the current position / orientation of the entity.
virtual makVrv::DtUnicode generateInfoString() const
Generates the information string displayed in the entity info widget.
bool tick(double simTime)
bool myEntityInfoWidgetPinnedFlag
Definition exampleDriver/DtExampleSimEngine.h:126
makVrv::DtEntityIndicatorWidget * myEntityIndicator
Definition exampleDriver/DtExampleSimEngine.h:121
virtual void slot_coordinateSystemChanged()
slot for when the coordinate system changes
virtual void repositionAircraft(DtVector position, DtTaitBryan ori)
Positions the aircraft at the given position with the given orientation.
makVrv::vrvSignalsLib::connection myMouseEnterConnection
Definition exampleDriver/DtExampleSimEngine.h:152
double myAngularVelocity
Definition exampleDriver/DtExampleSimEngine.h:141
DtVector myOrbitCenter
Definition exampleDriver/DtExampleSimEngine.h:140
The DtCoordinateSystem is used to manage the current coordinate system of the scene.
Definition DtCoordinateSystem.h:41
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer,...
Definition DtDe.h:77
The DtEntity3dFacade is a facade around agents that make up an entity in the 3D model set.
Definition DtEntity3dFacade.h:40
Class for height above terrain line to show height above terrain line and label.
Definition DtEntityHATLineFacade.h:35
std::set< DtUniqueID > IdSet
Definition DtSelectionManager.h:32
Class to manage disconnection of boost connections on deletion.
Definition DtSignalConnectionManager.h:21
Definition DtUnicode.h:34
Contains DtCreateSensorFieldOfViewCommand and DtCreateSensorFieldOfViewCommandCreator class declarati...
Definition DtGridLinesSettingsRecord.h:16
#include <matrix/LibMatrix.h>
#include <boost/bind/bind.hpp>
: 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(0.0, 0.0, 350.0)
, myAngularVelocity(0.1)
, myClockAngle(0.0)
, myRadius(1000.0)
, myRoll(0.6)
#endif
{
myCoordinateSystem = myDe.sharedState().coordinateSystem().clone();
if (myCoordinateSystem == nullptr)
{
DtTHROW_NEW(DtCorruptedState, "myDe.sharedState().coordinateSystem().clone() failed.");
}
slot_coordinateSystemChanged();
}
{
}
{
}
{
#ifdef SIM_IS_SHIP
#else
#endif
DtSharedSettingsManager::instance(
myDe), elementId,
true);
#ifdef SIM_IS_SHIP
myEntityFacade->setArticulatedModelDefinition(
"SurfaceWatercraftDDG151Arleigh-BurkeNavy");
#else
myEntityFacade->setArticulatedModelDefinition(
"FixedWingRQ-1Predator");
#endif
DtElementChanges changes;
changes.
myElementsAdded.push_back(
new DtElementEntry(elementId, parentElementId, DtElementEntry::Entity));
myDe.dataBank().elementData().applyChanges(changes);
DtStateVisualizer::EntityVisualizerType);
#ifndef SIM_IS_SHIP
#endif
DtSelectionManager& selectMgr(DtSelectionManager::instance(
myDe));
return true;
}
{
{
{
}
{
}
DtElementChanges changes;
myDe.dataBank().elementData().applyChanges(changes);
}
return true;
}
{
if (idList.size() == 0)
{
return 0;
}
if (updater)
{
}
return 0;
}
{
{
}
return true;
}
{
DtWidgetSignaler& widgetSignaler =
DtWidgetSignaler::instance(
myDe.mainEventQueue());
widgetSignaler);
if (active)
{
}
else
{
}
}
{
{
DtOverlayGroupManager& groupManager =
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
}
#ifdef SIM_IS_SHIP
void DtExampleSimEngine::repositionShip(DtVector position, DtTaitBryan ori, double dt)
#else
#endif
{
coordConverter = myCoordinateSystem->converter();
{
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();
for (; i != e; ++i)
{
{
}
}
}
Contains makVrv:DtAgentManager class.
Contains makVrv::DtAgentUpdateResolver class.
Contains makVrv::DtDataBank class.
Contains makVrv::DtDe class.
Contains makVrv::DtDeSharedState class.
Contains makVrv::DtDeSharedStateSignaler class.
Contains makVrv:DtMasterScene class.
Contains makVrv::DtElementAttributes class.
Contains makVrv::DtEntity3dFacade class.
Contains the DtEntityHATLineFacade.h class declaration.
Contains makVrv::DtObserver class.
Contains the DtOverlayGroupManager class declaration.
Contains makVrv::DtScene class.
Contains makVrv::DtSceneObject class.
Contains makVrv::DtSharedSettingsManager class.
Contains makVrv:DtStateVisualizer class.
virtual DtAgentUpdateResolverInterface * findUpdater(DtUniqueID id)
Find the update handler for a particular object id.
Abstract base class for object updaters.
Definition DtAgentUpdateResolverInterface.h:21
ObjectType * castObjectTypeFromUpdater(const std::string &className)
Attempt to cast an object from an updater using the className. It is vital that the class name is the...
Definition DtAgentUpdateResolverInterface.h:35
DtCoordinateConverter is the base class for 'local (cig) to geocentric' converters.
Definition DtCoordinateConverter.h:26
virtual const std::string & type() const
Get converter type - this base class type is NoOp.
virtual DtTaitBryan nedToCig_EulerTrans(const DtTaitBryan &topo) const
provide cig euler angles from topo euler
static const char * Geocentric
Does no conversion.
Definition DtCoordinateConverter.h:30
virtual void setupTopoFrame(const DtVector &truth)
virtual void enuToCig_vecTrans(const DtVector &enuVec, DtVector &cigVec) const
convert to Cig vector from Enu vector
virtual void enuToCig_coordTrans(const DtVector &enuPos, DtVector &cigPos) const
convert to Cig coordinates from Enu coordinates
const std::string & type() const
bool set(const std::string &type, const std::string &origin)
const std::string & parameters() const
The coordinate system parameters.
DtElementData & elementData()
Get element data. DtElementData contains data that is common to all VR-Vantage elements,...
DtAgentManager & agentManager()
Get the scene manager.
virtual DtDataBank & dataBank()
The DtDataBank accessor.
virtual DtDeSharedState & sharedState()
Returns the DtDeSharedState object.
const DtCoordinateSystem & coordinateSystem() const
Get the coordinate system.
static DtDeSharedStateSignaler & instance(DtDe &de)
Get an instance used to emit, or to connect.
ElementAttributeMap myAttributesChanged
Definition DtElementChanges.h:55
UniqueIdList myElementsDeleted
Definition DtElementChanges.h:54
ElementPointerList myElementsAdded
Definition DtElementChanges.h:53
virtual void getSceneObjectIds(const DtElementID &elementID, SceneObjectIdList &outputList, DtModelSetId modelSet=DtModelSetId::Unspecified) const
Get the scene object ID from the specified modelset that is associated with an element ID (or all sce...
std::vector< DtUniqueID > SceneObjectIdList
Public Type Definitions.
Definition DtElementData.h:38
virtual unsigned int nextGroupId(const std::string &groupSetName)
Returns the next available group id for the given set. Obtains the group id generator for the set wit...
A DtSceneObject represents an object that can be positioned in the scene by (possibly) attaching it t...
Definition DtSceneObject.h:45
virtual void setHullSprayStart(double offset)=0
virtual void setPropWashOffset(double offset)=0
virtual void setShipLength(double shipLength)=0
virtual void setPropWashFadeTime(double fadeTime)=0
virtual void setSternWaveOffset(double offset)=0
virtual void setBowSize(double size)=0
virtual void setSpraySizeScale(double scale)=0
virtual void setBowWaveScale(double scale)=0
virtual void setHullSprayVerticalOffset(double offset)=0
virtual void setHullSprayEnd(double offset)=0
virtual void setHullSpraySizeScale(double scale)=0
virtual void setBowSprayOffset(double offset)=0
virtual void setBowWaveOffset(double offset)=0
virtual void setBeamWidth(double beamWidth)=0
virtual void setSprayVelocityScale(double scale)=0
virtual void setSprayEnabled(bool enabled)=0
virtual void setMaxBowWaveAmplitude(double amplitude)=0
virtual void setWakeOffset(double offset)=0
virtual void setPropWashEnabled(bool b)=0
virtual void setNumHullSprays(int numSprays)=0
virtual void setHullSprayVelocityScale(double scale)=0
virtual void setDraft(double draft)=0
DtUniqueElementAttribute< std::string, DtElementAttributes::DisplayName > DtElementAttributeDisplayName
Definition DtElementAttributes.h:88
@ Models3D
Definition DtModelSetEnums.h:23
DtUniqueElementAttribute< std::string, DtElementAttributes::DisplayUnitCollectionName > DtElementAttributeDisplayUnitCollectionName
Definition DtElementAttributes.h:127
DtUniqueID DtElementID
Definition DtUniqueID.h:23
DtUniqueElementAttribute< unsigned int, DtElementAttributes::ElementSubtype > DtElementAttributeElementSubtype
Definition DtElementAttributes.h:121
DtUniqueElementAttribute< bool, DtElementAttributes::ObjectVisibility > DtElementAttributeVisibility
Definition DtElementAttributes.h:97
DtUniqueElementAttribute< std::string, DtElementAttributes::DriverType > DtElementAttributeDriverType
Definition DtElementAttributes.h:118