PROTO 메커니즘을 사용하여 원하는 것을 얻을 수 있습니다.
PROTO SmallSphere [
exposedField SFVec3f SmallSphere_translation 0 0 0
]
{
Transform {
translation IS SmallSphere_translation
children [
Shape {
appearance Appearance { material Material {} }
geometry Sphere { radius 1 }
}
]
}
위의 코드는 기본적으로 번역이 가변적 인 Transform에서 PROTO (Object Oriented Programming의 클래스와 비슷한 것)를 만듭니다. 그런 다음 다음과 같이 인스턴스를 만들 수 있습니다
SmallSphere { SmallSphere_translation 96.0 85.0 76.0 }
SmallSphere { SmallSphere_translation 3.0 8.0 6.0 }
SmallSphere { SmallSphere_translation 936.0 385.0 746.0 }
... 번역이 다른 하나 개의 인스턴스에서 변경 매개 변수이고, 당신이 원하는만큼. 인스턴스로 변경할 다른 필드가 필요하면 위의 예를 따라야합니다. 당신의 예를 들어 구체의 반경은 다음과 같이 PROTO를 만들어야 할 것이다 변수가되고 싶어요 :
PROTO SmallSphere [
exposedField SFVec3f SmallSphere_translation 0 0 0
exposedField SFFloat SmallSphere_radius 2.0
]
{
Transform {
translation IS SmallSphere_translation
children [
Shape {
appearance Appearance { material Material {} }
geometry Sphere { radius IS SmallSpehere_radius }
}
]
}
그 SmallSphere_translation 및 SmallSphere_radius 날에 의해 선택 이름입니다 유의하시기 바랍니다. 이 필드의 이름은 원하는대로 지정할 수 있습니다.
출처
2017-09-11 22:17:54
CpS