Share

Using C++ with MotionBuilder

The project settings in [MotionBuilder]/OpenRealitySDK/CMakeLists.txt contain the required configuration options to build plugins.

How to set up Visual Studio or Visual Studio Code

Note:

Visual Studio solution (*.sln) and project (*.vcxproj) files are no longer provided with the Sample projects, as a CMake build environment is now proposed. Reusing Visual Studio solution and project files from previous versions of MotionBuilder could also provide a valid build environment if it is more convenient.

  1. Create your plugin folder under [MotionBuilder]/OpenRealitySDK; for example: [MotionBuilder]/OpenRealitySDK/My_Folder.

  2. Copy one of the sample templates into your folder taken from [MotionBuilder]/OpenRealitySDK/Samples.

  3. Choose a Unique Name: you must declare a library using the library declaration macro FBLibraryDeclare(LibName). LibName must be unique because this macro is used to identify the class to be created, and it declares global symbols. Since this unique name should not interfere with other third-party developers, we suggest that you prefix (or suffix) it with your company name or other unique identifier. For example: FBLibraryDeclare(MyOrg_MyLibrary);.

  4. Registering Classes: certain plugin types require classes to be registered in the MotionBuilder registry (devices, tools, constraints, and so on.) These classes must be registered in the library declaration (FBLibraryDeclare), which includes the following:

    FBLibraryDeclare( mylibname )
    {
            FBLibraryRegister( MyDeviceClass );
               FBLibraryRegister( MyDeviceLayoutClass );
    }
    FBLibraryDeclareEnd;
  5. Replace "add_subdirectory( Samples )" in [MotionBuilder]/OpenRealitySDK/CMakeLists.txt with "add_subdirectory( My_Folder )" to build your plugin.

  6. Use Visual Studio on Windows or Visual Studio Code on Linux to open the Folder [MotionBuilder]/OpenRealitySDK and build your plugin.

C++ plugins are made by compiling code into Dynamically Linked Libraries (DLLs) which are put in [MotionBuilder]/bin/x64/plugins on Windows or [MotionBuilder]/bin/linux-x64/plugins on Linux from where they are detected and loaded at startup.

Code samples are in [MotionBuilder]/OpenRealitySDK/Samples. In each sub-directory there are detailed descriptions of each plug-in, including how to test them.

Was this information helpful?