Overview
Implements a custom entity element attribute.
Expected Result
Custom Element Attribute Result
Example details
VR-Forces publishes various properties for entities and other simulation objects. For entities, one such property is the 'entity label':
VR-Forces GUI - Setting an Entity Label
By default, VR-Vantage does not make use of this entity label property but a toolkit user can write a plugin which extracts this property from the entity state repository and makes it available throughout the application as an element attribute.
This example, implements a custom Entity State Listener class and maintains an entity's label that is published by VR-Forces for all entities and, if defined for an entity, reports it to the rest of the system as a custom element attribute. This custom element attribute can be queried throughout the system for visualization to the console, Qt user interface, or as part of the scene.
This example, when used with the exampleElementAttributesPlugin example, visualizes entity labels to the console.
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/exampleCustomElementAttributePluginDIS_stealth.bat (on Windows) or ./bin64/exampleCustomElementAttributePluginDIS_stealth.sh (on Linux). Once Vantage is started, connect with DIS. Open MAK DIS Logger and load "ExampleCustomElementAttributePluginDIS.lgr". Hit Play and you will see information printed in the console. There are startup scripts for HLA1516e: ./bin64/exampleCustomElementAttributePluginHLA1516e_stealth.bat (on Windows) or ./bin64/exampleCustomElementAttributePluginHLA1516e_stealth.sh (on Linux). There is no MAK Logger tape provided for the HLA1516e version of this example. For more information about running examples, please see Running Applications and Examples.
Example Source Files
exampleCustomElementAttributePlugin.h
#pragma once
#ifdef _WIN32
#ifdef EXAMPLECUSTOMELEMENTATTRIBUTEPLUGIN_EXPORTS
#define DT_DLL_EXAMPLECUSTOMELEMENTATTRIBUTEPLUGIN __declspec ( dllexport )
#else
#define DT_DLL_EXAMPLECUSTOMELEMENTATTRIBUTEPLUGIN __declspec ( dllimport )
#endif
#else
#define DT_DLL_EXAMPLECUSTOMELEMENTATTRIBUTEPLUGIN
#endif
#ifdef DtDIS
# define DT_PROTOCOL_NAMESPACE vrvDis
#else
# ifdef DtHLA_4
# define DT_PROTOCOL_NAMESPACE vrvHla4
# elif DtHLA_1516_EVOLVED
# define DT_PROTOCOL_NAMESPACE vrvHla1516e
# else
# ifdef DtHLA_1516
# include <vrvHla1516/vrvHla1516.h>
# define DT_PROTOCOL_NAMESPACE vrvHla1516
# else
# ifdef DtHLA
# define DT_PROTOCOL_NAMESPACE vrvHla13
# define DL_DLL_IGCONVRLINK DT_DLL_VRVHLA13
# else
# error "Protocol not specified or unsupported."
# endif
# endif
# endif
#endif
#define DT_DE_PLUGIN_EXPORT_MACRO DT_DLL_EXAMPLECUSTOMELEMENTATTRIBUTEPLUGIN
{
class DtDe;
}
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer,...
Definition DtDe.h:77
DT_DLL_EXAMPLEACCESSORY void init(makVrv::DtDe &de)
void slot_postInitialize(makVrv::DtDe &de)
#define DT_DLL_EXAMPLECUSTOMELEMENTATTRIBUTEPLUGIN
Definition exampleCustomElementAttributePlugin.h:20
Contains DtCreateSensorFieldOfViewCommand and DtCreateSensorFieldOfViewCommandCreator class declarati...
Definition DtGridLinesSettingsRecord.h:16
Contains DLL export macros.
Contains DLL export macros.
Contains DLL export macros.
Contains DLL export macros.
exampleCustomElementAttributePlugin.cxx
static vrvSignalsLib::connection postInitializeConnection;
{
postInitializeConnection.disconnect();
}
{
{
}
}
{
return true;
}
Contains makVrv::DtAccessoryManager class.
Contains declaration for DtCustomElementAttributeAccessory.
Contains makVrv::DtDe class.
#define DT_DE_INIT_ONCE(de)
This macro is called by modules in their init() function. This macro ensures that the module is only ...
Definition DtDe.h:30
This class defines an accessory that will install itself into DtVrlinkDriver objects and print out th...
Definition DtCustomElementAttributeAccessory.h:24
static DtAccessoryManager & instance(DtDe &de)
Lazily create singleton.
virtual bool isInMasterMode() const
Returns true if the DtDe is in master mode.
boost::signalslib::signal< void()> signal_postInitialize
Definition DtDe.h:535
Contains declarations for plugin initialization functions.
DT_DE_PLUGIN_EXPORT_MACRO bool initDeModule(makVrv::DtDe *de)
DtCustomElementAttributeAccessory.h
#pragma once
{
class DtVrlinkBaseConnection;
{
{
public:
DtCustomElementAttributeAccessory();
virtual ~DtCustomElementAttributeAccessory();
virtual void install(DtDriver* driver);
virtual void uninstall(DtDriver* baseConn);
virtual bool isCompatible(DtDriver* driver);
protected:
virtual void slot_onConnectionCreated(DtVrlinkBaseConnection* connection);
};
}
}
Contains makVrv::DtBaseAccessory class.
Contains implementation for DtCustomElementAttributeAccessory.
#define DT_PROTOCOL_NAMESPACE
Definition vrvAudioShared/dllExport.h:43
DtCustomElementAttributeAccessory.cxx
DtCustomElementAttributeVrlinkEntityStateListener.h
#pragma once
{
public:
public:
protected:
};
{
public:
#ifdef DtHLA
DtHlaObject* object);
#endif
#ifdef DtDIS
const DtEntityIdentifier& id, const DtEntityType& type);
#endif
};
Contains makVrv::DtUniqueID type.
Contains makVrv::DtVrlinkEntityStateListener class.
Definition DtCustomElementAttributeVrlinkEntityStateListener.h:50
DtCustomElementAttributeVrlinkEntityStateListenerCreator(makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection &conn)
Constructor.
virtual ~DtCustomElementAttributeVrlinkEntityStateListenerCreator()
Destructor.
virtual makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkEntityStateListener * create(DtHlaObject *object)
Definition DtCustomElementAttributeVrlinkEntityStateListener.h:25
virtual ~DtCustomElementAttributeVrlinkEntityStateListener()
Destructor.
DtCustomElementAttributeVrlinkEntityStateListener(makVrv::DtUniqueID id, makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection &vrlCon)
Constructor.
std::string myEntityLabel
Definition DtCustomElementAttributeVrlinkEntityStateListener.h:41
virtual void reflectedEntityPostUpdate() override
Called after the entity has been updated.
A class which represents the simulation the driver manages.
Definition DtVrlinkConnection.h:44
Creator class for the EntityStateListener.
Definition DtVrlinkEntityStateListener.h:293
Definition DtVrlinkEntityStateListener.h:61
unsigned long long DtUniqueID
Definition DtUniqueID.h:19
DtCustomElementAttributeVrlinkEntityStateListener.cxx
#include <vrfExtObjects/extEntityStateRepository.h>
enum class CustomElementAttributeIds : unsigned short
{
};
typedef DtUniqueElementAttribute<std::string, (
unsigned short)CustomElementAttributeIds::EntityLabel> DtElementAttributeEntityLabel;
, myEntityLabel("")
{
}
{
}
{
{
}
}
{
}
{
}
#ifdef DtHLA
{
return new DtCustomElementAttributeVrlinkEntityStateListener(
mySim.sceneInterface().createNewUniqueId(),
mySim);
}
#endif
#ifdef DtDIS
{
return new DtCustomElementAttributeVrlinkEntityStateListener(
mySim.sceneInterface().createNewUniqueId(),
mySim);
}
#endif
Contains makVrv::DtAgentManagerInterface class.
Contains declarations for DtCustomElementAttributeVrlinkEntityStateListener and DtCustomElementAttrib...
Contains makVrv::DtVrlinkSimulation class.
DtVrlinkConnection & mySim
Definition DtVrlinkEntityStateListener.h:320
DtVrlinkConnection * myVrlinkConnection
Same as mySimulation, except, stored for convenience.
Definition DtVrlinkEntityStateListener.h:286
virtual void reflectedEntityPostUpdate()
Called after the entity has been updated to resolve all dirty flags.
Definition DtVrlinkEntityStateListener.inl:380
DtEntityStateRepository & esr()
Definition DtVrlinkEntityStateListener.inl:924
void reportElementAttribute(DtElementID id, DtElementAttribute *attribute)
DtElementID myElementId
Definition DtStateListener.h:90
Definition DtUniqueElementAttribute.h:82
Definition DtAudioInit.h:25
@ AttributeIdUserStart
Definition DtElementAttributes.h:53