SceneKit의 머티리얼 diffuse를 변경하여 3D 물체의 외형을 변경
머티리얼이란?

htps : //에서 ゔぇぺぺr. 아 ぇ. 코 m / 도쿠 멘 타치 온 / s 세네 키 t / sc
Apple의 SCNMaterial에 대한 설명을 인용하면 기하학 표면의 외형을 결정하는 농담의 특징 세트로 번역합니다.
어떻게 설정하는지

scn 파일을 열고 sphere라는 지오메트리를 둔 모습이 위입니다.
오른쪽 공 아이콘으로 편집할 수 있습니다.
붉게 해보자

위와 같이 diffuse로 색을 변경하면 material의 색이 바뀝니다.
머티리얼은 하나뿐이 아니다

앞의 예에서는 위에서 설명한 것처럼 untitiledMaterial이 빨간색이었습니다. 스피어의 경우는 표면이 1개 밖에 없기 때문에,material가 1개 밖에 없었습니다. 그러나 원통의 경우는 어떨까요?

위와 같이 하나만 머티리얼을 추가하지 않으면 전체가 빨간색이지만,

원통은 표면이 위의 면, 아래의 면, 측면과 3개이므로 3개까지 머티리얼을 추가하여 면에 따라 색을 바꿀 수 있습니다. material은 각각 identity에 이름을 넣고 이름을 붙일 수 있습니다.

SCNText의 지오메트리에 대해 실시하면 위와 같이 IKEA도 재현할 수 있다. . ! w
이미지 할당하기
diffuse에는 이미지 파일도 할당할 수 있습니다.


이런 식으로, 이미지 머티리얼로 모양이 자유자재입니다.
사실 그 비행기도
ARKit의 템플릿을 만들면 나오는 이 비행기에도 실은 material이 있습니다.

겨우 재료를 삭제해 보면

새하얗게 되어 버렸습니다.
실은 비행기의 모양, 이하와 같은 화상의 머티리얼이 붙어 있을 뿐입니다. 3D의 모델을 전개해 2D의 면으로 했을 때의 전개도 같은 이미지입니까.

코드도 가능합니다.
let sphere = SCNSphere(radius: 0.1)
sphere.firstMaterial?.diffuse.contents = UIColor.red
let node = SCNNode()
node.geometry = sphere
여러 머티리얼을 붙이고 싶을 때는 다음과 같이
let m1 = SCNMaterial()
m1.diffuse.contents = UIColor.red // 赤
let m2 = SCNMaterial()
m2.diffuse.contents = UIColor.blue // 青
sphere.materials = [m1, m2]
요약

scn 파일을 열고 sphere라는 지오메트리를 둔 모습이 위입니다.
오른쪽 공 아이콘으로 편집할 수 있습니다.
붉게 해보자

위와 같이 diffuse로 색을 변경하면 material의 색이 바뀝니다.
머티리얼은 하나뿐이 아니다

앞의 예에서는 위에서 설명한 것처럼 untitiledMaterial이 빨간색이었습니다. 스피어의 경우는 표면이 1개 밖에 없기 때문에,material가 1개 밖에 없었습니다. 그러나 원통의 경우는 어떨까요?

위와 같이 하나만 머티리얼을 추가하지 않으면 전체가 빨간색이지만,

원통은 표면이 위의 면, 아래의 면, 측면과 3개이므로 3개까지 머티리얼을 추가하여 면에 따라 색을 바꿀 수 있습니다. material은 각각 identity에 이름을 넣고 이름을 붙일 수 있습니다.

SCNText의 지오메트리에 대해 실시하면 위와 같이 IKEA도 재현할 수 있다. . ! w
이미지 할당하기
diffuse에는 이미지 파일도 할당할 수 있습니다.


이런 식으로, 이미지 머티리얼로 모양이 자유자재입니다.
사실 그 비행기도
ARKit의 템플릿을 만들면 나오는 이 비행기에도 실은 material이 있습니다.

겨우 재료를 삭제해 보면

새하얗게 되어 버렸습니다.
실은 비행기의 모양, 이하와 같은 화상의 머티리얼이 붙어 있을 뿐입니다. 3D의 모델을 전개해 2D의 면으로 했을 때의 전개도 같은 이미지입니까.

코드도 가능합니다.
let sphere = SCNSphere(radius: 0.1)
sphere.firstMaterial?.diffuse.contents = UIColor.red
let node = SCNNode()
node.geometry = sphere
여러 머티리얼을 붙이고 싶을 때는 다음과 같이
let m1 = SCNMaterial()
m1.diffuse.contents = UIColor.red // 赤
let m2 = SCNMaterial()
m2.diffuse.contents = UIColor.blue // 青
sphere.materials = [m1, m2]
요약
let sphere = SCNSphere(radius: 0.1)
sphere.firstMaterial?.diffuse.contents = UIColor.red
let node = SCNNode()
node.geometry = sphere
let m1 = SCNMaterial()
m1.diffuse.contents = UIColor.red // 赤
let m2 = SCNMaterial()
m2.diffuse.contents = UIColor.blue // 青
sphere.materials = [m1, m2]
Reference
이 문제에 관하여(SceneKit의 머티리얼 diffuse를 변경하여 3D 물체의 외형을 변경), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/kboy/items/0ebc5b92e57807fa8b1e텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)