2017-07-07 17 views
0

私はと最新のVuforiaライブラリ6-2-9で作業しています。SceneKitの新機能です。SceneKit Vuforia ARライブラリのカスタムモデル

texturesをカスタム3Dモデルに適用する際に問題があります。

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]です。

アイデア?あなたは

Textures are messed up

答えて

0

私はfix問題に管理しているありがとうございます。

キーは「texture.png」ファイルにあります。

私はちょうど180度のために画像を反転する必要があります。

material.diffuse.contentsTransform = SCNMatrix4Translate(SCNMatrix4MakeScale(1, -1, 1), 0, 1, 0) 
関連する問題