Main Content

Package Custom Scenes into Executable

When you finish modifying a custom scene as described inCustomize Scenes Using Simulink and Unreal Editor, you can package the project file containing this scene into an executable. You can then configure your model to simulate from this executable by using theSimulation 3D Scene Configurationblock. Executable files can improve simulation performance and do not require opening the Unreal®Editor to simulate your scene. Instead, the scene runs by using the Unreal Engine®that comes installed with Vehicle Dynamics Blockset™.

Package Scene into Executable UsingUnrealEditor

  1. Open the project containing the scene in the Unreal Editor. You must open the project from a Simulink®model that is configured to co-simulate with the Unreal Editor.

    For more details on how to package projects, see "Packaging Projects" underUnreal Engine 4 Documentation.

  2. Rebuild the lighting in your scenes. If you do not rebuild the lighting, the shadows from the light source in your executable file are incorrect and a warning about rebuilding the lighting displays during simulation. In the Unreal Editor toolbar, selectBuild>Build Lighting Only.

  3. Close theProject Settingswindow.

  4. In the top-left menu of the editor, selectFile>Package Project>Windows>Windows (64-bit). Select a local folder in which to save the executable, such as to the root of the project file (for example,C:/Local/myProject).

    Note

    Packaging a project into an executable can take several minutes. The more scenes that you include in the executable, the longer the packaging takes.

    Once packaging is complete, the folder where you saved the package contains aWindowsNoEditorfolder that includes the executable file. This file has the same name as the project file.

    Note

    If you repackage a project into the same folder, the new executable folder overwrites the old one.

    Suppose you package a scene that is from themyProject.uprojectfile and save the executable to theC:/Local/myProjectfolder. The editor creates a file namedmyProject.exewith this path:

    C:/Local/myProject/WindowsNoEditor/myProject.exe

Simulate Scene from Executable in金宝app

To improve co-simulation performance, consider configuring theSimulation 3D Scene Configurationblock to co-simulate with the project executable.

  1. In theSimulation 3D Scene Configurationblock of your Simulink model, set theScene sourceparameter toUnreal Executable.

  2. Set theFile nameparameter to the name of your Unreal Editor executable file. You can either browse for the file or specify the full path to the file by using backslashes. For example:

    C:\Local\myProject\WindowsNoEditor\myProject.exe
  3. Set theSceneparameter to the name of a scene from within the executable file. For example:

    /Game/Maps/myScene
  4. Run the simulation. The model simulates in the custom scene that you created.

If you are simulating a scene from a project that is not based on theAutoVtrlEnvproject, then the scene simulates in full screen mode. To use the same window size as the default scenes, copy theDefaultGameUserSettings.inifile from the support package installation folder to your custom project folder. For example, copyDefaultGameUserSettings.ini来自:

C:\ProgramData\MATLAB\SupportPackages\\toolbox\shared\sim3dprojects\automotive\AutoVrtlEnv\Config

to:

C:\.project\Config

Then, package scenes from the project into an executable again and retry the simulation.

See Also