|
VR-Engage
2.3
|
Frontend plugins extend Player Station interaction, UI, input, and roles. Simulation Engine plugins extend VR-Forces entities, simulation components, physics, and backend services. Keep entry points focused on registration and lightweight initialization; put runtime behavior in the corresponding libraries.
VR-Engage supports two primary extension types. Frontend plugins add player-facing components, input devices, and UI. Simulation Engine plugins add entity behavior and simulation components to the backend. A feature can have both parts: the vehicle blinker example adds frontend input handling and a backend actuator, with entity state providing feedback to the display.
VR-Engage also uses VR-Vantage graphics plugins and VR-Forces protocol-dependent plugins. A shared library is a dependency, not a plugin: neither plugin loader calls its functions automatically. Choose the extension point that owns the behavior. A HUD or input mapping belongs in the frontend; an actuator or sensor model belongs in the simulation. Use a shared library when both sides need the same message definitions or common data structures.
DtVrePluginManager resolves three C-linkage exports. Each accepts makVre::DtPlayerStationApp*:
| Export | Return type | Purpose |
|---|---|---|
initPlayerStationModule | bool | Register component, input-device, or service creators |
postInitPlayerStationModule | bool | Finish setup that depends on application initialization |
shutdownPlayerStationModule | void | Remove registrations and release plugin-owned resources |
Declare exports in the plugin header using its DLL export macro. Including that header before the definitions exports the same C-linkage symbols. The notification example declares its init and shutdown hooks in examples/notification/plugin.h; it does not need a post-init hook.
The export declarations in that header are:
The header defines NOTIFICATION_DLL as __declspec(dllexport) when building the Windows module, and __declspec(dllimport) for consumers. Its condition is notification_EXPORTS, the module target's export definition. If adapting the example, keep the target, macro condition, declarations, and function definitions consistent. C linkage prevents C++ name mangling; the export macro makes the symbol visible to the loader.
The excerpt below is from examples/notification/plugin.cxx. The file includes plugin.h, notifyLogic.h, vrePlayerStation/playerStationApp.h, and vreUtil/logger.h.
The current loader accepts a DLL with any recognized hook; each phase skips missing hooks. An init hook is needed when the plugin registers creators. This differs from older header comments that describe init as universally required. A false init or post-init return logs a failure; it is not automatic rollback of registrations or proof that later hooks cannot run.
DtPlayerStationApp loads vreCommonComponents.dll before discovering other frontend plugins. It resolves playerStationApp.pluginPath, defaults to ../plugins64/vrEngage, and appends the build's release or debug subdirectory. Discovery scans that directory's DLLs in case-insensitive filename order. Frontend plugins do not use VR-Forces XML records.
Register a component with the same string returned by its type() method and used in Lua componentType. Registration does not construct a Player Station component. Player loading creates configured components and runs their lifecycle. Components should normally use the inherited myMessageHandlers group for message subscriptions. See Toolkit Fundamentals and Player Station Framework.
The factory stores a creator rather than a pre-created component. This lets different Player Stations create their own instances from role configuration. The notification plugin registers "DtNotifyLogic"; the component returns the same identifier from type(), and its maintained role uses:
The complete role inherits humanBase.lua and includes its display layouts. notifyLogic is the instance key; DtNotifyLogic is the registered C++ type. The framework supplies the merged component table to initialize() during player loading. Remove the creator in the plugin shutdown hook, as the entry-point example does.
Register component-specific handlers during component initialization, not by creating role objects in the plugin entry point. Prefer the inherited DtVreMessageHandlerGroup when subscriptions share the component's lifetime. The maintained saved-view updater registers its handlers this way:
The surrounding source includes vreMessages/menuAction.h and vreMessages/playerCreated.h. DtPlayerComponent supplies the member group. Its base shutdown disconnects both message and attribute subscriptions:
Call base shutdown before releasing resources that callbacks use. A single retained DtVreMessageHandler remains appropriate for a simpler connection. If using direct addHandler(type, delegate) calls, retain the matching removeHandler() cleanup. The QML HUD example shows that explicit pairing. Do not use the obsolete templated DtVreMessageManager::addHandler<MessageType>() pattern.
Simulation Engine plugins use the VR-Forces plugin loader and CGF factories, not the frontend loader. There are two entry-point patterns: use the VR-Forces hooks directly when adding new components or other factory types; call the VR-Engage initialization functions from those hooks when extending an existing VR-Engage controller or class.
The shipped VR-Engage Simulation Engine record is appData/plugins/vreVrfSimPlugin.xml. At runtime the backend reads the effective appData/plugins directory; --appDataDir can change the root.
The record is a Boost-serialized DtVrfPluginRecord, not a single <plugin> element. It selects a library for an application, platform, build configuration, and transport. In this record the selectors are vrfSim, Windows64, Release, and Independent. The library value is ../plugins64/vrForces/release/vreVrfSimPlugin.dll; myLoad is 1. Use the complete shipped record or the VR-Forces Plug-ins editor rather than inventing XML.
The complete record is:
This is the VR-Engage core Simulation Engine record, not a ready-made record for a different DLL. Create the custom record with the editor, selecting its actual DLL and supported configurations. Copying only the library path without retaining the record structure is insufficient.
The inherited VR-Forces startup method DtVrfApp::initializePluginsForCommandLineArguments() reads the records with DtVrfPluginRecordManager, selects vrfSim and applicable transports, and adds selected libraries to the CGF. It then creates the plugin manager. The same function handles --loadPlugin, including explicit XML records. See "Managing Plug-ins" in the VR-Forces User's Guide for the editor workflow.
Both patterns export the VR-Forces C-linkage hook names. The VR-Forces loader calls these exports; the namespaced VR-Engage functions described below are callable library functions, not alternative DLL export names.
Use this pattern when strictly adding new components, descriptors, or other factory types without extending VR-Engage controllers or classes. Register the new types directly in the VR-Forces initialization hook. No call to the VR-Engage initialization functions is needed for this registration-only pattern.
The lifecycle hooks documented by vrfcgf/vrfPluginExtension.h are:
| Export | Return type | Purpose |
|---|---|---|
DtPluginInformation(DtVrfPluginInformation& info) | void | Identify the customer plugin |
DtInitializeVrfPlugin(DtCgf* cgf) | bool | Register the plugin's creators and perform lightweight setup |
DtPostInitializeVrfPlugin(DtCgf* cgf) | bool | Perform setup that requires initialized CGF objects or other plugins |
DtUnloadVrfPlugin(DtCgf* cgf) | void | Release plugin-owned resources during unload |
Declare the hooks with extern "C" and DT_VRF_DLL_PLUGIN. Supply post-initialization and unload hooks when the plugin needs those phases. The unload hook takes DtCgf*, not an empty parameter list.
The vehicle blinker plugin shows this component-registration pattern:
The excerpt omits only additional contact metadata and comments. Its file includes plugin.h, the actuator and descriptor headers, vreUtil/version.h, vrfcgf/vrfPluginExtension.h, vrfcgf/cgf.h, and vrfcgf/factoryManager.h. Use the signature required by the selected VR-Forces entry point; the maintained blinker example accepts a const CGF pointer. The VR-Engage wrapper functions below require DtCgf*.
Use this pattern when deriving from an existing VR-Engage controller or component, such as makVre::DtObjectProximitySensor, or when extending classes that depend on VR-Engage's Simulation Engine setup. The plugin DLL itself does not inherit a DtVreSimPlugin class; DtVreVrfSimPlugin is a namespace.
The callable VR-Engage functions are declared in include/vrfExtensions/vreVrfSimPlugin/vreVrfPlugin.h. The core plugin forwards its VR-Forces exports to these functions:
The source includes vreVrfSimPlugin/vreVrfPlugin.h, vrfcgf/vrfPluginExtension.h, and CGF/factory headers. These wrappers show the core lifecycle functions, not a complete customer plugin.
In a customer plugin, call makVre::DtVreVrfSimPlugin::DtInitializeVreVrfPlugin(cgf) first and check its result, then register the derived creators. The initialization hook follows this template:
When replacing a built-in component, register the derived creator under the existing component type identifier. For example, a DtObjectProximitySensor replacement uses DtObjectProximitySensorType; a separately configured variant uses its own type identifier. The creator must construct the derived class, not the base class. This initialization order prevents the core plugin's registrations from replacing the customer override. DtInitializeVreVrfPlugin() has a repeat-call guard, so the core plugin's later initialization call does not repeat its registrations.
Keep the core plugin enabled when the customer plugin only extends it. The core plugin owns its post-initialization and unload phases; the customer hooks perform customer-owned setup and cleanup. Do not also forward the core post-initialization and unload functions from every extension plugin: post-initialization has no repeat-call guard, and core unload releases shared VR-Engage services. Use the full forwarding pattern only when deliberately taking over the core plugin's lifecycle, with a single owner for those phases. Populate DtPluginInformation() with the customer DLL's metadata rather than copying the core plugin's identity.
Component and descriptor registration serve different purposes. The component creator constructs the runtime actuator, sensor, or controller. The descriptor creator reads that component's configuration from the system definition. Register both when adding a new descriptor type, and ensure the configured component and descriptor type strings match their creators. A derived override can retain its existing descriptor when compatible.
examples/vehicleBlinker/vehicleBlinkerSim/plugin.cxx registers both an actuator and its descriptor:
This is an excerpt from its exported init function, not a complete plugin. The surrounding file includes the actuator, descriptor, CGF, factory-manager, and export headers. See Vehicle Blinker and Custom Projectile.
Shared libraries contain reusable code and definitions rather than plugin entry points. Common uses include generated messages, protocol-independent helpers, and data structures consumed by more than one module. A single shared definition avoids separately maintained copies of message layouts. Both consumers still need the library deployed and a compatible version of its interface.
Keep shared message definitions and utilities in libraries linked by their frontend and Simulation Engine consumers. Export public symbols with the library's export header and compile definition. The examples/customPdu/commentMessage project is a maintained example: export.h supplies EXAMPLEMESSAGE_DLL, and CMakeLists.txt generates the message classes from Lua. Its output library is exampleCommentMessage, deployed to bin64.
The Comment library uses this export header:
The building target defines COMMENTMESSAGE_EXPORTS; consumers include the same header without that definition. The resulting import declarations let Windows consumers link to the exported symbols. An export macro does not replace linking the import library or deploying the runtime DLL.
For a generated message, describe the fields in Lua and let the maintained generator supply the C++ class, accessors, serialization, and factory registration. The Comment schema is:
Generation produces makVre::CommentMessage and its commentMessage.h/.cpp files. The build passes EXAMPLEMESSAGE_DLL and export.h to the generator. Do not replace it with a partial handwritten DtVreMessage subclass that omits serialization and factory requirements. The message base header is vreMessageManager/vreMessage.h.
These excerpts show the actual shared target, generation call, export definition, and deployment rule:
The complete CMake file also supplies include/link directories, collects generated and handwritten sources, and links the message infrastructure. Retain those prerequisites when adapting it. See Message code generation for the full build example and parameter list.
The Entity Detection example demonstrates a shared library used by both frontend and Simulation Engine plugins. Both examples/entityDetection/entityDetectionFrontend/CMakeLists.txt and examples/entityDetection/entityDetectionSim/CMakeLists.txt include entityDetectionShared in their AddLibrariesToLinkWith() lists:
The shared target's output name is exampleEntityDetectionShared. Its CMake file installs the runtime library into both ${MAK_VREDIR}/bin64 and ${MAK_VRFDIR}/bin64 so the participating processes can find it. The Custom PDU example's consumers are frontend and network-connector modules; its network module is not a VR-Forces backend plugin.
Deploy the runtime DLL wherever each consumer process resolves its dependencies, not merely beside the source files. The import library is used during linking; the DLL is needed at runtime. The maintained shared-target CMake rules perform that deployment for their known consumers.
See Custom PDU for the shared message, frontend publisher, and network consumer. A local message queue does not automatically send data to the other process; a connector or bridge must handle the message and use the configured transport.
DtPlayerStationApp::postInitialize().Shutdown cleanup is explicit; loading a DLL does not create automatic factory unregistration. Recognized frontend plugin libraries remain loaded until process exit. The current wrapper deliberately retains them because disconnected signal connections can still reference plugin code. Do not describe shutdown as immediate DLL unload. See include/framework/vrePlayerStation/vrePluginManager.h.
The factory-registration phase and entity/component lifetime are separate. Do not instantiate a sample actuator in the entry point to simulate normal entity creation. Derived VR-Engage component overrides must also preserve the base-registration ordering described above.
Use the maintained example CMake files for include directories, export definitions, libraries, and install paths. Frontend headers in the source tree live beneath include/framework and include/utilities; an include such as vrePlayerStation/playerStationApp.h needs the corresponding include root.
The notification frontend links vrePlayerStation, vreMessageManager, vreMessages, vreUtil, VR-Vantage support, and its role/UI dependencies. The vehicle blinker Simulation Engine target links the VR-Forces component, state-data, transport, and utility libraries used by its actuator and descriptor. A shared-message consumer additionally links the shared target, as the Entity Detection example shows.
A plugin that calls the VR-Engage Simulation Engine initialization functions also links vreVrfSimPlugin. Add the include/vrfExtensions include root for vreVrfSimPlugin/vreVrfPlugin.h, and link the library that provides the controller or component being extended, such as vreVrfmodel for DtObjectProximitySensor.
Dependencies must match both the types used in headers and calls made in implementation. Adding an include directory does not resolve linker dependencies; copying a DLL does not provide the compile-time declarations or import library.
Within the frontend, plugins can exchange process-local messages and share application or Player Station attributes. Give each attribute a stable type and one owner. Those writes do not automatically reach the simulation.
For backend changes, use the supported connector/message path. For reflected entity data, retain the required interests and consume the connector-owned values. Shared message definitions keep field layouts consistent but do not create a transport on their own. See Inter-Process Communication, Frontend Attributes, and Reflected Entity Attributes.
The maintained examples use these Windows runtime destinations under the toolkit root:
| Target | Runtime output | Destination |
|---|---|---|
notification | exampleNotification.dll | plugins64/vrEngage/release |
vehicleBlinkerSim | exampleVehicleBlinkerSim.dll | plugins64/vrForces/release |
commentMessage | exampleCommentMessage.dll | bin64 |
examples/notification/CMakeLists.txt installs its module to plugins64/vrEngage/release. examples/vehicleBlinker/vehicleBlinkerSim/CMakeLists.txt defines the backend dependencies and install location. Shared-library dependencies must be available to the relevant process. Do not assume a generic install destination automatically appends release.
The frontend rule is:
The Simulation Engine plugin rule is:
The shared rule appears in the CMake configuration section above. For Simulation Engine plugins, installing the DLL is only part of deployment: the loader also needs the enabled record for that configuration. For frontend components, deploy the role/input/UI data that references the registered type.
Give components focused responsibilities and preserve base lifecycle behavior. Read supported role parameters during initialization; resolve dependencies in post-initialization. Use the loading/readiness stage for deferred setup rather than blocking a normal frame tick. Keep ownership and callback cleanup explicit, particularly when a station can be suspended and recreated.
Register creators rather than pre-creating objects during plugin load. Keep frame and simulation-tick work bounded, and avoid verbose per-frame logging in production. Loading a module eagerly does not mean that all its registered role components are created eagerly.
Check the effective plugin directory or XML record, DLL exports, dependency availability, and failure messages. Confirm the configured library filename matches OUTPUT_NAME, including a protocol suffix when the maintained project supplies one. A dependent shared DLL must be visible to that process as well. Check the active platform/build/transport selectors in a Simulation Engine plugin record. For frontend plugins, verify the unmangled entry-point names and the export header's target definition.
For a missing frontend component, check its registered type string against Lua componentType. Confirm that registration happened before player loading, that the role actually includes the component, and that initialization did not fail. A descriptor type and a component type serve different factories; registering one does not register the other. For a Simulation Engine override, check that base VR-Engage initialization runs before the replacement registration. An init failure does not undo registrations already made by that hook.
Check library/toolkit ABI compatibility, static initialization, and exceptions during plugin setup. Avoid accessing application services from global constructors before the application exists. For shutdown failures, check dangling callbacks, pointers to destroyed components, and attempted manual DLL unload. Calling a shutdown hook is not proof that no remaining object or signal connection references the DLL's code.
See also