首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >采用Vuforia AR库定制型号的SceneKit

采用Vuforia AR库定制型号的SceneKit
EN

Stack Overflow用户
提问于 2017-07-07 18:35:23
回答 1查看 167关注 0票数 0

我是SceneKit的新手,使用swift 3和最新的Vuforia库6-2-9。

我在自定义3D模型上应用textures时遇到了问题。

代码语言:javascript
复制
fileprivate func createDefaultMarkerScene(with view: VuforiaEAGLView) -> SCNScene {
    let scene = SCNScene()

    let lightNode = SCNNode()
    lightNode.light = SCNLight()
    lightNode.light?.type = .omni
    lightNode.light?.color = UIColor.lightGray
    lightNode.position = SCNVector3(x: 0, y: 0, z: 1000)
    scene.rootNode.addChildNode(lightNode)

    let ambientLightNode = SCNNode()
    ambientLightNode.light = SCNLight()
    ambientLightNode.light?.type = .ambient
    ambientLightNode.light?.color = UIColor.darkGray
    scene.rootNode.addChildNode(ambientLightNode)

    let geoNode = SCNNode()
    geoNode.name = "model_model"

    let normalsSources = SCNGeometrySource(normals: normalsSCNVector3)
    let verticesSources = SCNGeometrySource(vertices: verticesSCNVector3)
    let texCoordsSources = SCNGeometrySource(textureCoordinates: texCoordCGPoint)
    let indicesElements = SCNGeometryElement(indices: indices, primitiveType: SCNGeometryPrimitiveType.triangles)

    geoNode.geometry = SCNGeometry(sources: [verticesSources, normalsSources, texCoordsSources], elements: [indicesElements])
    geoNode.position = SCNVector3(x: 0, y: 0, z: 0)
    geoNode.scale = SCNVector3(x: 50, y: 50, z: 50)

    let material = SCNMaterial()

    material.diffuse.contents = UIImage(named: "grad_ao.png")

    geoNode.geometry?.firstMaterial = material

    scene.rootNode.addChildNode(geoNode)

    return scene
}

模型被正确渲染,但应用的纹理完全混乱。我已经尝试了旋转图像,也uv坐标都ok 0..1。

有什么想法吗?谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-07-10 20:41:00

我已经设法fix了一个问题。

密钥在"texture.png“文件中。

我只需要将图像翻转180度:

代码语言:javascript
复制
material.diffuse.contentsTransform = SCNMatrix4Translate(SCNMatrix4MakeScale(1, -1, 1), 0, 1, 0)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44968649

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档