Place Cameras on Actors in theUnreal编辑or
在虚幻中可视化对象®编辑场景,您可以将摄像机放在场景中的静态演员或自定义演员上。首先,您需要Vehicle Dynamics Blockset在terface forUnreal Engine4 Projects万博1manbetx支持包。看在stall Support Package and Configure Environment。
要遵循此工作流程,您应该舒适使用虚幻引擎®。Make sure that you have Visual Studio®2019年安装在您的计算机上。
Place Camera on Static Actor
Follow these steps to place aSimulation 3D Camera Getblock that is offset from a cone in the Unreal Editor. Although this example uses the进行视频显示从Computer Vision Toolbox™块中块,您可以使用其他可视化块显示图像。
在模拟中万博1manbetx®模型,添加Simulation 3D Scene Configuration,Simulation 3D Camera Get, 和进行视频显示块。
Set these block parameters. In theSimulation 3D Scene Configurationblock, select打开虚幻编辑器。
堵塞 参数设置 Simulation 3D Scene Configuration
场景来源—
Unreal Editor
Project— Specify the path and name of the support package project file. For example,
C:\Local\AutoVrtlEnv\AutoVrtlEnv.uproject
Simulation 3D Camera Get
Sensor identifier—
1
Vehicle name—
Scene Origin
车辆安装位置—
起源
Specify offset—
上
Relative translation [X, Y, Z]—
[-6, 0, 2]
This offsets the camera location from the cone mounting location, 6 m behind, and 2 m up.
Relative rotation [Roll, Pitch, Yaw]—
[0, 15, 0]
在里面Unreal Editor, from the放置演员选项卡,添加一个模拟3D场景帽to the world, scene, or map.
在里面Unreal Editor, from the放置演员选项卡,添加一个锥体to the world, scene, or map.
On theWorld Outliner tab, right-click theSim3DSceneCap1和attach it to the锥体。
On theDetailstab, under转换, add a location offset of
-500,0,100
in the X, Y, and Z world coordinate system, respectively. This attaches the camera 500 cm behind the cone and 100 cm above it. The values match theSimulation 3D Camera Getblock parameterRelative translation [X, Y, Z]value.On theDetailstab, underActor,标记Sim3DSceneCap1with the name Camera1.
Run the simulation.
在Simuli万博1manbetxnk模型中,单击Run。
Because the source of the scenes is the project opened in the Unreal Editor, the simulation does not start.
Verify that the Diagnostic Viewer window in Simulink displays this message:
在模拟3D场景配置块中,您将场景源设置为“虚幻编辑器”。在虚幻编辑器中,选择“播放”以查看场景。
This message confirms that Simulink has instantiated the vehicles and other assets in the Unreal Engine 3D environment.
在里面Unreal Editor, click玩。The simulation runs in the scene currently open in the Unreal Editor.
Observe the results in the To Video display window. The window displays the image from the camera.
Place Camera on Vehicle in Custom Project
Follow these steps to create a custom Unreal Engine project and place a camera on a vehicle in the project. Although the example uses the进行视频显示block from Computer Vision Toolbox, you can use a different visualization block to display the image.
首先,您需要Vehicle Dynamics Blockset在terface forUnreal Engine4 Projects万博1manbetx支持包。看在stall Support Package and Configure Environment。
在模拟中万博1manbetx模型,添加Simulation 3D Scene Configuration,Simulation 3D Camera Get,进行视频显示,Simulation 3D Actor Transform Set和三个持续的块。
Save the model.
使用车辆先进template from the Epic Games Launcher by Epic Games®。
在里面Epic Games Launcher, launch Unreal Engine 4.26.
For more information about the Epic Games Launcher, seeUnreal Engine。
在里面Unreal Project Browser, selectGames和下一个。
在选择模板,选择车辆先进模板并单击下一个。
在Project Settings,创建蓝图或C ++项目,然后选择一个项目名称和位置。点击创建项目。
The Epic Games Launcher creates a new project and opens the Unreal Editor.
Enable the MathWorks Interface plugin.
Select编辑>插件。
On the插件tab, navigate to MathWorks Interface. SelectEnabled。
Save the project. Close the Unreal Editor.
Open the Simulink model that you saved in step 1. Set these block parameters.
堵塞 参数设置 Simulation 3D Scene Configuration
场景来源—
Unreal Editor
Project- 指定您在步骤2中保存的项目的路径。例如
Myproject Path
\myProject
。uproject
Simulation 3D Camera Get
Sensor identifier—
1
Vehicle name—
Scene Origin
车辆安装位置—
起源
Simulation 3D Actor Transform Set
Tag for actor in 3D scene—
MainCamera1
ActTranslation
持续的value—
[-11310.0 - 300, 8140.0, 100]/100
在terpret vector parameters as 1-D—
离开
ActRotation
持续的value—
[0 0 0]
在terpret vector parameters as 1-D—
离开
ActScale
持续的value—
(1 1 1)
在terpret vector parameters as 1-D—
离开
在里面Simulation 3D Scene Configurationblock, select打开虚幻编辑器。
在虚幻编辑中,在内容浏览器navigate to
Sim3DCamera
。将其添加到世界,场景或地图中。在车辆上
VehicleBlueprint
,拖放相机。选择车辆插座或骨头将相机连接到。On theDetails标签,标记
Sim3dCamera1
with the nameCamera1
。设置父类。
UnderBlueprints, 点击Open Level Blueprint, 和selectClass Settings。
在里面类选项, set父级to
Sim3dLevelScriptActor
。
Save the project.
Run the simulation.
在Simuli万博1manbetxnk模型中,单击Run。
Because the source of the scenes is the project opened in the Unreal Editor, the simulation does not start.
Verify that the Diagnostic Viewer window in Simulink displays this message:
在模拟3D场景配置块中,您将场景源设置为“虚幻编辑器”。在虚幻编辑器中,选择“播放”以查看场景。
This message confirms that Simulink has instantiated the vehicles and other assets in the Unreal Engine 3D environment.
在里面Unreal Editor, click玩。The simulation runs in the scene currently open in the Unreal Editor.
Observe the results in the To Video Display window.
看Also
Simulation 3D Camera Get|Simulation 3D Scene Configuration