VR-Engage  2.3
Loading...
Searching...
No Matches
Toolkit Fundamentals

This section covers the foundational concepts that inform all subsequent development work: the dual-process architecture, plugin loading mechanism, build system configuration, and development environment setup.

Architecture fundamentals

Process architecture

VR-Engage operates as a distributed system with two cooperating processes, even when running on a single machine. This architectural decision enables high frame rates for visualization while maintaining simulation fidelity, and provides clean separation between user-facing code and simulation logic.

The frontend process (vrEngage.exe) builds upon VR-Vantage and handles everything the user directly experiences. This includes 3D rendering, head-mounted display integration, input device polling, audio playback, and user interface presentation. The frontend maintains a local copy of entity state for smooth rendering but defers to the backend for authoritative simulation decisions.

The backend process (vrEngageSim.exe) builds upon VR-Forces and manages the authoritative simulation state. This includes physics calculations, damage assessment, sensor modeling, AI behavior, and network protocol handling. The backend publishes state updates that the frontend consumes for visualization, and receives input commands that the frontend forwards from user actions.

When developing new features, consider which process should own each responsibility. User-facing concerns like custom HUDs, input mappings, or visual effects belong in the frontend. Simulation concerns like physics models or weapon ballistics, belong in the backend. State that both processes need access to flows through the messaging layer described in Inter-Process Communication.

Plugin system

VR-Engage uses a plugin-based architecture that loads custom code at runtime. Plugins are compiled as Dynamic Link Libraries (DLLs) that register factories, components, and services with the application framework. This approach enables extending VR-Engage without modifying or rebuilding the core application.

Frontend plugins extend the Player Station with custom UI components, input handlers, and control logic. The frontend loader recognizes initPlayerStationModule(), postInitPlayerStationModule(), and shutdownPlayerStationModule(). The application discovers DLLs in its configured plugin directory, normally plugins64/vrEngage/release/. Initialization registers creators; shutdown removes registrations and releases plugin-owned resources.

Simulation plugins (also called backend plugins) extend the VR-Forces simulation engine with custom entity behaviors, physics models, and network handlers. They use VR-Forces entry points (DtInitializeVrfPlugin()) and use Boost-serialized DtVrfPluginRecord XML files in the effective appData/plugins/ directory. The shipped record is appData/plugins/vreVrfSimPlugin.xml, installed into that directory.

Shared libraries contain code used by both frontend and simulation plugins, such as message definitions or utility functions. They are deployed to bin64/ where both processes can load them.

For detailed plugin implementation patterns, entry point signatures, and complete code examples, see Plugin Architecture.

Development environment

Plugin development requires Visual Studio 2022, CMake 3.21+, Qt 5.15.x, and the VR-Engage Toolkit. These tools work together to compile plugins against the VR-Engage SDK and deploy them to the correct runtime directories.

The maintained examples use examples/CMakeLists.txt and examples/utilities.cmake to generate a Visual Studio solution. Each plugin configures the actual toolkit include roots, library directories, dependencies, export definitions, and installation destinations. Follow an example of the same plugin type.

Environment variables tell the build system where to find dependencies. The examples build system computes MAK_VREDIR automatically from the directory structure, but requires MAK_VRFDIR for VR-Forces, MAK_VRLDIR for VR-Link, and QTDIR for Qt.

For step-by-step setup instructions, environment variable configuration, and build commands, see Environment Setup & Build Guide. The examples directory includes a setupEnv.bat script and working CMakeLists.txt files that serve as templates for new plugins.

Toolkit organization

The VR-Engage Toolkit installation organizes headers, libraries, and runtime files in this structure:

Directory Contents
bin64/ Executables (vrEngage.exe, vrEngageSim.exe) and shared libraries
include/ Public headers organized by subsystem (framework/, vrePlayerStation/, vreMessages/)
lib64/ Import libraries for linking
plugins64/ Plugin directories: vrEngage/ (frontend), vrForces/ (simulation), vrVantage/ (graphics)
data/ Runtime data: roles, input mappings, simulation model sets
examples/ Toolkit examples with full source code
examples/utilities.cmake Shared CMake helpers used by the maintained examples

Headers in include/ are organized by functional area. The framework/ directory contains core abstractions. The vrePlayerStation/ directory contains frontend-specific classes. The vrfExtensions/ directory contains backend integration classes.

For details on plugin installation paths and deployment, see Plugin Architecture.

Development patterns

Several patterns appear repeatedly throughout VR-Engage toolkit development.

Common patterns

Factory registration

Components are instantiated through factories rather than direct construction. This enables configuration-driven instantiation where role files specify component types by name.

// Source: examples/notification/plugin.cxx (init entry-point excerpt)
app->componentFactory().addCreator<DtNotifyLogic>("DtNotifyLogic");
Example component demonstrating player attribute monitoring and temporary notifications.
Definition notifyLogic.h:43

Configuration-driven initialization

Components read configuration from DtInitTable during initialization rather than hardcoding values. This enables runtime configuration through role files.

// Source: libsrc/commonRoleLibraries/vreCommonComponents/savedViewUpdater.cxx
// Excerpt from DtSavedViewUpdater::initialize(), after base initialization.
myObserverName = config.findDataOr<std::string>(SavedViewUpdaterConfig::observerName, "Observer 1");
myWindowName = config.findDataOr<std::string>(SavedViewUpdaterConfig::windowName, "Window 1");
myChannelName = config.findDataOr<std::string>(SavedViewUpdaterConfig::channelName, "Channel 1");
constexpr const char * channelName
Definition savedViewUpdater.h:45
constexpr const char * windowName
Definition savedViewUpdater.h:66
constexpr const char * observerName
Definition savedViewUpdater.h:54

Message-based communication

Prefer DtVreMessageHandlerGroup for several subscriptions with a shared lifetime. DtPlayerComponent already supplies the protected myMessageHandlers group. Connect during initialization and call base shutdown() to disconnect before releasing component resources. The group owns its handler objects, not the callback target or the messages.

// Source: libsrc/commonRoleLibraries/vreCommonComponents/savedViewUpdater.cxx
// Excerpt from DtSavedViewUpdater::initialize().
myMessageHandlers.connect(MenuActionMessage::theType(), this, &DtSavedViewUpdater::handleMenuMessage);
myMessageHandlers.connect(PlayerCreatedMessage::theType(), this, &DtSavedViewUpdater::handlePlayerCreated);

The complete source includes vreMessages/menuAction.h and vreMessages/playerCreated.h; playerComponent.h includes vreMessageManager/vreMessageManager.h. Handlers return DtVreMessageResult and receive a DtVreMessage*. The group stores one handler per message-type string: reconnecting that string replaces its prior handler. Use disconnect(type) or disconnectAll() for earlier cleanup; destruction also disconnects.

Retain DtVreMessageHandler for one handler, or one callback connected to several message types. Store it as a member of its callback owner and call connect(type) on that retained instance. Its destructor calls disconnectAll(); a temporary local handler disconnects when it leaves scope. The constructor/connection overloads and destructor are defined in include/utilities/vreMessageManager/vreMessageManager.h and the corresponding source. Avoid copying connected handlers or groups into owners with independent lifetimes.

queueMessage() transfers message ownership to the manager; callers must not delete or reuse the queued object. Handlers run on the dispatch thread selected at registration, with the main thread as the fallback. A local queue operation alone does not create a network transport. See Inter-Process Communication for connector and bridge requirements.

Error handling

Proper error handling ensures components behave predictably during both normal operation and failure conditions.

Configuration validation

Validate configuration during initialization. Check required parameters, validate ranges, and verify dependencies before returning from initialize(). Configuration errors should prevent component activation rather than causing runtime failures.

The saved-view updater checks that the configured file yields at least one saved view. Its failure branch uses the current logging API:

// Source: libsrc/commonRoleLibraries/vreCommonComponents/savedViewUpdater.cxx
if (myCachedObserverViews.size() == 0)
{
LOG_WARN("Observer Views", "DtSavedViewUpdater has no views to show!\n");
return false;
}
#define LOG_WARN(channel, format,...)
Macro to log a warning message using printf-style formatting.
Definition logger.h:150

Runtime error handling

Handle known recoverable failures explicitly and report their context. Do not catch every exception and continue with stale state. During deferred loading, return DtInitTickStatus::Failed when a component cannot become ready. See Component lifecycle for loading failure handling.

Logging best practices

Log sufficient diagnostic information to aid troubleshooting:

  • Include vreUtil/logger.h.
  • LOG_FATAL, LOG_WARN, LOG_INFO, LOG_VERBOSE, and LOG_DEBUG take a channel, printf-style format, and matching arguments. Use s with std::string::c_str().
  • Use LOG_*_STREAM(channel) for stream expressions; the corresponding LOG_*(channel) form is not valid.
  • Include component name and context in log messages
  • Log parameter validation failures with expected ranges
  • Avoid logging sensitive or excessive detail in production builds
  • VERBOSE and DEBUG select log severity; neither name alone means the call is compiled out.

The logging definitions are in include/utilities/vreUtil/logger.h and libsrc/utilities/vreUtil/logger.cxx.

Testing and validation

Consistent testing and validation help catch integration issues early and keep custom plugins maintainable over time.

  • Start with a minimal scenario that exercises only your new components or roles.
  • Verify that plugins load successfully by checking startup logs for entry-point registration and factory creation.
  • Use controlled test inputs (scripted input mappings or simple roles) before introducing complex hardware setups.
  • Validate backend behavior with repeatable scenarios: run the same maneuver multiple times and compare logged outputs.
  • When updating toolkit or physics versions, re-run a small regression set of representative scenarios.

See also

Next steps

This section covered the dual-process architecture, plugin system, and development environment. The following sections address specific implementation topics: