Estas
herramientas sirven en caso de que quieras utilizar figuras similares o iguales
repetidas iguales, esto para evitarnos el estar haciendo una por una y tener un
código ENORME.
Se
utilizan de una manera muy sencilla. Primero se hace la figura que queramos
utilizar (ésta se incluirá en el mundo virtual), y se agrupa con Group como ya
vimos anteriormente.
Ejemplo
de cuatro cajas agrupadas (utilizar el botón de examinar para poder ver bien el
sillón):
#VRML V2.0 utf8
Group{
children[
#Respaldo
Transform{
translation 0 0 0
rotation
0.0 0.0 0.0 0.0
children [
Shape{
appearance Appearance {
texture
ImageTexture{url ["Asiento.jpg"]}
}
geometry Box{
size 2 3
0.5
}
}
]
}
#Asiento
Transform{
translation 0 -1.75 -0.75
rotation 0.0 0.0 0.0 0.0
children [
Shape{
appearance Appearance {
texture
ImageTexture{url ["Asiento.jpg"]}
}
geometry Box{
size 2 0.5 2
}
}
]
}
#Recargadera
izquierda
Transform{
translation -0.75 -1.25 -1
rotation
0.0 0.0 0.0 0.0
children [
Shape{
appearance Appearance {
texture
ImageTexture{url ["Asiento.jpg"]}
}
geometry Box{
size 0.5 0.5 1.5
}
}
]
}
#Recargadera
derecha
Transform{
translation 0.75 -1.25 -1
rotation 0.0 0.0 0.0 0.0
children [
Shape{
appearance Appearance {
texture
ImageTexture{url ["Asiento.jpg"]}
}
geometry
Box{
size 0.5 0.5 1.5
}
}
]
}
]
}
Vamos a
empezar, lo que debemos hacer después de este paso es lo siguiente:
♥ Antes
de Group se escribe DEF N,
sustituyendo “N” por el nombre de la agrupación que se desea utilizar.
Ya
que hicimos este sencillo paso si se desea podemos poner un Transform antes de
DEF.
Ejemplo
desarrollado:
#VRML
V2.0 utf8
Transform{
translation -23 -8 0
rotation 0 0 0 0
children [
DEF
asientocompleto Group{
children[
#Respaldo
Transform{
translation 0 0 0
rotation 0.0 0.0 0.0 0.0
children [
Shape{
appearance
Appearance {
texture ImageTexture{url
["Asiento.jpg"]}
}
geometry
Box{
size 2 3 0.5
}
}
]
}
#Asiento
Transform{
translation 0 -1.75 -0.75
rotation 0.0 0.0 0.0 0.0
children [
Shape{
appearance
Appearance {
texture ImageTexture{url
["Asiento.jpg"]}
}
geometry
Box{
size
2 0.5 2
}
}
]
}
#Recargadera
izquierda
Transform{
translation -0.75 -1.25 -1
rotation
0.0 0.0 0.0 0.0
children [
Shape{
appearance
Appearance {
texture ImageTexture{url
["Asiento.jpg"]}
}
geometry
Box{
size
0.5 0.5 1.5
}
}
]
}
#Recargadera
derecha
Transform{
translation 0.75 -1.25 -1
rotation
0.0 0.0 0.0 0.0
children [
Shape{
appearance
Appearance {
texture ImageTexture{url
["Asiento.jpg"]}
}
geometry
Box{
size
0.5 0.5 1.5
}
}
]
}
]
}
]
}
Ahora
lo que sigue es el ¿Cómo se va a volver a utilizar? Pues muy sencillo.
♥
Se
escribe USE N, sustituyendo la N por
el nombre de la agrupación, debe de ser el mismo que pusiste antes de Group.
USE asientocompleto
♥
Si
se desea pudes utilizar un Transform antes de USE.
Transform {
translation
4.3 0 0
rotation
0 0 0 0
children
[
USE asientocompleto
]
}
Ejemplo
(Utilizar el botón examinar para ver mejor el ejemplo):
#VRML V2.0 utf8
DEF asientocompleto Group{
children[
#Respaldo
Transform{
translation 0 0 0
rotation 0.0 0.0 0.0
0.0
children [
Shape{
appearance Appearance {
texture ImageTexture{url
["Asiento.jpg"]}
}
geometry Box{
size 2 3 0.5
}
}
]
}
#Asiento
Transform{
translation 0 -1.75
-0.75
rotation 0.0 0.0 0.0
0.0
children [
Shape{
appearance Appearance {
texture ImageTexture{url
["Asiento.jpg"]}
}
geometry Box{
size 2 0.5 2
}
}
]
}
#Recargadera izquierda
Transform{
translation -0.75 -1.25 -1
rotation
0.0 0.0 0.0 0.0
children [
Shape{
appearance Appearance {
texture ImageTexture{url
["Asiento.jpg"]}
}
geometry Box{
size 0.5 0.5 1.5
}
}
]
}
#Recargadera derecha
Transform{
translation 0.75 -1.25 -1
rotation
0.0 0.0 0.0 0.0
children [
Shape{
appearance Appearance {
texture ImageTexture{url
["Asiento.jpg"]}
}
geometry Box{
size 0.5 0.5 1.5
}
}
]
}
]
}
Transform {
translation 4.3 0 0
rotation 0 0 0 0
children [
USE asientocompleto
]
}
Transform {
translation 6.5 0 0
rotation 0 0 0 0
children [
USE asientocompleto
]
}
Transform {
translation 8.7 0 0
rotation 0 0 0 0
children [
USE asientocompleto
]
}



No hay comentarios:
Publicar un comentario