Beruflich Dokumente
Kultur Dokumente
Shape {
#Campo appearance:
appearance Appearance {
material Material { }
}
#Campo geometry:
geometry Box {
size 2 0.5 3
}
}
Ejemplo
#VRML V2.0 utf8
# Cono con la apariencia por defecto
Shape {
#Campo appearance:
appearance Appearance {
material Material { }
}
#Campo geometry:
geometry Cone {
height 3
bottomRadius 0.75
}
}
REPRESENTACIÓN :CUBO
Shape {
Shape {
Shape {
Geometry Cone {
bottomRadius 3
height 2
}
}
REPRESENTACIÓN :CILINDRO
# VRLM V2.0 utf8
Shape {
Geometry Cylinder
{radius 4
Height 5
}
}
MATERIALES
Shape {
Rotación
escalado
TRASLACIONES
Shape {
Transform {
translation 10 0 0
children [
Shape {
#esfera verde trasladada 10
# unidades en el eje X
geometry Sphere {radius 2 }
appearance Appearance {material Material
{diffuseColor 0 1 0 }}
}
]
}
Ejemplo2:
Ahora queremos añadir un cono azul
sobre nuestra esfera verde. Para hacer
esto debemos trasladar el cono 10
unidades en el eje de las X al igual que
la esfera verde, pero además, debemos
trasladarlo 3 unidades en el eje de las Y
(en concordancia con las medidas de la
esfera y el cono).
Ejemplo
Shape { # Esfera roja que nos marca el origen de coordenadas
geometry Sphere { radius 2 }
appearance Appearance { material Material { diffuseColor 1 0 0 } }
}
Transform {
translation 10 0 0
children [
Shape { # Esfera verde trasladada 10 unidades en el eje X
geometry Sphere { radius 2 }
appearance Appearance { material Material { diffuseColor 0 1 0 } }
}
]
}
Transform {
translation 10 3 0
children [
Shape { # Cono azul trasladado 10 unidades en el eje X y 3 en el eje Y
geometry Cone { bottomRadius 2 height 2 }
appearance Appearance { material Material { diffuseColor 0 0 1 } }
}
]
}
ROTACIONES
rotation 1 0 0 1.57
Aquí vemos cuatro valores, los tres primeros se corresponden a
las tres coordenadas y pueden tener el valor 0 ó 1 y representan
la rotación alrededor de cada eje en el orden x, y, z.
Es decir:
Rotación sobre el eje X = 1 0 0
Rotación sobre el eje Y = 0 1 0
Rotación sobre el eje Z = 0 0 1
La cuarta cifra representa el ángulo girado, pero expresado en
radianes. Para calcular la correspondencia entre grados y
radianes, hay que tener en cuenta que 180º equivalen a 3.14
radianes. Por tanto, 90º sería la mitad de 3.14 o sea 1.57
radianes. Para facilitarles las cosas hacer el cálculo en forma
automática
ROTACIONES
Transform {
rotation 0 1 0 0.7854 # 45 grados en radianes
children [
Shape { # Caja azul que es rotada 45 grados respecto al eje Y
geometry Box { size 2 4 2 }
appearance Appearance { material Material
{ diffuseColor 0 0 1 } }
}
]
}
Ejemplo4:
Ahora queremos que la caja azul también
rote 45 grados respecto al eje X.
Ejemplo
Shape { # Caja amarilla que nos marca la rotación cero
geometry Box { size 4 2 4 }
appearance Appearance { material Material { diffuseColor 1 1 0 } }
}
Transform {
rotation 1 0 0 0.7854 # Rotación eje X
children [
Transform {
rotation 0 1 0 0.7854 # Rotación eje Y
children [
Shape { # Caja azul
geometry Box { size 2 4 2 }
appearance Appearance { material Material
{ diffuseColor 0 0 1 } }
}
]
}
]
}
ESCALADOS
CLASES
Uniformes : engrandecen o reducen un
objeto en todas las direcciones por igual.
No uniformes: lo hacen en una sola
dirección
Ejemplo
#VRML V2.0 utf8
Transform {
translation 540
rotation 1 0 0 0.5236 #30 grados
scale 0.5 0.5 1
children [
Shape { # cubo verde oscuro
geometry Box { size 1 1 1}
appearance Appearance {material Material {
diffuseColor 0 0.5 0.2 }}
}
]
}
EJERCICIOS