0% found this document useful (0 votes)
33 views

Customizing Scenes For Simulation Use: CILE 490: Multidisciplinary Capstone William Abraham, Lara Buckingham

Uploaded by

tradingshajie
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Customizing Scenes For Simulation Use: CILE 490: Multidisciplinary Capstone William Abraham, Lara Buckingham

Uploaded by

tradingshajie
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

CUSTOMIZING SCENES

FOR SIMULATION USE

CILE 490: Multidisciplinary Capstone


William Abraham, Lara Buckingham
[email protected], [email protected]
TABLE OF CONTENTS
Introduction ..................................................... 3
1. Software Installs ....................................... 4
Matlab 2019a / 2019b.................................4
Unreal Engine 4 .........................................6
Visual Studio ..............................................6
2. Plugin Set Up ........................................... 8
Installing the Matlab Plugin ........................8
Environment Set up Script ..........................8
Startup Script ........................................... 10
3. General Unreal Engine Use ................... 11
The Basics ............................................... 11
Navigation ................................................ 11
Sculpting & Landscapes ........................... 12
Materials & Meshes .................................. 13
Skeletal Meshes ....................................... 19
Particles, the Sky Sphere, & the Sun ....... 20
Getting Additional Meshes and Materials . 22
4. Compiling Project Into An Executable .... 23
Building Assets ......................................... 23
Compiling the Project ............................... 24
5. Using Custom Scenes In Simulink ......... 26
3D Config Block ....................................... 26
Calling a Custom Scene ........................... 28
Appendix....................................................... 30
Scene Call Workaround ........................... 30
Windows 8.1 SDK Install .......................... 30
Packaging Settings................................... 30
References ................................................... 32

ii
INTRODUCTION

A simulation is only as good as the model and the environment within it. Without a model that
accurately reflects a real-world counterpart, a simulation has little relevant use. The same logic
follows for the simulation’s environment; without an accurate or useful environment, scant use
is found all the same. This is where the Unreal Engine and the ability to customize scenes for
use within the engine finds its own niche within the context of the AutoDrive Challenge.
The largest goal of this project was, and is, to provide the AutoDrive team with a method to test
various systems, controllers, and creative ides in a no-risk environment. Some of the various
potential benefits the Unreal Engine team sought to bring to the wider AutoDrive team are:
• Customized 3D environments that allow for the team to test in conditions not readily
available in the Flint area. This could help circumvent time, budgetary, or even geographical
limitations.

• Fringe events and conditions can be generated and tested within a no-risk environment. If a
system is underperforming in a certain situation, a simulation could be built around that
given situation.

• A controlled testing environment; an environment in which variables can be isolated and


multiple trials can be conducted under like conditions.

• Ability to create custom props and tailor the environments to desired conditions that more
accurately reflect desired testing conditions.

This user guide is meant to serve as more of an onboarding guide than an in-depth tutorial on
how to do everything one might wish within the Unreal Engine itself. It is broken down into
sections and focuses on providing general instructions in the following areas:
1. Software Installs

2. Plugin Set Up

3. General Unreal Engine Use

4. Compiling Project into an Executable

5. Using Custom Scenes in Simulink

6. Appendix

7. References

3
1. SOFTWARE INSTALLS

The list of required software installs is rather short, but there are explicit versions of each
software component needed for the whole system to work. This section will detail what
software needs to be installed, where to find said software, and installation steps.

Matlab 2019a / 2019b


The first major software needed is a licensed version of Matlab 2019a; 2019b will be available
in the future but at the time of writing this guide, 2019b is not available for use. The instructions
for installing 2019b will be the same as those for installing 2019a. However, the versions will
be different but the process will be much the same. Kettering University has an enterprise
license for Students to use. A link to Kettering’s page for Matlab use can be found here or at
https://my.kettering.edu/page/matlab. Navigate to the “How do I download MATLAB
software?” section and click the ‘MathWorks website’ hyperlink.
If you already have a MathWorks account tied to you student email (@KU address) go ahead
and sign in; if you do not already have a MathWorks account, create and account with your
Kettering email as the university license is tied to your email. After logging in Click on the
Campus license selection.

Click the blue download button, and then click the blue button on the following webpage
labeled “R2019a”. If 2019b or a later version has been released when reading this guide,
simply select the newer version of Matlab from the “Download earlier release” menu on the
right-hand side. From there select the blue Windows OS option button.

4
Afterwards follow the installer instructions for installation. If additional information is needed,
please consult the MathWorks documentation here, or at
https://www.mathworks.com/help/install/ug/install-mathworks-software.html
There are a number of Toolboxes and Blocksets that are recommended installs for the
AutoDrive team; it’s a catch-all list of toolboxes given out by Dr. Reck. These can be found in
the following set of pictures. Though as noted in the Add-On documentation, for customizing
scenes in Unreal Engine the plugin mainly requires Simulink and the Vehicle Dynamics
Blockset to be installed; they are highlighted below.

5
Unreal Engine 4
The Unreal Engine can be installed onto a computer in a number of ways, for the sake of
simplicity this guide will focus on the most straightforward method of installation; the Epic
Games Launcher. Official steps for installing the Unreal Engine 4 to your computer can be
found here or at https://docs.unrealengine.com/en-US/GettingStarted/Installation/index.html.
This guide recommends following the official documentation from the Unreal Engine site if any
questions arise during the Unreal Engine installation process. As there are not any Kettering
specific steps to take during the installation of the Unreal Engine, the official documentation is
more than adequate. The Unreal Engine download page found here, or at
https://www.unrealengine.com/en-US/download.

It is important that the version of the Unreal Engine installed is 4.19.x as that is
the version of the Editor that the plugin is designed to work with. Should this
version change, download the version specified in the Plugin Documentation.

Visual Studio
Visual Studio is needed to compile projects within the Unreal Engine 4 (ue4) Editor. The 2017
version of the community license is all that is needed. The community version is a free
download with a Microsoft account so that is the one chosen here; if other tiers of Visual Studio
are already installed on the target computer, they should work as long as they are the 2017
version. At the time of writing this the 2017 version of Visual Studio is the specified version for
Unreal Engine 4.19.x, this may be subject to change in the future. Official documentation from
Microsoft can be found here, or at https://docs.microsoft.com/en-
us/visualstudio/install/install-visual-studio?view=vs-2019
The first step is to navigate to the Visual Studio download site here , or at
https://visualstudio.microsoft.com/downloads/. This webpage has the most recent version
of Visual Studio front and center. So, to find the older versions scroll down to find the blue
“Older versions” button near the bottom of the page. Click the older version button, select the
2017 and then the blue Download button. If you are not already logged in to your Microsoft
account this will prompt you to log in; if you do not have an account, you will need to create
one.

6
Once you have signed in, there will be a table of download options available. For the sake of
this guide the latest version of the Visual Studio Community 2017 option was chosen. Simply
select the download button again and the download should commence shortly after.

Once the installer is downloaded, run the vs_community.exe wait for the Visual Studio Installer
window to open then select Continue. Once the Installer has installed it is time to select the
Workloads needed. Select launch for a first time install or modify for already exisiting
installations. The required workloads are shown below with the blue checkmarks. Click on the
tiles in the Installer window to select them for installation. Once all 4 of the required workloads
are selected, click Install in the lower right-hand corner of the window. Once the downloading
and installation of the workloads has finished Visual Studio will have been successfully
installed.

Note
You may need to install relevant SDKs if the Unreal Engine gives off errors during the
compilng process. Information on this can be found in the Appendix.

7
2. PLUGIN SET UP

MathWorks has created a Support Package/Plugin within the Vehicle Dynamics Blockset for
customizing scenes in the Unreal Engine. The installation of this Add-On is fairly straight-
forward; however, it takes some time because of the installation size.
With a valid MathWorks account login, official documentation on this support package can be
found here, or by manually navigating to the following webpage:
https://www.mathworks.com/help/vdynblks/ug/support-package-for-customizing-scenes.html

Installing the Matlab Plugin


Installing the plugin to Matlab is fairly straight-forward. Navigate to the Home tab and click the
Add-Ons dropdown arrow in Envirornment seciton. Following this click the Get Add-Ons option
to open the Add-On Explorer. Search for “Vehicle Dynamics Blockset Interface for Unreal
Engine 4 Projects” and open the resulting search item. Next click the blue Install button, select
Install, select I Accept, and then wait for Matlab to finish the installation operation.

Environment Set up Script


Once the Add-On has been installed, or while waiting for it to install create a new Script. This
script will be used to set up the environment by copying files to the necessary directories within
the Unreal Engine and Matlab. Most of the code for this is provided by MathWorks with the
user only needing to change a few lines corresponding to installation directories. These lines
are highlighted on the following page.

Note
Be cautious of the working directory name’s length as long working directory names may
cause project compile errors later due to file path length exceeding the windows character
limit.

8
Script code for setting up the environment:

% Specify the location of the support package project files and a local folder destination
% Note: Only one path is supported. Select latest download path.

%this is where you want the working directory for all Unreal Engine Files to be
dest_root = "YOUR FILEPATH HERE"; %It could be something like "C:\Local";
src_root = fullfile(matlabshared.supportpkg.getSupportPackageRoot, ...
"toolbox", "shared", "sim3dprojects", "automotive");

% Specify the location of the Unreal Engine installation.

%This is where you installed the 4.19 version of Unreal Engine


ueInstFolder = "YOUR FILEPATH HERE";
%The default install path is usually "C:\Program Files\Epic Games\UE_4.19";

% Copy the MathWorksSimulation plugin to the Unreal Engine plugin folder.


mwPluginName = "MathWorksSimulation";
mwPluginFolder = fullfile(src_root, "PluginResources", "UE419"); % choose UE version
uePluginFolder = fullfile(ueInstFolder, "Engine", "Plugins");
uePluginDst = fullfile(uePluginFolder, "Marketplace", "MathWorks");

cd(uePluginFolder)
foundPlugins = dir("**/" + mwPluginName + ".uplugin");

if ~isempty(foundPlugins)
numPlugins = size(foundPlugins, 1);
msg2 = cell(1, numPlugins);
pluginCell = struct2cell(foundPlugins);

msg1 = "Plugin(s) already exist here:" + newline + newline;


for n = 1:numPlugins
msg2{n} = " " + pluginCell{2,n} + newline;
end
msg3 = newline + "Please remove plugin folder(s) and try again.";
msg = msg1 + msg2 + msg3;
warning(msg);
else
copyfile(mwPluginFolder, uePluginDst);
disp("Successfully copied MathWorksSimulation plugin to UE4 engine plugins!")
end

% Copy the support package folder that contains the AutoVrtlEnv.uproject


% files to the local folder destination.
projFolderName = "AutoVrtlEnv";
projSrcFolder = fullfile(src_root, projFolderName);
projDstFolder = fullfile(dest_root, projFolderName);
if ~exist(projDstFolder, "dir")
copyfile(projSrcFolder, projDstFolder);
end

© 1994-2019 The MathWorks, Inc.

When both file paths have been changed, save the script with any name you prefer and run
the script to copy to necessary files to where they need to go. Once the script finishes, proceed
to creating the Unreal Editor Startup Script.

9
Startup Script
The Startup Script is one of the easiest methods of opening the AutoVrtlEnv project for editing
scenes; it is possible to manually open the project itself from within the ue4 Editor but using a
script file from MathWorks takes care of most of the work anyway. To begin, create a new
script file and copy the code below into the new script. Starting up the Unreal Engine may take
a long time depending on the computer used; be patient but watch the Task Manager if you
suspect it is not loading.
Try to use the snippet of the provided MathWorks code first, if it does not work use the Altered
Startup Code. Both accomplish the same thing, both have failed startup more than once, but
sometimes one works where the other hasn’t. IF none of them work, check the MathWorks
plugin webpage for the most up to date code as it may have changed since the writing of this
guide.
Change the highlighted portion of the code to the same working directory you specified in the
environment set up script. After changing the file path to the correct working directory, save the
script with whatever name you wish, and run the script to open the Unreal Engine Editor.
Provided MathWorks Code:
% Create an instance the of sim3d.Editor class for the project.
% The project is located in the projDstFolder and has the projFolder name.
dest_root="YOUR FILE PATH HERE";
projFolderName = "AutoVrtlEnv";
projDstFolder = fullfile(dest_root, projFolderName);
editor = sim3d.Editor(fullfile(projDstFolder, projFolderName + ".uproject"));

% Open the project in the Unreal Editor.


editor.open();

© 1994-2019 The MathWorks, Inc.


Altered Startup Code:
%Unreal Startup Script
%File Path
dest_root = 'YOUR FILE PATH HERE';
src_root = fullfile(matlabshared.supportpkg.getSupportPackageRoot,...
'toolbox','shared','sim3dprojects','automotive');
%Directory Setup
projFolderName = 'AutoVrtlEnv';
projSrcFolder = fullfile(src_root, projFolderName);
projDstFolder = fullfile(dest_root, projFolderName);
%Engine Setup
sim3d.Engine.engine;
%Run Command
system(['start /b ' fullfile(projDstFolder, [projFolderName '.uproject'])]);

After initial set up of both these scripts, the only script that you need to run is the startup script
at the beginning of each session.

Note
You may need to associate .uproject files with the Unreal Editor in Windows so that the Unreal
Editor opens when attempting to open, or when selecting .uproject files.

10
3. GENERAL UNREAL ENGINE USE

The Basics
Upon running the startup script, the entire screen called the level editor should appear.

Level Editor
As can be seen in the above figure there are five windows. The upper left window is the
content browser, which is where you can locate any element you wish to add to your project.
In the lower left hand corner, we have the modes panel. This is where we can find our level
editing tools. In the upper right-hand corner we have the world outliner which is where you can
access world features such as light sources, landscape, atmospheric fog, etc., and then on the
lower-right hand corner you have the details panel which gives information about whatever
world feature you have selected.
Navigation
There are three different navigation techniques that can be used to move around the world.
These techniques are:
1) Hold the left mouse button and drag for backward and forward movement. Hold the
right mouse button and dragging the mouse allows you to look around. Holding the
middle mouse button and dragging allows for up and downward movement.
2) Hold the right mouse button then use WASD
3) Hold the ALT key and move the mouse

11
Sculpting & Landscapes
By selecting “Landscape” in the modes panel, the landscape manager will open. Here you can
adjust elements of the landscape. The overall landscape is divided into an array of sections. It
is important to adjust the number of sections by changing the section size in the modes panel
to match the level of detail you want in your landscape. Do note that the higher the section
size, the more difficult it is for your CPU to process, so choose wisely.

Landscape Manager
The “Fill World” box allows you to create the largest possible landscape available.

Sculpting
To sculpt a landscape, you can use the sculpting tool to make the level less flat and more
realistic. To create hill, select the sculpting tool then left click the section of your landscape
that you want raised and hold. The longer you hold the left mouse button, the higher the hill
will become. If you want to have a portion of your landscape be lower, hold Shift and the left
mouse button and you can create a place of lower elevation. You can do this to create a lake,
river, valley, potholes, etc.
There are many other sculpting tools available in the modes panel if you use the dropdown
arrow next to the sculpting tool. You can flatten out hills, create either heat or hydro erosion,
make ramps, etc. on your landscape.

12
Sculpting Tool

Materials & Meshes


Materials
Materials in the unreal engine are assets that can be applied to meshes to control how they
look. This might be through specifying color, texture, opacity or how metallic the mesh should
be. Materials are constructed through visual scripting using a network of nodes called material
expressions. These include mathematical operations and textures, and materials are built
using the material editor ( 2018). The following figure shows the material editor for a small
green tree.

13
M_Tree_01-Green
The material itself is going to appear a spherical shape in the upper left hand corner; this is
normal. The material can then be loaded into a mesh that can be then placed into the level.
To make comment on each node in the material editor to specify what each node is for, simply
click on the node then press the “c” key on the keyboard to open a new comment that you can
use to label the node.

Adding a Comment

14
As can be seen in the above figures, each texture sample is a node connected to a port in the
material properties box which specifies a particular attribute of the material. The texture
sample can be changed by clicking on the texture sample then changing the texture in the
“Material Expression Texture Base” box as seen below.

Changing Textures in the Materials Editor


The “normal” port allows the user to make properties like the grass less flat.
You can also convert any constant block to a parameter. To do this, right click the box and
convert to parameter. Give it a name and an upper and lower limit. As seen below, the
roughness for this landscape material is set to 0.75. For roughness, the higher the number the
rougher the texture.
I had also added a grass scaling parameter to specify how large I wanted the blades of grass
to appear on the landscape.

15
Adding Parameters

Layer Blends
You can use a landscape layer blend node to blend between different textures. For example, if
you have four textures that you want to include on your landscape at different moments, this
guide outlines the steps to do so.
1) Add 4 array elements for 4 different textures, then rename them.
2) Create 4 texture sample expressions so that you can get the textures into the layer
blend node. Hold T on the keyboard and left click 4 times in the viewer. Click on each
one and change the material expression texture to each texture you want to add in.
3) Plug each texture sample into the appropriate layer bland. Then plug the layer blend
into base color. Then you make comments. You may do this more times for normal
and roughness. You can copy and paste then nodes and plug into roughness or
normal.
4) Add landscape coordinates for a blend applying to a landscape.
5) Go back into your map, select the new material, then choose your new material on the
landscape material. Then go into the landscape tools, and select paint. Now that
you’ve assigned the material, each of the materials included in the layer blend you’ve
created. Click on the plus sign, select weight blended material, then it will ask you what
you want to call it and where you want to put it. You can then start painting with each
texture.

16
Layer Blend for M_Landscape Practice
Static Meshes
“A static mesh is a piece of geometry that consists of a static set of polygons that are the basic
unit to create world geometry for levels in Unreal Engine 4. In addition to building levels, Static
Meshes can be used for creating movers such as doors or lifts, rigid body physics objects,
foliage and terrain decorations, procedurally created buildings, game objectives, and many
more visual elements.” From https://docs.unrealengine.com/en-
US/Engine/Components/StaticMesh/index.html
A static mesh can be added to a landscape by finding the static mesh in the content browser
and then dragging it onto the landscape. The figure below shows a static mesh of a deer
being added to the landscape. Any existing mesh can be searched for in the content browser
by name. This is a quick way to add stop signs, animals, pedestrians, etc. to a landscape.

17
Deer Mesh

Each mesh has a material and LOD (level of detail) slot as seen below.

Material and Level of Detail Slot

Some static meshes can be adjusted to include small movements such as tree leaves blowing
in the wind. You can adjust the mesh’s material to include nodes such as the wind nodes to
add movement to the mesh. The leaves material as seen below has both wind speed and
intensity nodes. The mesh that the leaves node goes into has two levels of detail: one for the
leaves and one for the bark. This allows the tree bark to remain stationary while the tree
leaves and branches move in the wind.

18
Adding Tree Leaves Wind Movement and Level of Details

Skeletal Meshes
“Skeletal Meshes are made up of two parts: A set of polygons composed to make up the
surface of the Skeletal Mesh, and a hierarchical set of interconnected bones which can be
used to animate the vertices of the polygons.
Skeletal Meshes are often used in Unreal Engine 4 to represent characters or other animating
objects. The 3D models, rigging and animations are created in an external modeling and
animation application (3DSMax, Maya, Softimage, etc), and are then imported into Unreal

19
Engine 4 and saved into packages by using Unreal Editor's Content Browser.” - from
https://docs.unrealengine.com/en-US/Engine/Content/Types/SkeletalMeshes/index.html
Blender Animation is a software you can also use so that you can create a skeletal mesh then
import it into UE4. A really great tutorial about this is:
https://www.youtube.com/watch?v=Ayp1lof0RJU

Particles, the Sky Sphere, & the Sun


Go to light source in the world outliner, then press “f” on the keyboard. You can then adjust
the sun’s position. To change the sunlight color, you can change it in light color in the details
panel.

Light Source Details

20
If you change the light color, sometimes the sky won’t match. To fix this, go into sky sphere
and on the details panel, check the box to refresh. You can also uncheck the “colors
determined by” field.

Fixing Sky Color

Sun and Sky Adjustment Image

21
Getting Additional Meshes and Materials
To get additional meshes and materials, they can be downloaded as packages from the Unreal
Engine Marketplace. The link to this is https://www.unrealengine.com/marketplace/en-
US/store. Note that you must have an account with the Unreal Engine to download any new
package because sign in info is needed. Creating an account is free.

Note
The Epic Games Launcher does not work on the classroom PC, so the procedure to get new
content is to download it from the marketplace onto an external drive, then copy and paste this
material into the contents folder of whatever drive Epic Games is installed on.

The Unreal Engine Marketplace

22
4. COMPILING PROJECT INTO AN EXECUTABLE

After all editing has been done and the scenes have been customized, it only takes a few
steps to get the customized scenes into an executable that Simulink can make use of. Each of
the two steps can take a long time to complete depending on how many props were added to a
given scenes, and how big the overall project is; MB and GB wise. Once a project has been
compiled any changes made to the scene after the initial compile operation will only be seen
after the project is compiled again.

Building Assets
Before a project is compiled into an executable the new project assets and props placed into
scenes need to be built into the scene itself. If this is the case a red notification will appear in
the top left of the scene window similar to the picture below.
Building scene assets is a very straight-forward process in the context of the AutoDrive team’s
use of the Unreal Engine Editor. If only lighting needs to be built you can select the build
lighting only button under the Build dropdown menu, or you can just select the Build button
itself. For the AutoDrive teams use, both options function much the same. Clicking the Build
button will export lighting data to the Swarm Agent application. Depending on the number of
props and general detail of the given scene, this may take a while to finish.

The work the Swarm Agent application does is all automatic and it functions autonomously in
the background. If, however you want to see it’s current progress in building the scene lighting,
open then hidden icons bar near the clock in the windows taskbar and look for the swarm icon.
Double click this icon to open the Swarm Agent. A picture of the Swarm Agent icon, its
location, and the Swarm Agent Application can be found in a picture on the next page.

23
When the Swarm Agent has finished generating and building the scenes lighting data the
editor window will update with the newly generated lighting and if you had Swarm Agent open
the progress bar will read 100.00%. If there are no other build errors in the project, it is time to
move on to compiling the project into its final format; an executable.

Compiling the Project


Compiling the project is actually very simple in practice, just like compiling a program in an IDE
or a text editor. The major difference between the two is really terminology. In the Unreal
Engine Editor, compiling a project is referred to as “Packaging” the project. The option to
package the project can be found in the picture below or by following File>Package
Project>Windows>Windows(64-bit).

After clicking the Windows


(64-bit) option you will
need to choose the folder
where the project will be
packaged to. In order to
keep the project and its
files together choose the
AutoVrtlEnv folder in the
working directory specified
in the startup scripts
section.

Packaging will take some


time so be patient.

Packaging Settings can also be


found here. Some examples of
settings you may need to
change can be found in the
Appendix section.

24
Once the project has started packaging the following popup should appear in the bottom right
of the editor window. Clicking the cancel button at any stage of the packaging operation will
terminate the process. This popup will notify you of not only the packaging progress and
packaging completion, but it will also notify you in the event of a failed packaging attempt.

Clicking the show Output Log option in the popup window will open the Unreal Engine’s output
log; a very detailed log of every evert that occurs within the Editor itself; an example of the
output log during the packaging process can be found below. It may be worth keeping an eye
on the Output Log during the packaging process because it will notify you of any errors during
the lengthy packaging process.

Note
Two simple errors to keep watch out for will be file paths exceeding characters limits and
Windows SDKs not being installed. File path errors can be resolved by limiting the length of
working directory folder names, information for solving the Windows SDKs errors can be found
in the Appendix section.

25
5. USING CUSTOM SCENES IN SIMULINK

The ability to use custom scenes in Simulink centers around a single Simulink block, the
Simulation 3D Config block. This block allows the user to change what scene is used when the
simulation is launched. It comes with a set of 9 default scenes / examples but has the option to
use any scene from an Unreal Engine project compiled with the MathWorks Plugin.
Again, official documentation can be found in the latter half of the webpage here, or by
navigating to this address https://www.mathworks.com/help/vdynblks/ug/support-
package-for-customizing-scenes.html

3D Config Block
The Simulation 3D Config block can be found in Simulink in a few different ways, the first being
through the Simulink Library Browser.

The Library Browser can


be found in the main
Simulink toolbar. Simply
click the image on the
toolbar and search the
browser for “Simulation
3D Config”. Drag the block
from the library browser
window into the Simulink
Workspace. It may ask
you for a project name, do
not worry about that for
the moment. Click inside
the window or hit escape
to dismiss the request.

26
An alternate method for getting the Simulation 3D Config block into the workspace is to click
once in the workspace’s whitespace and then start typing “Simulation 3D Config”. If the correct
block is highlighted like in the picture below, hit enter to bring the block into the workspace.
Once the block is in the workspace, the next step is editing the block to run a custom scene
with the scene call string.

Double clicking the Simulation 3D Config block will open it. The default configuration for the
block can be seen below. With the default configuration it can open any of the 9 default
scenes. The Sample time may need adjusting depending on the simulation you are running.
The default value of .02 will suffice for most cases, but may require changing as needed.

Of the 9-default scenes, the


MathWorks provided plugin allows
the editing of all but the Virtual
Mcity scene and the Large Parking
lot scene.
In addition to the 9-default scenes
shown in the dropdown menu there
are also 2 hidden scenes that can
only be accessed by using the
customs scene call string. These
scenes are the AssetLibrary scene
and the EmptyGrass4k4k scenes.

27
Calling a Custom Scene
Calling a custom scene in the Simulation 3D Config block is fairly straightforward; there are
four parts to making it work. The first two aspects needed are that the block needs the Co-
Simulation format set to Executable and the Scene description set to Custom. The next steps
are outlined below; they relate to changing the project name of the block itself into the two
halves of the scene call string. There is a space between the two halves!

This section of the call string dictates This section of the string dictates what
where Simulink will look for the .exe scene you are calling to interface with
containing the customized scenes. This Simulink. It should be the same as it
file path should be the same Unreal appears in the picture above with only the
Engine working directory that has been scene name being changed as desired.
used thus far. This part of the scene call string
The folder architecture should be the corresponds to an internal path within the
same as the string shown above. executable and should not be altered except
Specify the AutoVrtlEnv.exe that for the specific name of the scene to be
corresponds to the desired packaged used in the Simulation. In this case that
project. name is “HwCurveTest”.

If the scene call string is entered correctly and the project was compiled correctly everything
should be in place to run the simulation. This can be done by selecting the in the toolbar.

28
If everything worked as it should, congratulations! A window similar to the one below should
appear. The scene will be different depending on what custom scene was chosen.

However, at the time of writing this guide, to the knowledge of the Unreal Engine Team, there
exists a bug somewhere in Matlab which causes custom scenes to not be called correctly if
they do not share the same name as default scenes. If this happens, something resembling
the picture below may appear. A workaround was found to allow custom scenes to be used;
this workaround can be found in the Appendix.

29
APPENDIX

Scene Call Workaround


Simply put, use the default names. The workaround is to just customize scenes and keep them
as the same names as the default scenes to allow the Simulation 3D Config block to actually
use the custom scenes. When customizing new scenes in the Unreal Engine Editor, do not
change the names of the default scenes and instead keep track of what scene goes with what
default name in an external text file, physically write it down, or something similar.

In addition to this its possible to compile the


same project into different executables each
containing different scenes, despite all the
scenes sharing the same set of names. This
allows the user to circumvent the artificial
scene limit imposed by the number default
scenes in addition to the hidden scenes.
Just rename the compiled exe after the
packaging process so the next packaging
operation does not override the previous exe.

Windows 8.1 SDK Install


In some cases, depending on the age of the computer, windows versions, or other external
factors sometimes an SDK may be missing. If this is the case the Unreal Engine Editor may
give off an error in the Output Log about missing an SDK. To fix this you may need to visit this
site here, or at https://developer.microsoft.com/en-us/windows/downloads/sdk-archive
and download the missing SDK. Just follow instructions on the site and in the SDK installer
itself.

Packaging Settings
Some packaging settings that may be worth looking at are displayed in the pictures below.
Epic Games & the Unreal Engine Editor recommend turning on the Full Rebuild option when
packaging projects. It is found on the main window when opening the Packaging Settings
shown in the “Compiling the Project” section earlier.

30
Another setting of note that may prove useful if the Unreal Engine is having trouble finding the
correct compiler to use is the Toolchain>Compiler Version setting. With this setting you can
specify which compiler the Unreal Engine will use. Naturally it is set to default by default, but it
can be changed to specify VS 2017. To do this just search “toolchain” in the search bar of the
Packaging Settings window and change the dropdown option.

31
REFERENCES

Academy, G. (Director). (2018, January 14). Unreal Engine 4 Tutorial for Beginners | Free UE4
Training [Video file]. Retrieved September 21, 2019, from
https://www.youtube.com/watch?v=a0qNO6_xPx0&t=9296s

Engine, U. (2015, January 14). Blender & UE4 | 01 | Live Training | Unreal Engine. Retrieved
September 21, 2019, from https://www.youtube.com/watch?v=Ayp1lof0RJU

Skeletal Meshes. (n.d.). Retrieved September 21, 2019, from


https://docs.unrealengine.com/en-US/Engine/Content/Types/SkeletalMeshes/index.html

Static Mesh Components. (n.d.). Retrieved September 21, 2019, from


https://docs.unrealengine.com/en-US/Engine/Components/StaticMesh/index.html

32

You might also like