简体   繁体   English

如何在ARKit和SceneKit中正确扩展DAE模型?

[英]How to scale DAE models correctly in ARKit and SceneKit?

I'm currently trying to combine the following sources: 我目前正在尝试合并以下来源:

Apples SceneKit Vehicle Demo , Resp. 苹果SceneKit车辆演示Resp。 its Swift version , ARKit by example , and resp. 它的Swift版本ARKit示例 ,以及resp。 its Swift version . 它的Swift版本

Each project on its own works like a charm (although I changed the vehicle demo so that the car can be controlled by on-screen buttons). 每个项目本身就像一个魅力(虽然我改变了车辆演示,以便可以通过屏幕按钮控制汽车)。

Now, when I try to combine both projects to create an augmented reality racing game, I run into problems regarding the size of the .dae model of the car: it's too big. 现在,当我尝试将两个项目结合起来创建一个增强现实赛车游戏时,我遇到了关于.dae车型大小的问题:它太大了。

I can scale the model using the (chassis) nodes .scale property, but as soon as I add the SCNPhysicsVehicle properties and behaviour, the car gets reset(?) to its original size. 我可以使用(chassis)节点.scale属性缩放模型,但是只要我添加SCNPhysicsVehicle属性和行为,汽车就会重置(?)到原始大小。 I tried to scale the model in Xcode (open dae file, change scale), but its bounding box remains the same - that tells me that the rescaling didn't work properly. 我试图在Xcode中扩展模型(打开dae文件,更改比例),但它的边界框保持不变 - 这告诉我重新缩放不能正常工作。

Any hints? 任何提示?

1)you can scale the dae models by art.scnassets directly. 1)您可以直接通过art.scnassets缩放dae模型。

art.scnassets -> car.dae -> node inspector -> transforms -> scale the object

2) can scale 3dmodel by SCNAction 2)可以通过SCNAction缩放SCNAction

let scene = SCNScene(named: "art.scnassets/cup.dae")!
let node = scene.rootNode.childNode(withName: "cup", recursively: true)!
let action = SCNAction.scale(by: sender.scale, duration: 1.0)
node.runAction(action)

What I like to do is use Blender or some other 3d modeling program to resize your dae model to work in meters. 我喜欢做的是使用Blender或其他一些3D建模程序来调整你的dae模型的大小以便以米为单位工作。 Everything in ARKit is based on meters, so by sticking to the same metric you can get all your models to play well together without having to guess what the scale factor needs to be. ARKit中的所有内容都基于计量表,因此通过坚持相同的指标,您可以使所有模型在一起运行,而无需猜测需要的比例因子。

I'm not sure how to fix the model directly in Xcode. 我不确定如何直接在Xcode中修复模型。 However, you can fix it in blender. 但是,您可以在搅拌机中修复它。 Start by importing the object into blender. 首先将对象导入blender。 Select the object and observe it's dimensions. 选择对象并观察其尺寸。 Scale the object to the desired dimensions and apply them by hittin Ctrl + A, and selecting scale. 将对象缩放到所需的尺寸,然后按Ctrl + A应用它们,然后选择比例。 Alternatively, from the object menu, you can select Apply -> Scale. 或者,从对象菜单中,您可以选择“应用” - >“缩放”。 Now you can export your model with the corrected size. 现在,您可以使用更正的大小导出模型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM