简体   繁体   English

3D模型(dae格式)在SceneKit编辑器中显示,但不在运行时显示

[英]3D model (dae format) shows in SceneKit editor, but not at runtime

I grabbed a simple pool table made in Blender from the web, exported it to dae format, added it into a scene by dragging the file and dropping it into the scene editor. 我从网上抓起一个简单的Blender制作的台球桌,将其导出为dae格式,通过拖动文件并将其放入场景编辑器中将其添加到场景中。 The pool table shows fine there, however, when testing it on device/sim the model isn't visible and I just get a black screen. 池表在那里显示很好,但是,当在设备/ sim上测试时,模型不可见,我只是得到一个黑屏。 I can confirm it's something related to that model since I created a sphere from the primitive shapes in scene editor and that shows up fine. 我可以确认它是与该模型相关的东西,因为我在场景编辑器中从原始形状创建了一个球体并且显示得很好。 Also somehow the 3D model is there because the sphere sits on top of it. 也不知何故,3D模型就在那里,因为球体位于它上面。 The sphere has a rigid body setup and its affected by gravity and it doesn't fall because of the pool table. 球体具有刚体设置并且受重力影响,并且由于台球桌而不会下降。

将dae文件拖动到.scnassets文件夹中,使用内置转换器将其转换为.scn,然后将生成的文件拖动到主场景文件中以解决问题。

Check the normals of your object. 检查对象的法线。 Since SceneKit always culls backfaces, it won't show faces whose normals are pointing inwards. 由于SceneKit总是剔除背面,因此它不会显示法线指向内部的面。 You can fix them in Blender by going into Edit Mode , selecting everything with A , and pressing Ctrl + N . 您可以进入编辑模式 ,在A中选择所有内容,然后按Ctrl + N ,即可在Blender中修复它们。 If it still doesn't work, then it is possible something is wrong with the exporter and you'll have to examine the normals of the .dae file with a different program. 如果它仍然不起作用,那么导出器可能出现问题,您将不得不使用不同的程序检查.dae文件的法线。

I had the same problem when I dragged and dropped a .obj file into XCode (into the scene.scnassets folder). 当我将.obj文件拖放到XCode(进入scene.scnassets文件夹)时,我遇到了同样的问题。 The model would appear in the scene editor but wouldn't be there at runtime (on the simulator or on a device). 模型将出现在场景编辑器中,但不会在运行时出现(在模拟器上或设备上)。

Solved the problem by adding the .obj file to the scene.scnassets folder in Finder, rather than XCode. 通过将.obj文件添加到Finder中的scene.scnassets文件夹而不是XCode来解决问题。 The file then appears in XCode (refreshes automatically). 然后该文件出现在XCode中(自动刷新)。 I then selected the .obj file within XCode and clicked Editor > Convert to .scn file. 然后,我在XCode中选择了.obj文件,然后单击编辑器>转换为.scn文件。

The texture will not be there, so you need to do the same process of copying the .png file into the scene.scnassets folder in Finder, and then dragging and dropping the .png file onto the Diffuse property. 纹理将不存在,因此您需要执行将.png文件复制到Finder中的scene.scnassets文件夹,然后将.png文件拖放到Diffuse属性上的相同过程。

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

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