SceneKit:如何控制导入资产的大小,一个DAE文件创建了巨大的SCNNode,而另一个DAE文件则创建了“正常"的SCNNode. [英] SceneKit: how to control size of imported assets, one DAE file creates SCNNode of huge size while another is "normal"

查看:142
本文介绍了SceneKit:如何控制导入资产的大小,一个DAE文件创建了巨大的SCNNode,而另一个DAE文件则创建了“正常"的SCNNode.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设计师提供了附加了在电影4D .

在Cinema 4D中,这两种资产的大小均相当.这两个DAE文件都是用相同的导出过程生成的.

Both assets are of comparable size inside of Cinema 4D. Both DAE files were produced with the same export process.

但是,将DAE文件导入到SceneKit场景中会产生不同的结果.

Importing the DAE files into a SceneKit scene, however, produces different results.

Chango.dae以正常"大小导入,边框为〜3x4x3.

Chango.dae imports at a "normal" size with a bounding box of ~3x4x3.

Tiki.dae会以155x325x140的包围盒巨大尺寸导入.它在C4D中的尺寸为〜122x283x142.

Tiki.dae imports at a huge size with a bounding box of ~155x325x140. Its dimensions inside C4D are ~122x283x142.

问题:

1)您如何确保资产适合" SceneKit场景?您是应该使用SCNNode的"scale"属性按比例缩小资产,还是应要求设计者制作一定大小的资产?在SpriteKitUIKit中,这很简单.资产的大小与屏幕大小直接相关(例如,20x20图标占用的屏幕空间取决于分辨率).但是,SceneKit的模拟是什么?如果您希望资产适合1x1x1 SCNNode,请问设计者要制造多少尺寸?

1) How do you make sure assets "fit" into a SceneKit scene? Are you supposed to scale down assets with the "scale" property of the SCNNode, or are you supposed to ask the designer to make the asset of a certain size? In SpriteKit and UIKit, this is straightforward. The asset size correlates directly to its screen size (e.g., 20x20 icon takes about that much screen space depending on resolution). However, what's the analog for SceneKit? If you want an asset to fit into a 1x1x1 SCNNode, what size do you ask the designer to make the asset?

2)如果您的资产对于某个场景而言太大,那么如何缩小规模?例如,在UIKit中,您可以缩放图像以使UIViewScaleAspectFit类似. SCNNode似乎没有类似物.使用SCNNode的scale属性可以更改外观,但不会更改资产的边界框.甚至改变外观也不是很精确.例如,对于Tiki.dae,资产的原始高度(如边界框所示)为324.36.但是,如果将Y比例设置为0.01,则高度不会变为〜3.24.它变得小于3,可以通过将其舒适地装配在高度3(半径为1.5)的球体内来证明.

2) If your asset is too large for a scene, how do you scale it down? In UIKit, for instance, you can scale an image to fit a UIView with something like ScaleAspectFit. There doesn't seem to be an analog for a SCNNode. Using the SCNNode's scale property changes the appearance, but doesn't change the asset's bounding box. And even changing the appearance isn't precise. For instance, with Tiki.dae, the original height of the asset (as shown by the bounding box) is 324.36. If you set the Y-scale to 0.01, however, the height doesn't become ~3.24. It becomes smaller than 3, which you can prove by fitting it comfortably within a sphere of height 3 (radius of 1.5).

推荐答案

如果打开Collada文件,您会发现在一种情况下,距离以米表示:

If you open the Collada files you'll find that in one case distances are expressed in meters:

Chango.dae

Chango.dae

<unit name="meter"/>

,在另一种情况下,它们以厘米为单位:

and in the other case they are expressed in centimeters:

Tiki.dae

Tiki.dae

<unit meter="0.01" name="centimeter"/>

因此,值1在一个文件中表示1m,在另一个文件中表示1cm. 这是一个资产问题,您可能可以在Cinema 4D中解决,也可以通过手动编辑Collada文件来解决.您还可以使用 convertUnitsToMeters 在加载时转换单位的选项.

So a value of 1 means 1m in one file and 1cm in the other. This is an asset issue that you can probably fix in Cinema 4D, or by manually editing the Collada file. You can also use the convertUnitsToMeters option to convert units at load time.

这篇关于SceneKit:如何控制导入资产的大小,一个DAE文件创建了巨大的SCNNode,而另一个DAE文件则创建了“正常"的SCNNode.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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