Reality Kit:在Real Composer中创建的“行为"存储在.rcproject对象中的什么位置? [英] Reality Kit: Where are 'behaviours' created in reality composer stored in the .rcproject object?

查看:194
本文介绍了Reality Kit:在Real Composer中创建的“行为"存储在.rcproject对象中的什么位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况

我正在用xcode(11.3.1)制作一个AR应用程序.我已经使用Reality Composer向场景中添加了对象(例如,立方体),并使用Reality Composer向这些对象添加了行为(即,轻按并翻转并看着相机).保存后,切换到ViewController.swift

I am making an AR app in xcode (11.3.1). I have added objects (e.g. a cube) into the scene using reality composer and added behaviours (i.e. tap and flip and look at camera) to those objects, also using reality composer. Saved that, switched to ViewController.swift

在ViewController中,我加载Experience.rcproject并通过编写var box = try! Experience.loadBox()访问默认的Box场景.所有工作都按预期进行.

In ViewController, I load in the Experience.rcproject and access the default Box scene by writing var box = try! Experience.loadBox(). All works as expected.

然后,我在层级结构中打印各种对象,以了解它们是如何构造的.因此,例如,我将编写print(box)并在此处中查看所有描述的实体和组件. >

I am then printing the various objects in the hierachy to understand how they are constructed. So I will for example write print(box) and see all the entities and components as they are described here

问题

我可以看到诸如Transform的位置等信息和ModelComponent的网格,材料等信息,这一切都说得通,但是我看不到.rcproject迅速成为对象的行为存储在哪里. .

I can see things like Transform for position etc. and ModelComponent for the mesh, materials etc. and this all makes sense but I cannot see where the behaviours are stored within the object that the .rcproject becomes within swift.

例如,如果我在现实作曲家中添加了look at camera行为,则我的假设是该对象上将附着类似广告牌"组件的内容,但我看不到该对象之间的任何区别有应用的行为,有没有的行为.

For example, if I have added a look at camera behaviour in reality composer, my assumption would be that there would be something like a `billboard' component attached to that object, but I don't see any difference between objects that have behaviours applied, and those that don't..

另一个例子是,将tap and flip添加到对象后,我希望在该对象内的某处找到一些动画信息,但是我再也看不到它附加在该对象上.我也看不到场景对象内任何位置的任何动画信息或行为组件.

Another example would be, having addded tap and flip to an object, I would expect to find some animation information somewhere within the object, but again I can't see it attached to the object. Nor can I see any animation info, or behaviour components any where within the scene object.

任何地方都知道我可以在哪里访问这些文件吗?在box下似乎有一个叫做actions的东西,但是打印后仅返回Experience.Box.Actions而没有更多信息.

Does anywhere know where I might be able to access these? There seems to be something under box called actions but printing that simply returns Experience.Box.Actions with no more info.

我看错地方了吗?还是不暴露这些?

Am I looking in the wrong place? Or are these not exposed?

推荐答案

打印Entity以获得包含组件的路径:

Print Entity to get a path containing components:

let boxAnchor = try! Experience.loadBox()
let entity = boxAnchor.steelBox!

print(entity as Any)
print(entity.components[PhysicsBodyComponent] as Any)

然后应用新值:

var physicsComponent: PhysicsBodyComponent = entity.components[PhysicsBodyComponent]!

physicsComponent.mode = .dynamic

boxAnchor.steelBox?.components.set(physicsComponent)
arView.scene.anchors.append(boxAnchor)

这篇关于Reality Kit:在Real Composer中创建的“行为"存储在.rcproject对象中的什么位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆