Reputation: 89
What I am trying to do is add shininess to a .dae
model in SceneKit.
How can I add shininess to this model?
Upvotes: 1
Views: 115
Reputation: 58563
At first select your .dae
model and choose Editor – Convert to SceneKit File Format (.scn) in main menu.
After that get through the hierarchy with .childNodes[0]
to retrieve the model. Then apply a .blinn
shader and setup specular.intensity
and shininess
parameters.
import SceneKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let sceneView = self.view as! SCNView
sceneView.scene = SCNScene(named: "art.scnassets/ship.scn")!
sceneView.allowsCameraControl = true
sceneView.backgroundColor = .black
sceneView.scene?.lightingEnvironment.contents = .none
sceneView.scene?.background.contents = .none
let sun = SCNNode()
sun.light = SCNLight()
sun.light?.type = .directional
sun.light?.intensity = 500
sun.eulerAngles.x = -.pi/2
sceneView.scene?.rootNode.addChildNode(sun)
let s = sceneView.scene!.rootNode.childNode(withName: "ship",
recursively: true)!
s.childNodes[0].geometry?.firstMaterial?.lightingModel = .blinn
s.childNodes[0].geometry?.firstMaterial?.shininess = 100
s.childNodes[0].geometry?.firstMaterial?.specular.intensity = 100
}
}
Upvotes: 1