5.2 - Escala
As dimensões do objeto
definido em children são diminuídas ou aumentadas. O campo scale apresenta
três números: o tamanho da escala em cada uma das direções x, y e
z.
Uma escala unitária,
em qualquer direção, implica na não alteração de tamanho naquela direção
e, portanto, uma escala igual a (1 1 1) não implicaria em nenhuma
modificação nas dimensões do objeto.
Um valor 0 (zero) em
qualquer direção não é aconselhável, fazendo com que o browser envie
um aviso solicitando que todos os valores do campo scale sejam maiores
que 0.0.
Exemplo 36: Escalonando por
4.0 na direção
X
#VRML
V2.0 utf8
# The VRML 2.0 Sourcebook
# Copyright (c) 1997
# Andrea L. Ames, David R. Nadeau, and John L. Moreland
Transform {
......scale 4.0 1.0 1.0
......children [
............Shape
{
..................appearance
Appearance {
........................material
Material {
..............................diffuseColor
0 0 1
........................}
..................}
..................geometry
Sphere { }
............}
......]
}
Exemplo 37: Escalonando por
0.5 na direção X
#VRML
V2.0 utf8
# The VRML 2.0 Sourcebook
# Copyright (c) 1997
# Andrea L. Ames, David R. Nadeau, and John L. Moreland
Transform {
......scale 0.5 1.0 1.0
......children [
............Shape
{
..................appearance
Appearance {
........................material
Material {
..............................diffuseColor
0 0 1
........................}
..................}
..................geometry
Sphere { }
............}
......]
}
Exemplo 38: Escalonando por
4.0 na direção
Y
#VRML
V2.0 utf8
# The VRML 2.0 Sourcebook
# Copyright (c) 1997
# Andrea L. Ames, David R. Nadeau, and John L. Moreland
Transform {
......scale 1.0 4.0 1.0
......children [
............Shape
{
..................appearance
Appearance {
........................material
Material {
..............................diffuseColor
0 0 1
........................}
..................}
..................geometry
Sphere { }
............}
......]
}
Exemplo 39: Escalonando por
0.5 na direção Z
#VRML
V2.0 utf8
# The VRML 2.0 Sourcebook
# Copyright (c) 1997
# Andrea L. Ames, David R. Nadeau, and John L. Moreland
Transform {
......scale 1.0 1.0 0.5
......children [
............Shape
{
..................appearance
Appearance {
........................material
Material { }
..................}
..................geometry
Sphere { }
............}
......]
}
Exemplo 40: Escalonando por 2.0 na direção X, 0.5 na direção Y
e por 4.0 na direção Z.
#VRML
V2.0 utf8
# The VRML 2.0 Sourcebook
# Copyright (c) 1997
# Andrea L. Ames, David R. Nadeau, and John L. Moreland
Transform {
......scale 2.0 0.5 4.0
......children [
............Shape
{
..................appearance
Appearance {
........................material
Material { }
..................}
..................geometry
Sphere { }
............}
......]
}
Exemplo 41: Uma simples espaçonave
formada com cilindro e esfera escalonandos.
#VRML
V2.0 utf8
# The VRML 2.0 Sourcebook
# Copyright (c) 1997
# Andrea L. Ames, David R. Nadeau, and John L. Moreland
Group {
......children [
............#
Wing
............Transform
{
..................scale
0.5 1.0 1.5
..................children
Shape {
........................appearance
DEF White Appearance {
..............................material
Material { diffuseColor 0 1 0 }
........................}
........................geometry
Cylinder {
..............................radius
1.0
..............................height
0.025
........................}
..................}
............},
............#
Fuselage
............Transform
{
..................scale
2.0 0.2 0.5
..................children
Shape {
........................appearance
USE White
........................geometry
Sphere { }
..................}
............}
......]
}
Exemplo 42: Uma simples espaçonave
formada com cilindro e esfera escalonandos.
#VRML
V2.0 utf8
# The VRML 2.0 Sourcebook
# Copyright (c) 1997
# Andrea L. Ames, David R. Nadeau, and John L. Moreland
Group {
......children [
............# Wing
............DEF Wing Transform {
..................scale 0.5 1.0 1.5
..................children Shape {
........................appearance DEF
White Appearance {
..............................material
Material { }
........................}
........................geometry Cylinder
{
..............................radius
1.0
..............................height
0.025
........................}
..................}
............},
............# Fuselage
............DEF Fusalage Transform {
..................scale 2.0 0.2 0.5
..................children Shape {
........................appearance USE
White
........................geometry Sphere
{ }
..................}
............},
............# Wing detail and fusalage
dome
............Transform {
..................scale 0.3 2.0 0.75
..................children [
........................USE Wing,
........................USE Fusalage
..................]
............}
......]
}
Exemplo 43: Uma arcada maior com arcadas menores escalonandas.
#VRML
V2.0 utf8
# The VRML 2.0 Sourcebook
# Copyright (c) 1997
# Andrea L. Ames, David R. Nadeau, and John L. Moreland
Transform {
translation 0 -5 -10
......children [
............Group
{
..................children
[
........................#
Ground
........................Shape
{
..............................appearance
DEF White Appearance {
....................................material
Material {
................................................diffuseColor
.21 .21 0
................................................specularColor
.93 .58 0
................................................emissiveColor
.07 .05 0
................................................ambientIntensity
.00667
................................................shininess
.06
....................................}
..............................}
..............................geometry
Box {
....................................size
25.0 0.1 25.0
..............................}
........................},
........................#
First archway
........................DEF
Archway Group {
..............................children
[
....................................#
Left Column
....................................DEF
LeftColumn Transform {
..........................................translation
-2.0 3.0 0.0
..........................................children
DEF Column Shape {
................................................appearance
USE White
................................................geometry
Cylinder {
......................................................radius
0.3
......................................................height
6.0
................................................}
..........................................}
....................................},
....................................#
Right Column
....................................DEF
RightColumn Transform {
..........................................translation
2.0 3.0 0.0
..........................................children
USE Column
....................................},
....................................#
Archway span
....................................DEF
ArchwaySpan Transform {
..........................................translation
0.0 6.05 0.0
..........................................children
Shape {
................................................appearance
USE White
................................................geometry
Box {
......................................................size
4.6 0.4 0.6
................................................}
..........................................}
....................................},
....................................#
Left Roof
....................................DEF
LeftRoof Transform {
..........................................translation
-1.15 7.12 0.0
..........................................rotation
0.0 0.0 1.0 0.524
..........................................children
DEF Roof Shape {
................................................appearance
USE White
................................................geometry
Box {
......................................................size
2.86 0.4 0.6
................................................}
..........................................}
....................................},
....................................#
Right Roof
....................................DEF
RightRoof Transform {
..........................................translation
1.15 7.12 0.0
..........................................rotation
0.0 0.0 1.0 -0.524
..........................................children
USE Roof
....................................}
..............................]
........................},
........................#
Left small archway
........................Transform
{
..............................translation
-4.0 0.0 0.0
..............................scale
0.5 0.5 0.5
..............................children
USE Archway
........................},
........................#
Right small archway
........................Transform
{
..............................translation
4.0 0.0 0.0
..............................scale
0.5 0.5 0.5
..............................children
USE Archway
........................}
..................]
............}
......]
}
Exemplo 44: Uma árvore
no seu tamanho original.
#VRML
V2.0 utf8
# The VRML 2.0 Sourcebook
# Copyright (c) 1997
# Andrea L. Ames, David R. Nadeau, and John L. Moreland
Group {
......children [
............# Ground
............Shape {
..................appearance DEF White
Appearance {
........................material Material
{ }
..................}
..................geometry Box {
........................size 12.0 0.1
12.0
..................}
............},
............# Tree
............Transform {
..................translation 0.0 1.0
0.0
..................scale 1.0 1.0 1.0
..................center 0.0 -1.0 0.0
..................children [
........................# Trunk
........................Shape {
..............................appearance
USE White
..............................geometry
Cylinder {
....................................radius
0.5
....................................height
2.0
..............................}
........................},
........................# Branches
........................Transform {
..............................translation
0.0 3.0 0.0
..............................children
Shape {
....................................appearance
USE White
....................................geometry
Cone {
..........................................bottomRadius
2.0
..........................................height
4.0
....................................}
..............................}
........................}
..................]
............}
......]
}
Exemplo 45: A árvore
anterior escalonanda na direção Y.
#VRML
V2.0 utf8
# The VRML 2.0 Sourcebook
# Copyright (c) 1997
# Andrea L. Ames, David R. Nadeau, and John L. Moreland
Group {
......children [
............# Ground
............Shape {
..................appearance DEF White
Appearance {
........................material Material
{ }
..................}
..................geometry Box {
........................size 12.0 0.1
12.0
..................}
............},
............# Tree
............Transform {
..................translation 0.0 1.0
0.0
..................scale 1.0 2.0 1.0
..................center 0.0 -1.0 0.0
..................children [
........................# Trunk
........................Shape {
..............................appearance
USE White
..............................geometry
Cylinder {
....................................radius
0.5
....................................height
2.0
..............................}
........................},
........................# Branches
........................Transform {
..............................translation
0.0 3.0 0.0
..............................children
Shape {
....................................appearance
USE White
....................................geometry
Cone {
..........................................bottomRadius
2.0
..........................................height
4.0
....................................}
..............................}
........................}
..................]
............}
......]
}
Exemplo 46: A árvore
anterior escalonanda numa direção qualquer.
#VRML
V2.0 utf8
# The VRML 2.0 Sourcebook
# Copyright (c) 1997
# Andrea L. Ames, David R. Nadeau, and John L. Moreland
Group {
......children [
............# Ground
............Shape {
..................appearance DEF White
Appearance {
........................material Material
{ }
..................}
..................geometry Box {
........................size 12.0 0.1
12.0
..................}
............},
............# Tree
............Transform {
..................translation 0.0 1.0
0.0
..................scale 1.0 2.0 1.0
..................scaleOrientation
0.0 0.0 1.0 -0.785
..................center 0.0 -1.0 0.0
..................children [
........................# Trunk
........................Shape {
..............................appearance
USE White
..............................geometry
Cylinder {
....................................radius
0.5
....................................height
2.0
..............................}
........................},
........................# Branches
........................Transform {
..............................translation
0.0 3.0 0.0
..............................children
Shape {
....................................appearance
USE White
....................................geometry
Cone {
..........................................bottomRadius
2.0
..........................................height
4.0
....................................}
..............................}
........................}
..................]
............}
......]
}
Exemplo 47: Cubos Escalonados
#VRML V2.0 utf8
# ------------------------------------------------
# Desenho de dois cubo com transformações geométricas
em escala
# ------------------------------------------------
Transform {
......scale 1.0 1.0 1.0
......children [
............# As transformações pode ter
um ou mais
............# "filhos"
............Shape {
..................# Estes "filhos" são Shapes
ou outras
..................# transformações
..................appearance Appearance {
........................material Material {
..............................diffuseColor 1.0 0.0 0.0
..............................transparency 0.0
........................}
..................}
..................geometry Box {
........................size 3 3 3
..................}
............}
......]
}
Transform {
......scale 0.5 2.0 0.5
......children [
............# As transformações pode ter
um ou mais
............# "filhos"
............Shape {
..................# Estes "filhos" são Shapes
ou outras
..................# transformações
..................appearance Appearance {
........................material Material {
..............................diffuseColor 0.0 1.0 0.0
..............................transparency 0.0
........................}
..................}
..................geometry Box {
........................size 3 3 3
..................}
............}
......]
}