ios 如何创建逼真的 .scn 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44814390/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create realistic .scn files?
提问by 14wml
Looking at the apple sample AR app, there are many realistic looking objects (cup, candle, etc). However working with the scene kit editor on Xcode it is clear that this only allows you to create basic objects.
查看苹果示例 AR 应用程序,有许多逼真的对象(杯子、蜡烛等)。然而,在 Xcode 上使用场景工具包编辑器很明显,这仅允许您创建基本对象。
My question is, what software/file can be used to create realistic scn
objects? I'm sure that there is software that allows you to create 3D models and covert them to scn
files. I just don't know which software to use or what files can be converted to scn
我的问题是,可以使用什么软件/文件来创建逼真的scn
对象?我确信有软件可以让您创建 3D 模型并将它们转换为scn
文件。我只是不知道该使用哪个软件或可以转换为哪些文件scn
Note:I understand that this question may be too vague/broad for the Stackoverflow guidelines. I just don't know where to pose my question and this seems like the best place
注意:我知道这个问题对于 Stackoverflow 指南来说可能过于模糊/宽泛。我只是不知道在哪里提出我的问题,这似乎是最好的地方
回答by D. Rothschild
To get some existing models to work with, here is what I did...just the basics that I know.
为了让一些现有的模型可以使用,这就是我所做的……只是我所知道的基础知识。
- I went to Turbosquidand found a 3D model that would work for me.
- Make sure it has the OBJ files. Buy and download.
- Next download Blender. Import the OBJ file you just bought.
- Export a DAE file.
- Drag the DAE files and any textures (png files) into the .scnassets folder in your project.
- Click on the DAE model in the .scnassets folder. Click to select the object in the Scene graph.
- Click the globe in the upper right.
- I clicked Diffuse and selected one of the PNGs I dragged in to apply it to the model
- 我去了Turbosquid并找到了一个适合我的 3D 模型。
- 确保它有 OBJ 文件。购买并下载。
- 接下来下载搅拌机。导入您刚购买的 OBJ 文件。
- 导出 DAE 文件。
- 将 DAE 文件和任何纹理(png 文件)拖到项目中的 .scnassets 文件夹中。
- 单击 .scnassets 文件夹中的 DAE 模型。单击以选择场景图中的对象。
- 单击右上角的地球。
- 我单击了“漫反射”并选择了我拖入的 PNG 之一以将其应用于模型
You can also skip the Blender conversion and just use one of the free online OBJ to DAE conversion tools. Google it. And try to buy a cheap $5 range model on Turbosquid that just has a OBJ file and not a lot of other piece parts. They are too big and create other issues as a starter approach anyway.
您也可以跳过 Blender 转换,只使用免费的在线 OBJ 到 DAE 转换工具之一。去谷歌上查询。并尝试在 Turbosquid 上购买一个便宜的 5 美元范围模型,它只有一个 OBJ 文件而不是很多其他零件。它们太大了,无论如何都会产生其他问题作为入门方法。
UpdateAfter watching a Apple WWDC presentation on Model IO in Xcode, I now see that you could drop in a OBJ file into your .scnassets folder. Select that file, go to Editor and select Convert to SCN file. That should work also but I have not tried. Worth trying with a copy of your OBJ file.
更新在 Xcode 中观看了关于 Model IO 的 Apple WWDC 演示后,我现在看到您可以将 OBJ 文件放入您的 .scnassets 文件夹中。选择该文件,转到编辑器并选择转换为 SCN 文件。这也应该有效,但我还没有尝试过。值得尝试使用 OBJ 文件的副本。
Update December 2018:I've been working more with 3D files. Here is some incremental help on this issue.
2018 年 12 月更新:我一直在更多地使用 3D 文件。这里有一些关于这个问题的增量帮助。
Try using MeshLab to import your 3D model and convert it to a .DAE file. Drag the .DAE file into a folder in Xcode. That is what you are going to use to display in your app.
尝试使用 MeshLab 导入您的 3D 模型并将其转换为 .DAE 文件。将 .DAE 文件拖到 Xcode 中的文件夹中。这就是您将要用于在您的应用程序中显示的内容。
If your source 3D model is a .OBJ file, there are two related files that should be in the same folder as the .OBJ file. These are a *.mtl file and a *.jpg or *.BMP file. The .mtl file can be opened with TextEdit.
如果源 3D 模型是 .OBJ 文件,则有两个相关文件应与 .OBJ 文件位于同一文件夹中。它们是 *.mtl 文件和 *.jpg 或 *.BMP 文件。.mtl 文件可以用 TextEdit 打开。
Open and make sure it has a line that says: map_Kd *.jpg. The .jpg is the texture image the wraps around the 3D mesh file. I've found that it is best to make sure your texture file is in .jpg format. If it isn't, change it to .jpg format (in Preview for example by resaving it as a jpeg) and then edit the .mtl file for the new .jpg file name.
打开并确保它有一行写着:map_Kd *.jpg。.jpg 是环绕 3D 网格文件的纹理图像。我发现最好确保您的纹理文件是 .jpg 格式。如果不是,请将其更改为 .jpg 格式(例如在预览中将其重新保存为 jpeg),然后编辑 .mtl 文件以获得新的 .jpg 文件名。
I had some texture files that were .bmp and I just converted to .jpg, edited the .mtl file and I was good.
我有一些 .bmp 的纹理文件,我只是转换为 .jpg,编辑了 .mtl 文件,我很好。
The second issue is the name of the node in the .obj file. The .obj file can also be opened with TextEdit. The .obj file should reference the .mtl file in the same folder. If not, you have a problem.
第二个问题是 .obj 文件中节点的名称。.obj 文件也可以用 TextEdit 打开。.obj 文件应引用同一文件夹中的 .mtl 文件。如果没有,你就有问题。
And here is the tricky part. When you are adding a childNode to the rootNode in a SceneKit scene, you have to fill in the "withName:" text name. Open the converted .DAE file that you have made from your .obj + .jpg + .mtl (all three are used when importing into MeshLab but after exporting to .DAE, there is only the .DAE file), and search for "node id =" . It might say: "node id="node". If so, the word "node" is the name of the childNode you enter for your text name in the "withName:" property of the scene.rootNode.childNode(withName: "node", recursively: true) call.
这是棘手的部分。当你在 SceneKit 场景中向 rootNode 添加 childNode 时,你必须填写“withName:”文本名称。打开您从 .obj + .jpg + .mtl 制作的转换后的 .DAE 文件(导入 MeshLab 时使用所有三个文件,但导出到 .DAE 后,只有 .DAE 文件),然后搜索“节点标识 = 。它可能会说:“node id="node"。如果是这样,那么“node”这个词是您在scene.rootNode.childNode(withName:"的"withName:"属性中为文本名称输入的childNode的名称节点”,递归地:true) 调用。
You can change your node name ID to node if it isn't already.
您可以将节点名称 ID 更改为节点(如果尚未更改)。
Hope this helps. Many hours of work and help from others to understand this next round of working with 3D models.
希望这可以帮助。许多小时的工作和其他人的帮助,以了解下一轮使用 3D 模型的工作。
回答by rickster
Xcode's SceneKit editor isn't a 3D art authoring package — just like its SpriteKit editor and Interface Builder components aren't equivalent to the likes of Photoshop, Illustrator, Pixelmator, Affinity Designer, etc. To create 3D art assets yourself, you'll need to learn Blender, Maya, 3DS Max, or one of the other major 3D authoring tools. Beware, the learning curve to becoming a 3D artist is a bit steeper than learning how to paint in 2D.
Xcode 的 SceneKit 编辑器不是 3D 艺术创作包——就像它的 SpriteKit 编辑器和界面生成器组件不等同于 Photoshop、Illustrator、Pixelmator、Affinity Designer 等。要自己创建 3D 艺术资产,您将需要学习 Blender、Maya、3DS Max 或其他主要 3D 创作工具之一。请注意,成为 3D 艺术家的学习曲线比学习如何在 2D 中绘画要陡峭一些。
What the SceneKit editor isfor is taking the output from a 3D artist and preparing or combining it for use in a SceneKit-based app or game — tweaking material definitions so they look right with SceneKit's renderer, arranging separate assets to create a game level or other scene, adding dynamic SceneKit-specific features like particle effects and physics, etc.
SceneKit 编辑器的用途是获取 3D 艺术家的输出并准备或组合它以用于基于 SceneKit 的应用程序或游戏——调整材质定义使其与 SceneKit 的渲染器看起来正确,安排单独的资产以创建游戏关卡或其他场景,添加动态 SceneKit 特定功能,如粒子效果和物理等。
You bridge between these two worlds by exporting assets from your 3D art tools in one of the formats SceneKit can import. Digital Asset Exchange (.dae) is one of the best options here, but through SceneKit's lower level counterpart, Model I/O, you can also import other formats like OBJ or Pixar USD.
通过以 SceneKit 可以导入的格式之一从 3D 艺术工具导出资产,您可以在这两个世界之间架起桥梁。Digital Asset Exchange (.dae) 是这里最好的选择之一,但通过 SceneKit 的低级对应物Model I/O,您还可以导入其他格式,如 OBJ 或 Pixar USD。
When you open those in Xcode, you get the SceneKit editor, so you can start marking SceneKit-specific edits and save the results for use in your app as .scn files.
当您在 Xcode 中打开它们时,您将获得 SceneKit 编辑器,因此您可以开始标记 SceneKit 特定的编辑并将结果保存为 .scn 文件以在您的应用程序中使用。
There are a few things you can do in the process of authoring and prepping 3D assets that makes them look more realistic in ARKit. The ARKit session from WWDC(and the ReadMe file in the sample code project attached to that session) includes a few such tips:
在创作和准备 3D 资产的过程中,您可以做一些事情,使它们在 ARKit 中看起来更逼真。来自 WWDC的ARKit 会话(以及附加到该会话的示例代码项目中的自述文件)包括一些这样的提示:
- use physically based materials
- "bake" ambient occlusion and other static lighting effects
- add invisible shadow planes
- 使用基于物理的材料
- “烘焙”环境光遮蔽和其他静态光照效果
- 添加不可见的阴影平面
回答by Kamran
You can create your realistic 3D models in .DAE format which is supported by many tools. Then in Xcode, you can convert that .DAE file to .SCN format. For conversion, check this
您可以使用许多工具支持的 .DAE 格式创建逼真的 3D 模型。然后在 Xcode 中,您可以将该 .DAE 文件转换为 .SCN 格式。对于转换,检查这个
回答by Andy
In SceneKit's Scene graph
you can use pre-made 3D models, create 3D primitives (like cube, sphere, or cylinder) and reassign 2D textures.
在 SceneKit 中,Scene graph
您可以使用预制的 3D 模型,创建 3D 基元(如立方体、球体或圆柱体)并重新分配 2D 纹理。
The proper way to create life-like animated 3d models is to use professional 3D authoring tools like Autodesk Maya, Autodesk 3dsMax, Maxon Cinema 4D, The Foundry Modo, Blender or SideFX Houdini. These apps allow you create not only a perfect geometry but also realistic UV-mapped textures containing render passes for diffuse, transparency, metalness, bump, and occlusion slots of SceneKit's material editor.
创建栩栩如生的 3D 动画模型的正确方法是使用专业的 3D 创作工具,如 Autodesk Maya、Autodesk 3dsMax、Maxon Cinema 4D、The Foundry Modo、Blender 或 SideFX Houdini。这些应用程序不仅可以让您创建完美的几何体,还可以创建逼真的 UV 映射纹理,其中包含 SceneKit 材质编辑器的漫反射、透明度、金属度、凹凸和遮挡槽的渲染通道。
When your 3d model and set of UV-mapped textures are ready for use all you need to do is to save a .dae
file. Then in Xcode, select .dae
file and apply command from menu:
当您的 3d 模型和一组 UV 映射纹理准备好使用时,您需要做的就是保存.dae
文件。然后在 Xcode 中,.dae
从菜单中选择文件并应用命令:
Editor
- Convert to SceneKit file format...
Editor
—— Convert to SceneKit file format...
Now for converted .scn
model you can choose a Physically Based
shader in Material Inspector
. It's a PBR shader that makes your model photo-realistically believable.
现在对于转换后的.scn
模型,您可以Physically Based
在Material Inspector
. 这是一个 PBR 着色器,可让您的模型逼真地逼真。