2

I face one problem on implementing ARKit/SceneKit. I want to add a texture only to some part of 3D model (for example a 3d model of a car, where I wanna change texture of wheels and a mirror).

let dragonScene = SCNScene(named: "art.scnassets/Dragon_Baked_Actions_fbx_6.dae")!
let position = anchor.transform

for childNode in dragonScene.rootNode.childNodes {
    self.dragonNode.addChildNode(childNode)
}

let scale:Float = 0.01
self.dragonNode.scale = SCNVector3(x: scale, y: scale, z: scale)
self.dragonNode.position = SCNVector3(x: position.columns.3.x, y: position.columns.3.y, z: position.columns.3.z)

self.sceneView.scene.rootNode.addChildNode(self.dragonNode)

let material = SCNMaterial()
material.diffuse.contents = UIImage(named: "Fire_A_2.png")
material.isDoubleSided = true
material.diffuse.wrapT = SCNWrapMode.repeat
material.diffuse.wrapS = SCNWrapMode.repeat
material.isDoubleSided = true
self.dragonNode.childNodes.first?.geometry!.replaceMaterial(at: 0, with: material)
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
  • Could you include a reproducible code example of what you are trying to accomplish? This will help us track down your issue better. – CEH Sep 30 '19 at 14:58

1 Answers1

0

If each part of your model is a separate 3D object, you can easily change a texture for it in Xcode. But if you have a mono-model (so called one-piece model), you can change a texture of a definite part of it only via UV-mapping (you can do it in 3dsMax, Maya, Cinema4D, Blender, etc).

Here are how UV-mapped textures look like:

enter image description here

enter image description here

Consider, Xcode's Scene graph editor isn't suitable for UV-mapping at all. In Xcode you can only apply pre-made UV-mapped textures.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220