simulation_看看Simulation在Unity MARS中如何工作

Unity MARS的Simulation系统减少了AR应用的测试时间,允许在编辑器内进行AR测试,提供模拟数据以预览AR设备在真实环境中的表现。通过执行预览和环境场景设置,Simulation支持快速迭代,简化了适应性AR体验的创建。Simulation提供综合、记录和实时数据,以模拟真实世界的不同情况,助力开发者创建复杂AR体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

simulation

The Simulation system in Unity MARS reduces testing time for augmented reality (AR) app development. It provides world-understanding capabilities, like plane and image marker detection, right in the Unity Editor — in both Play and Edit Mode. Read on to learn more about this system and how creators can use it to rapidly iterate on context-adaptable AR experiences.

Unity MARS中的仿真系统减少了增强现实(AR)应用程序开发的测试时间。 它在Play和Edit模式下都可以在Unity Editor中提供世界公认的功能,例如平面和图像标记检测。 继续阅读以了解有关此系统的更多信息,以及创建者如何使用它来快速迭代适合上下文的AR体验。

Unity MARS makes it easy to create complex AR experiences that intelligently adapt to the real world. We designed this authoring tool to address the three most common pain points for AR developers: authoring for an enormous possibility space of data, iterating and testing against real-world scenarios, and delivering apps that adapt responsively to their environment. 

Unity MARS 使创建智能适应现实世界的复杂AR体验变得容易。 我们设计了这种创作工具,以解决AR开发人员最常见的三个痛点:创作巨大的数据空间,针对实际场景进行迭代和测试以及提供可适应其环境的应用程序。

Simulation solves the problem of iteration time by enabling AR testing within the Unity Editor to preview how an AR device would work with its physical surroundings. Simulation facilitates testing against a variety of environments that imitate or come from the real world. This makes it easier to create apps and experiences that are adaptable and accessible. In combination with the proxy and condition-matching systems of Unity MARS, Simulation helps empower creators to push the boundaries of spatial computing.

通过在Unity Editor中启用AR测试以预览AR设备如何在其物理环境中工作,仿真解决了迭代时间的问题。 仿真有助于在模拟或来自现实世界的各种环境中进行测试。 这使创建适应性强且可访问的应用程序和体验变得更加容易。 结合Unity MARS的代理和条件匹配系统,Simulation可帮助创建者突破空间计算的界限。

As a system, Simulation can be broken down into two core functionalities that are conceptually separate, but work together to drastically reduce iteration time:

作为一个系统,仿真可以分解为两个核心功能,它们在概念上是分开的,但是可以共同工作以大大减少迭代时间:

  1. Preview the execution of a scene in isolation in Edit Mode.

    在“编辑模式”下单独预览场景的执行。

  2. Set up an environment scene in the Editor, and provide AR data based on that environment.

    在编辑器中设置环境场景,并根据该环境提供AR数据。

We’ll go into detail on how these parts of Simulation work to improve AR development.

我们将详细介绍Simulation的这些部分如何工作以改善AR开发。

执行预览如何工作 (How execution previewing works)

Simulation lets you preview the execution of a scene in Edit Mode to support rapid iteration and provide an instantaneous understanding of how flexible proxies that represent real-world objects might behave in the real world. In the execution preview process, Simulation copies the GameObjects in the active scene into a preview scene – called the content scene – and sets the runInEditMode flag on each MonoBehaviour in the content scene that opts into running. See the Unity MARS documentation for details on how to write MonoBehaviours that are compatible with Simulation scene preview.

通过仿真,您可以在“编辑模式”下预览场景的执行,以支持快速迭代,并即时了解代表真实对象的灵活代理在真实世界中的行为。 在执行预览过程中,Simulation将活动场景中 的GameObjects 复制到预览场景(称为 内容场景)中 ,并在选择运行的内容场景中的每个MonoBehaviour上设置runInEditMode标志。 有关 如何编写与Simulation场景预览兼容的MonoBehaviours的详细信息, 请参见 Unity MARS文档

With the Simulation view, you can interact with this scene execution preview in isolation from your open Unity scenes. The Simulation view is a custom Scene view that shows the content scene rendered over the environment scene (the next section digs more into the environment scene), from either a third-person perspective or from the camera’s perspective.

使用“模拟”视图,您可以与此场景执行预览进行交互,而与打开的Unity场景隔离。 “模拟”视图是一个自定义“场景”视图,它从第三人称视角或从摄像机的视角显示在环境场景上渲染的内容场景(下一节将深入探讨环境场景)。

In Unity MARS, the default behavior of a Simulation preview is to run in instant mode. In this mode, the entire execution process happens over a single frame, in which Unity MARS tries to match proxies against all data at once. While this behavior is not realistic, it has the benefit of providing immediate feedback as you define proxies and their conditions.

在Unity MARS中,模拟预览的默认行为是在 即时模式下 运行 。 在这种模式下,整个执行过程发生在单个框架上,在该框架中,Unity MARS尝试一次将代理与所有数据进行匹配。 尽管此行为不现实,但在定义代理及其条件时,它具有提供即时反馈的好处。

You can also manually start and stop a continuous mode Simulation preview. This mode is more analogous to Play Mode, in that the behaviors in the content scene run frame by frame until the preview is stopped. App interaction and behavior in continuous preview are limited, since some Unity systems, like physics and input, only work in Play Mode. Continuous preview is useful for seeing how your app responds to data that changes over time while still being able to quickly make revisions to your scene.

您还可以手动启动和停止 连续模式的 模拟预览。 此模式与“播放模式”更相似,因为内容场景中的行为逐帧运行,直到预览停止。 由于某些Unity系统(例如物理系统和输入)只能在“播放模式”下运行,因此连续预览中的应用交互和行为受到限制。 连续预览对于查看您的应用如何响应随时间变化的数据,同时仍然能够快速对场景进行修订非常有用。


The Simulation system keeps track of the status of the content scene in relation to the active scene, keeping it up to date as you make changes. If you make any property modification to an object that has a copy running in the content scene, Simulation picks up on that change and indicates that it is Out of Sync, which means the latest changes will not apply to the preview until it is resynced. In the resync process, Simulation destroys the content objects, replaces them with new copies from the active scene, and then starts running the new copies.


Simulation系统会跟踪内容场景相对于活动场景的状态,并在您进行更改时使其保持最新状态。 如果对内容场景中正在运行副本的对象进行任何属性修改,则Simulation会选择该更改并指示其 不同步 ,这意味着最新更改将在重新同步之前不会应用于预览。 在重新同步过程中,Simulation销毁内容对象,用活动场景中的新副本替换它们,然后开始运行新副本。

Simulation has an option to automatically resync preview, so you can iterate on proxies and instantly see your changes reflected in the Simulation view. This is especially powerful in combination with the visual authoring features of Unity MARS, which work not only in the standard Scene view, but also in the Simulation view. You can change proxy conditions in the context of the environment and instantly see how adjusting condition parameters changes the outcome. For large and complex scenes that would be expensive to copy, we recommend that you disable the auto-sync option and instead manually resync when necessary.

Simulation具有自动重新同步预览的选项,因此您可以迭代代理并立即查看反映在Simulation视图中的更改。 与Unity MARS的视觉创作功能结合使用时,此功能特别强大,不仅可以在标准“场景”视图中使用,而且可以在“模拟”视图中使用。 您可以在环境的上下文中更改代理条件,并立即查看调整条件参数如何改变结果。 对于要复制昂贵的大型复杂场景,我们建议您禁用自动同步选项,而在必要时手动重新同步。

Simulation如何提供AR数据 (How Simulation provides AR data)

The construct of an environment is fundamental to Simulation. An environment is a set of objects separate from the app content that is running in Simulation. Practically speaking, the environment is a scene with its own isolated physics and lighting that renders underneath the app content, both in the Simulation view as well as the Game view in Play Mode. This separation exists so that testing in the Editor can behave as closely as possible to testing on an AR device, with the environment acting as the real world in the Editor.

环境 的构建 是仿真的基础。 环境是一组与Simulation中运行的应用程序内容分离的对象。 实际上,环境是一个场景,具有独立的物理特性和照明,并在“模拟”视图和“游戏模式”下的“游戏”视图中呈现在应用程序内容的下方。 存在这种分离,以便在环境中充当编辑器中的真实世界时,编辑器中的测试可以表现得与AR设备上的测试尽可能接近。

Data providers are the key link between the environment and content. Like other kinds of AR data providers, Simulation providers exist alongside the app content, but they also have access to information from the environment. To work with execution previewing, these providers must work in both Play Mode and Edit Mode. There are a variety of ways Simulation providers can use environment information to provide data, but there are three main categories of data sources that Simulation works with: synthetic, recorded, and live.

数据提供者 是环境与内容之间的关键链接。 像其他类型的AR数据提供程序一样,Simulation提供程序与应用程序内容并存,但是它们也可以访问环境中的信息。 要使用执行预览,这些提供程序必须同时在播放模式和编辑模式下工作。 Simulation提供程序可以使用多种方式使用环境信息来提供数据,但是Simulation可以使用三种主要的数据源类别:合成,记录和实时。

综合数据 (Synthetic data)

Synthetic data is artificially created, rather than generated from real-world events. This data comes from a prefab that is instantiated in the environment scene. Unity MARS provides a set of default environment prefabs that includes rooms, buildings, and outdoor spaces. You can also create your own simulated environments.

合成数据是人为创建的,而不是从实际事件中生成的。 该数据来自在环境场景中实例化的预制件。 Unity MARS提供了一组默认的环境预制件,包括房间,建筑物和室外空间。 您还可以 创建自己的模拟环境

We’ve launched Simulation with synthetic AR capabilities for motion tracking, geolocation, plane finding, point cloud detection, image marker detection, and light estimation, with more to come. Most of this data is provided instantaneously from synthetic objects within the environment prefab. 

我们推出了具有综合AR功能的Simulation,可用于运动跟踪,地理定位,平面查找,点云检测,图像标记检测和光线估计,并且还有更多功能。 这些数据的大部分是从环境预制件中的合成对象即时提供的。


Simulation can also create data for motion tracking, point cloud detection, and plane finding through a process of simulated data discovery. Simulated discovery provides data dynamically based on the contents of the environment prefab (the simulated “real world”) and the state of the main camera in the Simulation content scene (the simulated “device”). To emulate data discovery on mobile devices, we only detect data when the camera moves and only use parts of the environment within the camera frustum to add to our simulated understanding of the world. We also create planes that grow in “chunks,” as they do on mobile devices, but these planes are limited to facing up, down, left, right, forward, or back.


仿真还可以通过仿真数据发现过程创建用于运动跟踪,点云检测和平面查找的数据。 模拟发现基于环境预制件的内容(模拟的“真实世界”)和模拟内容场景中的主摄像机的状态(模拟的“设备”)动态提供数据。 为了在移动设备上模拟数据发现,我们仅在照相机移动时才检测数据,并且仅使用照相机视锥中的部分环境来增加对世界的模拟理解。 我们还创建了像在移动设备上一样以“块状”增长的飞机,但是这些飞机仅限于面向上,向下,向左,向右,向前或向后。

记录数据 (Recorded data)

Simulation can also provide data by playing back a recording of an AR session. These recordings can be created using the upcoming Unity MARS companion app or using Simulation itself. Unity MARS also provides sample recordings of face-tracking data.

仿真还可以通过回放AR会话的记录来提供数据。 可以使用即将推出的 Unity MARS配套应用 或Simulation本身 来创建这些录音 。 Unity MARS还提供面部跟踪数据的示例记录。

Recorded session data is stored in a Timeline asset, with one track for each type of data. A Playable Director in the environment plays the session recording Timeline, and provider objects in the app content are bound to data tracks so they can provide the actual data. See the Unity MARS documentation for more information on session recording objects.

记录的会话数据存储在时间轴资产中,每种类型的数据都有一个轨道。 环境中的Playable Director播放会话记录时间轴,并且应用程序内容中的提供者对象已绑定到数据轨道,因此它们可以提供实际数据。 有关 会话记录对象的更多信息, 请参见 Unity MARS文档

Because session recordings are represented as Timelines, you can work with them as you would other Timelines. For example, you can modify the looping behavior or tweak the contents of the data tracks.

由于会话记录以时间轴表示,因此您可以像使用其他时间轴一样使用它们。 例如,您可以修改循环行为或调整数据磁道的内容。


In Edit Mode, you can also scrub through a recording in the Timeline window. An important caveat of scrubbing is that the proxy system and other Unity MARS behaviors cannot run backward in time, so the Simulation system treats time scrubbing as a change that requires a resync of the execution preview. When execution restarts, the recording begins anew and execution runs at a faster time scale to catch up to the new time. For details on how to write behaviors compatible with time resyncing, refer to the Unity MARS documentation.


在编辑模式下,您还可以在“时间轴”窗口中浏览记录。 清理的一个重要警告是 代理系统和其他Unity MARS行为不能在时间上向后运行 ,因此Simulation系统将清理时间视为需要重新同步执行预览的更改。 重新开始执行时,记录会重新开始,并且执行会以更快的时间范围运行以赶上新的时间。 有关如何编写与时间重新同步兼容的行为的详细信息,请参阅 Unity MARS文档

实时数据 (Live data)

This data comes from real-time, real-world events. We’ve launched Simulation with the ability to provide a live camera image via a webcam device. The environment in this case includes the video player object and the camera image quad, while the data provider in the app content provides the raw texture. A third-party license is required to get face-tracking data from this texture.

此数据来自实时,真实事件。 我们已经启动了Simulation,能够通过网络摄像头设备提供实时摄像头图像。 在这种情况下,环境包括视频播放器对象和摄像机图像四边形,而应用程序内容中的数据提供者则提供原始纹理。 需要第三方许可证才能从此纹理获取面部跟踪数据。

Unity MARS和AR开发的层次 (Layers of Unity MARS and AR development)

Unity MARS can work with data from AR Foundation, from Simulation, or from custom providers. All of this data goes through an abstraction layer that includes the Unity MARS database – used by the proxy-matching system – as well as a layer for general AR functionality. This way your app content and the systems that use data do not need to know which device the data comes from or whether the data comes from Simulation.

Unity MARS可以处理来自AR Foundation,Simulation或自定义提供程序的数据。 所有这些数据都经过一个抽象层,该层包括由代理匹配系统使用的Unity MARS数据库,以及一个用于常规AR功能的层。 这样,您的应用程序内容和使用数据的系统就不必知道数据来自哪个设备,或者数据是否来自模拟。

We know Simulation is a powerful general tool for AR development. We’re excited to share that later this year, creators using Unity MARS will be able to use the Simulation system without requiring the proxy system. With Simulation as its own XR subsystem, creators will be able to take advantage of Edit Mode previewing and AR capabilities in the Editor, adding flexibility and Simulation support for any kind of XR project you’re working on. And, of course, all Unity MARS features, including Simulation, will always work with AR Foundation.

我们知道模拟是用于AR开发的强大的通用工具。 我们很高兴与大家分享今年晚些时候,使用Unity MARS的创作者将能够使用Simulation系统,而无需代理系统。 通过将Simulation作为其自己的 XR子系统 ,创建者将能够利用编辑器中的编辑模式预览和AR功能,从而为正在处理的任何XR项目增加灵活性和Simulation支持。 而且,当然,所有Unity MARS功能(包括Simulation)都将始终与AR Foundation一起使用。

有关Simulation和Unity MARS的更多信息 (For more information about Simulation and Unity MARS)

Visit our webpage for more information about Unity MARS and join us in the Unity Forums for further discussion and questions related to Simulation.

请访问我们的网页 ,以获取有关Unity MARS的更多信息,并加入我们的 Unity论坛中 ,进行与仿真有关的进一步讨论和问题。

Get started with Unity MARS

开始使用Unity MARS

翻译自: https://blogs.unity3d.com/2020/08/14/a-look-at-how-simulation-works-in-unity-mars/

simulation

XIN_SIMULATION_MODE是一个宏定义,用于设置Xilinx中断控制器(XIntc)的启动模式[^1]。具体来说,XIN_SIMULATION_MODE用于将XIntc设置为仿真模式,以便在仿真环境中进行中断控制器的测试和调试。 在Xilinx中,中断控制器(XIntc)是一种硬件模块,用于管理和处理系统中的中断信号。它可以连接到多个外部设备,并根据优先级和中断掩码来处理中断请求。XIntc提供了一组API函数,用于配置和操作中断控制器。 在使用XIntc之前,需要通过调用XIntc_Initialize函数来初始化中断控制器实例。然后,可以使用XIntc_Connect函数将中断处理函数与特定的中断ID关联起来。接下来,通过调用XIntc_Start函数来启动中断控制器,并使用XIntc_Enable函数来启用特定的中断。 在启动模式方面,XIntc提供了两种模式:硬件中断模式和仿真模式。硬件中断模式用于实际的硬件系统,而仿真模式用于在仿真环境中进行测试和调试。XIN_SIMULATION_MODE宏定义用于将XIntc设置为仿真模式,以便在仿真环境中进行中断控制器的测试和调试。 下面是一个示例代码,演示了如何使用XIN_SIMULATION_MODE启动XIntc并设置为仿真模式: ```c #include <xintc.h> #include <xil_exception.h> #define INTC_DEVICE_INT_ID 0 #define XIN_SIMULATION_MODE 1 XIntc XIntcInstance; void DeviceDriverHandler(void *data) { // 中断处理函数的实现 } int main() { XStatus Status; // 初始化中断控制器 Status = XIntc_Initialize(&XIntcInstance, XPAR_INTC_DEVICE_ID); if (Status != XST_SUCCESS) { // 错误处理 } // 连接中断函数和对应的中断ID Status = XIntc_Connect(&XIntcInstance, INTC_DEVICE_INT_ID, (XInterruptHandler)DeviceDriverHandler, (void *)0); if (Status != XST_SUCCESS) { // 错误处理 } // 打开主启用寄存器,分为硬件中断和软件中断两种 Status = XIntc_Start(&XIntcInstance, XIN_SIMULATION_MODE); if (Status != XST_SUCCESS) { // 错误处理 } // 打开中断挂起寄存器,允许某些中断起作用 XIntc_Enable(&XIntcInstance, INTC_DEVICE_INT_ID); // 中断例外三件套 Xil_ExceptionInit(); Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler)XIntc_InterruptHandler, &XIntcInstance); Xil_ExceptionEnable(); // 其他代码 return 0; } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值