uiimage – Swift:设置SCNMaterial适用于SCNBox但不适用于从Wings3D DAE加载的SCNGeometry

代码摘录(场景,相机,灯光等,从代码删除)在iOS模拟器上的 Swift中工作:
let BoxNode = SCNNode()

    // Create a Box
    BoxNode.geometry = SCNBox(width: 1,height: 1,length: 1,chamferRadius: 0.1)
    let numFaces = 6

    scene.rootNode.addChildNode(BoxNode)

    // create and configure a material for each face
    var materials: [SCNMaterial] = Array()

    for i in 1...numFaces
    {
        let material = SCNMaterial()
        material.diffuse.contents = UIImage(named: "texture")
        materials += material
    }

    // set the material to the 3d object geometry
    BoxNode.geometry.materials = materials

它会生成一个框,每个面都是方格图像.

尝试在Wings3D中创建的简单库存几何体,保存到DAE,并在应用程序中加载,给我一个合适的形状,但脸上没有阴影和图像:

let BoxNode = SCNNode()

    // Load the geometry
    let urlToColladaFile = NSBundle.mainBundle().URLForResource("Objects",withExtension:"dae")
    let scenesource = SCNScenesource(URL:urlToColladaFile,options:nil)

    BoxNode.geometry = scenesource.entryWithIdentifier("dodecahedron3-0",withClass:SCNGeometry.self) as SCNGeometry
    let numFaces = 10

    scene.rootNode.addChildNode(BoxNode)

    // create and configure a material for each face
    var materials: [SCNMaterial] = Array()

    for i in 1...numFaces
    {
        let material = SCNMaterial()
        material.diffuse.contents = UIImage(named: "texture")
        materials += material
    }

    // set the material to the 3d object geometry
    BoxNode.geometry.materials = materials

我错过了什么?

你的几何有纹理坐标吗?
您可以通过编程方式(通过检查是否存在具有SCNGeometrySourceSemanticTexcoord语义的源)或在Xcode中内置的SceneKit编辑器中进行验证.

另请注意,您不必为每个几何元素创建一个材质.如果它们完全相同,只需构建一个材质的数组,它将用于整个几何体.

相关文章

软件简介:蓝湖辅助工具,减少移动端开发中控件属性的复制和粘...
现实生活中,我们听到的声音都是时间连续的,我们称为这种信...
前言最近在B站上看到一个漂亮的仙女姐姐跳舞视频,循环看了亿...
【Android App】实战项目之仿抖音的短视频分享App(附源码和...
前言这一篇博客应该是我花时间最多的一次了,从2022年1月底至...
因为我既对接过session、cookie,也对接过JWT,今年因为工作...