VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( [email protected] ) 09 de...
Transcript of VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( [email protected] ) 09 de...
![Page 1: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/1.jpg)
VRMLVirtual Reality Modeling Language
INTRODUÇÃO AO VRMLMárcio Bueno ([email protected])09 de maio de 2005
Atualizada por Paulo Gonçalves de BarrosBaseada na apresentação de:Dênio Mariz ([email protected]) Judith Kelner ([email protected]) Alejandro Frery ([email protected]) Cin/UFPE, novembro 2000
![Page 2: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/2.jpg)
Roteiro
1. O que é VRML2. Histórico3. Objetivos da VRML4. VRML, Internet e WWW5. Visão geral do VRML6. Estrutura do Arquivo VRML 7. Conceitos-chave8. Semântica dos Nós 9. Primitivas Básicas10.Primitivas Avançadas
![Page 3: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/3.jpg)
O Que é VRML
Virtual Reality Modeling Language Suporte para RV não-imersiva VRML não suporta imersão
• Capacetes 3D, luvas digitais Não é exatamente "Modeling Language"
Verdadeira linguagem de modelagem 3D deve prover primitivas de modelagem geométricas e mecanismos muito mais ricos
O que é então ? Um formato de intercâmbio para 3D Publicação de páginas Web em 3D (~HTML 3D)
• Jogos, engenharia, visualização científica, experiências educacionais, arquitetura
Um modelo coerente para integração de 3D, 2D, texto e multimídia
![Page 4: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/4.jpg)
Objetivos da VRML
Modelagem de objetos 3D Composição de "mundos" pela hierarquia de objetos Animação, interação, multimídia formato intercambiável (várias aplicações podem ler/gravar)
Internet e WWW VRML foi projetado para ser usado com a infraestrutura
Internet/WWW existente Simplicidade
Suporte VRML deve ser facilmente adicionado às aplicações• Vários browsers (navegadores) podem e devem dar suporte
Facilidade de Composição Facilidade em se "montar o todo a partir das peças" Produtividade e trabalho em grupo
![Page 5: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/5.jpg)
Objetivos da VRMLCont.
Escalabilidade O navegador VRML deve operar com "mundos" distribuídos na
Internet Independente da potência da máquina Mundos ajustados à performance da rede (14.4K ~ OC12) Especificação permite adições futuras
Otimização da performance Algoritmos de manipulação 3D têm efeito nas ramificações
agrupadas Se algo não puder ter performance, então não fará parte da
especificação Versões futuras
Interação entre vários usuários Criaturas autônomas que podem sentir e reagir no ambiente
![Page 6: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/6.jpg)
VRML, Internet e WWW
Navegadores suportam VRML através de plug-ins Arquivos VRML podem referenciar vários outros formatos
JPEG, PNG, GIF, MPEG podem ser usados para compor a textura de objetos
WAV, MIDI podem ser usados para sons emitidos pelo ambiente ou por objetos
Arquivos com código Java ou JavaScript podem ser referenciados para implementar comportamento de objetos
VRML permite hiperlinks Organizações que definem esses padrões
Exemplo: World Wide Web Consortium (W3C) padronizou um "tag" HTML (<OBJECT>) que permite embutir VRML, Java, ou outros tipos de arquivos em documentos HTML.
![Page 7: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/7.jpg)
Visão Geral do VRML
Estrutura Gráfica da Cena VRML descreve "mundos" (worlds) usando uma cena gráfica
hierárquica Entidades na cena são chamados "nós" (nodes). VRML 2.0 define 54 tipos de nós:
• Primitivas geométricas• Propriedades de aparência, som• Agrupamento de nós
Nós armazenam seus dados (atributos) em "campos" (fields). VRML 2.0 define 20 tipos de campos (números, arrays) Nós podem conter outros nós.
• Alguns nós podem ter "filhos" (children) • Alguns nós podem ter mais de um "pai“• Um nó não pode conter a si mesmo (recursividade).• Criação de "mundos" complexos ou objetos a partir de subpartes
![Page 8: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/8.jpg)
Visão Geral do VRML cont.
Arquitetura de Eventos Mecanismo de geração de eventos permite que os nós da cena
se comuniquem entre si. Cada tipo de nó define os nomes e tipos de eventos que podem
ser gerados ou recebidos Sensores
Sensores são as primitivas básicas de animação e interação com o usuário.
• O nó "TimeSensor" gera eventos com o passar do tempo e é a base para todos os comportamentos animados.
• Outros sensores geram eventos quando o usuário se movimenta através da cena ou quando interage através de algum dispositivo de entrada.
Sensores geram apenas eventos. Eles devem ser combinados com outros nós para ter qualquer efeito visual na cena.
![Page 9: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/9.jpg)
Visão Geral do VRML cont.
Scripts e Interpoladores Scripts permitem ao autor da cena definir comportamentos
arbitrários, usando qualquer linguagem suportada. VRML 2.0 define conexões para linguagens Java e JavaScript Nós "Script" podem ser inseridos entre geradores de eventos
(sensores) e recebedores. Interpoladores são scripts embutidos que executam animações.
Eles podem ser combinados com "TimeSensor" e algum nó da cena para fazer objetos se moverem.
Encapsulamento e Reuso Geometria, propriedades, animações ou comportamento podem
ser encapsulados separadamente ou junto da cena. Permite a definição de um novo tipo de nó a partir da
combinação de tipos existentes de nós• Biblioteca de objetos 3D• Facilidade de uso, trabalho em equipe• Reduz tamanho de arquivos
![Page 10: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/10.jpg)
Visão Geral do VRML cont.
Cenas Distribuídas VRML 2.0 inclui duas primitivas que permitem que a
definição de uma cena possa ser distribuída independentemente.
O nó "Inline" permite a inclusão de outra cena armazenada em outro arquivo – em qualquer lugar da Web.
O comando "EXTERNPROTO" permite que definições de novos nós possam ser acessados de qualquer lugar da Web. É o mecanismo básico que estende o VRML.
![Page 11: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/11.jpg)
Visão Geral do VRML cont.
Modelo Conceitual de um Browser VRML
![Page 12: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/12.jpg)
Estrutura do Arquivo VRML
Arquivos VRML têm extensão .wrl (world) Cabeçalho (obrigatório) Cena
Definição dos objetos gráficos Contém os nós (nodes) que descrevem objetos e suas
propriedades Objetos podem ter geometria hierarquicamente agrupada
para prover representações áudio -visuais complexas. Protótipos
Extensões de nós VRML definidos externamente pelo usuário
Eventos Definições dos eventos associados aos objetos
![Page 13: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/13.jpg)
Estrutura do Arquivo VRML
Cabeçalho Primeira linha do arquivo Identifica o arquivo como VRML e informa o tipo de
codificação usada• #VRML V2.0 <encoding type> [comment] <line terminator>
Apenas um caractere de espaço entre os componentes do cabeçalho
<encoding type> é "utf8" • Existem outras codificações autorizadas pelo VRML 2.0• "utf8" indica texto livre (padrão UTF-8 da ISO 10646-1,
RFC2044)• Também conhecido como Unicode ;-)
#VRML V2.0 utf8 Gerado por Maria da Silva
![Page 14: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/14.jpg)
Estrutura do Arquivo VRML
# inicia um comentário Apenas o 1º comentário tem significado (cabeçalho)
Caracteres NÃO permitidos para nomes Primeira letra: + - 0-9 " ' # , . [ ] \ {} 0x0-0x20 Restante: " ' # , . [ ] \ {} 0x0-0x20
Palavras reservadas DEF, EXTERNPROTO, FALSE, IS, NULL, PROTO, ROUTE TO, TRUE, USE, eventIn, eventOut, exposedField, field
VRML é sensível a maiúsculas e minúsculas "Sphere" é diferente de "sphere" "BEGIN" é diferente de "begin"
![Page 15: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/15.jpg)
Conceitos-chave: Unidades de Medida Unidades de medida
Radianos foi escolhido por compatibilidade com o padrão da linguagem C (math library routines)
Conversão graus radianos: Radianos = .graus / 180 Tempo é expresso como um double-precision floating point
(precisão nano-segundos)
Categoria Unidade
Distância linear Metros
Ângulos Radianos
Tempo Segundos
Cores RGB ([0., 1.], [0., 1.], [0., 1.])
![Page 16: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/16.jpg)
Conceitos-chave: Nó
Sintaxe da declaração do Nó [DEF <name>] <nodeType> { <body> } Nome opcional Tipo do nó Corpo do nó O [DEF <name>] permite usar o nó depois
referenciando o nome com o comando USE (ex.: USE <name>)
Não precisa de espaço separando { } e [ ] Exemplo:
Box { size 2 2 2 }
![Page 17: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/17.jpg)
Conceitos-chave: Campo
Sintaxe da declaração de um campo: <fieldName> <fieldValue> <fieldName> [ <fieldValues> ]
Exemplos: radius 0.1 height 20 colorIndex [0 1 2 3 4 5 6 7 ] coordIndex [ 0 1 2 3 -1, 8 9 10 11 -1, 0 1 11 8 5 4 -1 ]
![Page 18: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/18.jpg)
Conceitos-chave: Campo cont. Tipos de Campo
SFBool TRUE/FALSE SFColor 3 valores float entre 0 e 1 (RGB). Ex.: 0 0.7 0.2 MFColor lista de valores SFColor. Ex.: [0 0.5 0, 1 0 0] SFFloat 1 valor float. Ex.: 1.7456 MFFloat lista de valores float. Ex.: [1.2, 3.5, 7, 9.5] SFInt32 & MFInt32 inteiro de 32bits & lista SFNode &
MFNode nó & lista de nós SFRotation 4 valores float:
• 3 primeiros: vetor-eixo de rotação• 4º: ângulo de rotação em radianos
MFRotation lista de SFRotation
![Page 19: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/19.jpg)
Conceitos-chave: Campo cont. Tipos de Campo
SFString string de characteres utf-8. Ex.: “Eu” MFString lista de SFStrings. E.x: [“Eu”, “Tu”, “Ele”] SFTime & MFTime: tempo (float) & uma lista de tempos.
Exs.:1947582537.2323, [1000000000.1, 9.8] SFVec2f vetor 2D.
Ex.: 1.4 7.3 MFVec2f lista de vetores 2D.
Ex.: [2.3 3.4, 4.5 5.6] SFVec3f vetor 3D.
Ex.: 1.4 7.3 9.1 MFVec3f lista de vetores 3D.
Ex.: [2.3 3.4 4.5, 5.6 6.7 7.8]
![Page 20: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/20.jpg)
Conceitos-chave: Campo cont. Tipos de Campo
SFImage imagem bidimensional colorida ou em tons de cinza.
• 2 inteiros: largura e altura da imagem• 1 inteiro: número de componentes de cor:
– 1 para tons de cinza– 2 para tons de cinza com transparência– 3 para RGB– 4 para RGB com transparência
• N números hexadecimais (N = largura da imagem x altura da imagem) para a cor dos pixels. Ex.:
– Tons de cinza: 0X00 (cor preta)– RGB com transparência: 0x00FF007F (verde semi-transparente)
![Page 21: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/21.jpg)
Conceitos-chave: Eventos
São notificações de mudança no valor de algum campo
Tipos EventOut eventos que geram informação EventIn aceitam e utilizam informação externa
(EventOut) Campos Exposed possuem EventIn e EventOut
próprios
![Page 22: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/22.jpg)
Conceitos-chave: Rotas
Efetuam a transmissão de informação entre eventos Ex.: tocar um som quando o mouse for clicado
• Definir nomes únicos para os objetos cujos eventos serão ligados
DEF SENSOR TouchSensor { } DEF SOUND Sound { }
• Conectar campos através do comando RouteROUTE SENSOR.touchTime TO SOUND.startTime
Se houver objetos com mesmo nome, todos serão afetados!
Sensor
EventOut TouchTime
Sound
EventIn StartTimeRoute
![Page 23: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/23.jpg)
Conceitos-chave: Sistema de Coordenadas Sistema de Coordenadas
VRML usa sistema Cartesiano 3D
+X para a direita, -X para a esquerda
+Y para cima, -Y para baixo
+Z para perto, -Z para longe
Z
X
Y
![Page 24: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/24.jpg)
Conceitos-chave: Cores
Sistema RGB Cada cor básica é
representada por número decimal de 0 até 1
A cor é montada combinando as 3 cores básicas
Para montar a cor desejada, mapeie as cores básicas [0, 255] --> [0,1]
![Page 25: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/25.jpg)
Primitivas VRML
Primitivas Básicas Primitivas Avançadas
Atenção:
Nas páginas a seguir, a especificação dos nós VRML não contém, necessariamente, todos os atributos e opções. Por motivos didáticos, apenas as principais características foram selecionadas para discussão. Para uma referência completa dos nós VRML, veja a especificação da ISO em:
http://www.web3d.org/x3d/specifications/vrml/
![Page 26: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/26.jpg)
Primitivas Básicas Shape {
Geometry• Box • Cone • Cylinder • ElevationGrid • Extrusion • IndexedFaceSet • IndexedLineSet • PointSet • Sphere • Text
Appearance• material • texture • textureTransform
}
![Page 27: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/27.jpg)
Box
Box { size 2 2 2 }
defaultsx y z
Centro = ( 0, 0, 0 )
![Page 28: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/28.jpg)
Box#VRML V2.0 utf8Shape { geometry Box {} appearance Appearance { material Material {
diffuseColor 1 0 0 }
}}
Aparência: cor vermelha
Valores default: 2 2 2
![Page 29: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/29.jpg)
Sphere
Sphere { radius 1 }
Raio default
Centro = ( 0, 0, 0 )
![Page 30: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/30.jpg)
Sphere#VRML V2.0 utf8Shape { geometry Sphere {} appearance Appearance { material Material {
diffuseColor 0 1 0 }
}}
Aparência: cor verde
Raio default: 1
![Page 31: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/31.jpg)
Cone
Cone {bottomRadius 1 height 2 side TRUE bottom TRUE
}
![Page 32: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/32.jpg)
Cone#VRML V2.0 utf8Shape { geometry Cone {} appearance Appearance { material Material {
diffuseColor 0 0 1 }
}}
Aparência: cor azul
Valores default
![Page 33: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/33.jpg)
Cylinder
Cylinder {bottom TRUE height 2 radius 1 side TRUE top TRUE
}
![Page 34: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/34.jpg)
Cylinder#VRML V2.0 utf8Shape { geometry Cylinder {} appearance Appearance { material Material {
diffuseColor 1 0 1 }
}}
Aparência: cor magenta
Valores default
![Page 35: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/35.jpg)
Primitivas Básicas e Avançadas Shape {
Geometry• Box • Cone • Cylinder • ElevationGrid • Extrusion • IndexedFaceSet • IndexedLineSet • PointSet • Sphere • Text
Appearance• material • texture • textureTransform
} Text
fontStyle
Group Transform Viewpoint Anchor Inline Proto Extern Proto WorldInfo Background Panorama Fog IndexedFaceSet IndexedLineSet PointSet Extrusion Elevation Grid
Billboard
![Page 36: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/36.jpg)
Text
Text { string []fontStyle NULLlength [] maxExtent 0.0
}
Posição inicial Z = 0 fontstyle é outro nó que
especifica detalhes do fonte usado
length indica o tamanho (pode encolher ou alargar a apresentação do string)
maxExtent
maxExtent
![Page 37: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/37.jpg)
fontStyle
fontStyle { family "SERIF"horizontal TRUEjustify "BEGIN"language ""leftToRight TRUEtopToBottom TRUEsize 1.0 spacing 1.0 style "PLAIN"}
![Page 38: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/38.jpg)
Text#VRML V2.0 utf8 gerado por denio
Shape{ geometry Text {
string "VRML is Easy!"length 30 fontStyle FontStyle {
family "VERDANA"horizontal TRUEjustify "BEGIN"language ""leftToRight FALSEsize 4.0 spacing 1.0 style "BOLD"topToBottom TRUE
} }}
Esquerda para a direita
fontStyle Opcional
![Page 39: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/39.jpg)
Aparência dos Objetos Appearance
material texture textureTransform
![Page 40: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/40.jpg)
Material Material {
ambientIntensity 0.2diffuseColor 0.8 0.8 0.8 emissiveColor 0 0 0shininess 0.2specularColor 0 0 0 transparency 0
} ambientIntensity
Indica com que intensidade o objeto deve refletir a luz do ambiente
diffuseColor a cor que o objeto emite
transparency Grau de transparência (0=opaco, 1=transparente)
#VRML V2.0 utf8Shape { geometry Cylinder {} appearance Appearance { material Material {
diffuseColor 1 0 1 }
}}
![Page 41: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/41.jpg)
Aparência dos Objetos Appearance
material texture textureTransform
![Page 42: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/42.jpg)
Texture
texture ImageTexture { url []repeatS TRUErepeatT TRUE
} url = aponta para um arquivo JPEG, PNG, GIF repeatS = repete na horizontal (FALSE=distorce) repeatT = repete na vertical (FALSE=distorce)
![Page 43: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/43.jpg)
Texture
#VRML V2.0 utf8Shape {
geometry Sphere {}appearance Appearance {
texture ImageTexture {url ”jupiter.jpg”
} }
}
Arquivo com a textura
![Page 44: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/44.jpg)
Primitivas Avançadas Group Transform Viewpoint Achor Inline WorldInfo Background
![Page 45: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/45.jpg)
Group
Group { children [ nó interno ]
} Agrupa nós formando uma hierarquia Podemos usar DEF para nomear e usar depois
#VRML V2.0 utf8DEF GRUPO1 Group {
children [Shape {geometry Sphere {} }Shape {geometry Box {} }Shape {geometry Cone {} }
] bboxSize -1.0 -1.0 -1.0
bboxCenter 0.0 0.0 0.0addChildrenremoveChildren
}
![Page 46: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/46.jpg)
Transform Transform {
children [ ] rotation 0 0 1 0 scale 1 1 1 translation 0 0 0
} children pode conter vários nós
Transformações afetam todos os filhos rotation: indicar o eixo e o ângulo
eixo X = 1 0 0, eixo Y = 0 1 0, eixo Z = 0 0 1 scale: uma escala em cada eixo (scale>0) translation: usado mover objetos nos eixos
translation 20 0 0 --> X=X+20 translation 0 -1 -10 --> X=X, Y=Y-1, Z=Z-10
![Page 47: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/47.jpg)
Transform
Criando objetos em um lugar desejado Mudando a posição inicial do centro (0, 0, 0)
#VRML V2.0 utf8Transform {
translation 10 10 10 children [
Shape { geometry Sphere {} }]
}
![Page 48: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/48.jpg)
Transform
Rotacionando objetos
#VRML V2.0 utf8
DEF CONE Shape {geometry Cone { height 3 }appearance Appearance {material Material {diffuseColor 0 0 1
} }}Transform {# 180 graus em X rotation 1 0 0 3.14159translation 0 -1 0 children USE CONE
}
![Page 49: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/49.jpg)
Viewpoints
O nó Viewpoint descreve a posição, a orientação e o campo de visão para a observação de uma cena.
Por default, o observador entra no mundo na posição (0.0, 0.0, 10.0).
Com o nó Viewpoint podem ser especificados: novas posições de entrada do observador no mundo
VRML vistas especiais para o observador nomes para a vistas
Viewpoints podem ser transformados com o nó Transform O browser mostra um menu com a lista dos viewpoints
definidos
![Page 50: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/50.jpg)
Viewpointscont. Viewpoint {
orientation 0 0 1 0
position 0 0 10
description ”descrição"
} orientation = orientaçao do campo de visao
Mesma interpretaçao do “transform/rotation”
position = a posiçao do observador description = um nome para o viewpoint No browser, a sintaxe ".../scene.wrl#ViewpointName"
especifica o viewpoint inicial do usuário, após carregar a cena que contém: DEF ViewpointName Viewpoint {...}
set_bindfieldOfViewjump bindTimeisBound
![Page 51: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/51.jpg)
Adicionano Links Anchor {
children []
description “descricao do link"
url “url de destino”
} Adiciona um link para um outro arquivo
com em HTML URL: Um arquivo qualquer Internet “www.vrml.org/mundo.wrl” Disco local “../obj.wrl”, “obj.wrl”
#VRML V2.0 utf8
#Link de saidaAnchor{children [Shape {geometry Sphere{}
}]description “sair”url “../../index.htm”
}
parameter bboxSize bboxCenter
![Page 52: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/52.jpg)
Reusando Objetos
Inline {
url “nome”
} Incorpora objetos já construídos
URL: Um arquivo qualquer Internet “www.lalonge.com/vrml/obj.wrl” Disco local “../obj.wrl”, “obj.wrl”
#VRML V2.0 utf8
#EixosInline { url "../coord.wrl" }
Shape {geometry Sphere {}
}
![Page 53: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/53.jpg)
Reusando Objetos cont.
#VRML V2.0 utf8 by David R. NadeauInline { url "table.wrl" }# CadeirasTransform { translation 0.95 0.0 0.0 children DEF Chair Inline { url "chair.wrl" }}Transform { translation -0.95 0.0 0.0 rotation 0.0 1.0 0.0 3.14 children USE Chair}Transform { translation 0.0 0.0 0.95 rotation 0.0 1.0 0.0 -1.57 children USE Chair}Transform { translation 0.0 0.0 -0.95 rotation 0.0 1.0 0.0 1.57 children USE Chair}
X+Z+
Y+
![Page 54: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/54.jpg)
Reusando e Modificando Objetos
PROTO nome [tipoAcesso tipo parâmetro1 valor] {
objetoPrototipado {
campoParametrizado IS parâmetro1
}
} Incorpora objetos já construídos e faz modificações
através da passagem de valores internamente à nova cópia do objeto
![Page 55: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/55.jpg)
Reusando e Modificando Objetos cont.
Exemplo
#VRML V2.0 utf8#Criação de protótipoPROTO myBox [ field SFColor boxColour 1 0 0 ] {
Shape { appearance Appearance { material Material { diffuseColor IS boxColour
} } geometry Box { }
} } #Caixa em vermelho: uso do valor padrão do parâmetroTransform {translation -2 0 0 children myBox { }}
#Caixa com nova cor passada como parâmetroTransform {translation 2 0 0 children myBox { boxColour 0 1 0 }}
![Page 56: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/56.jpg)
Reusando e Modificando Objetos Externos EXTERNPROTO nomeNo [tipoAcesso tipo
parâmetro1 valor]
[“possivelLocalizacao1NoProto”,
“possivelLocalizacao2NoProto”]
} Incorpora objetos já construídos externamente e
faz modificações através da passagem de valores internamente à nova cópia do objeto
Localizações alternativas da definição do objeto Não precisa definir os valores de campo padrão
![Page 57: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/57.jpg)
Reusando e Modificando Objetos Externos Exemplo1: Arquivo somente
com nó PROTO de myBox e único endereço de localização:
#VRML V2.0 utf8
#Criação de protótipoEXTERNPROTO myBox [ field SFColor boxColour] “protoMyBox.wrl”
#Caixa em vermelho: uso do valor padrão do parâmetroTransform {translation -2 0 0 children myBox { }}#Caixa com nova cor passada como parâmetroTransform {translation 2 0 0 children myBox { boxColour 0 1 0 }}
#VRML V2.0 utf8
#Criação de protótipoEXTERNPROTO myBox [ field SFColor boxColour] [“protoMyBox.wrl#myBox”, “www.cin.ufpe.br/protos.wrl#myBox”]
#Caixa em vermelho: uso do valor padrão do parâmetroTransform {translation -2 0 0 children myBox { }}#Caixa com nova cor passada como parâmetroTransform {translation 2 0 0 children myBox { boxColour 0 1 0 }}
Exemplo2: Arquivo com vários nós PROTO (incluindo o de myBox) e vários possíveis endereços de localização:
![Page 58: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/58.jpg)
Primitivas Básicas e Avançadas
Shape { Geometry
• Box • Cone • Cylinder • Sphere • Text
Appearance• material • texture • textureTransform
}
Text fontStyle
Group Transform Viewpoint Anchor Inline Proto Extern Proto WorldInfo Background Panorama Fog IndexedFaceSet IndexedLineSet PointSet Extrusion Elevation Grid
Billboard
![Page 59: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/59.jpg)
Informações Gerais do Mundo
WorldInfo {
title “nome"
info [“info1" “info2"]
} Contém informações gerais
Título para aparecer na barra de título da janela do navegador
Outras informações relevantes do mundo
#VRML V2.0 utf8
#Informações do MundoWorldInfo { title "Meu mundo Virtual" info ["(C)Copyright 2004 Eu""[email protected]"] }
Equivalente a tag TITLE em HTML Pode se ter mais de um nó WorldInfo
só o primeiro é processado pelo parser VRML
![Page 60: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/60.jpg)
Backgrounds
Modifica o pano de fundo da cena Background { skyColor [ 0.0 0.0 0.0] skyAngle [] groundColor [] groundAngle []} Informações básicashttp://www.cin.ufpe.br/~if124/vrml/cores_em_vrml.htm
![Page 61: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/61.jpg)
Backgrounds
#VRML V2.0 utf8 Background {
skyColor [0 0 1, .5 0 .5, 1 0 0]
skyAngle [1.31, 1.57] groundColor [1 0 0, 0 .5 .2,
0 .8 .3] groundAngle [1.31, 1.57] }
Céu
Chão
N cores implica N-1 ângulos
2º ângulo
1º ângulo
Primeira cor
(2ª cor)
(3ª cor)
1º ângulo
2º ângulo
Primeira cor
(2ª cor)
(3ª cor)
![Page 62: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/62.jpg)
Cubo envolvendo o usuário com planos de fundo
Background {
MFString backUrl []
MFString bottomUrl []
MFString frontUrl []
MFString leftUrl []
MFString rightUrl []
MFString topUrl []
}
Panoramas
bottomUrl
leftUrlfrontUrl
rightUrl
backUrl
topUrl
![Page 63: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/63.jpg)
Panoramas
#VRML V2.0 utf8 Background {
skyColor [0 0 1, .5 0 .5, 1 0 0]
skyAngle [1.31, 1.57] groundColor [1 0 0, 0 .5 .2,
0 .8 .3] groundAngle [1.31, 1.57] backUrl "ceuLateral.gif" frontUrl "ceuLateral.gif" rightUrl "ceuLateral.gif" leftUrl "ceuLateral.gif" bottomUrl "grass.jpg" topUrl "ceuTop.png"}
Combinação de campos de background Panorama com cor de transparência Cores de fundo
Não utilizar cores de fundo se não houver transparência no panorama
![Page 64: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/64.jpg)
Fog {
SFColor color 0 0 0
SFString fogType "LINEAR"
SFFloat visibilityRange 0
} Fornece o efeito de neblina Restringe o campo de visão do usuário
Diminui processamento gráfico do mundo
Neblina
![Page 65: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/65.jpg)
Objetos sem appearance e material não são afetados
Fog da mesma cor do background!
Panoramas
#VRML V2.0 utf8 Fog { color 0 0 0 fogType "EXPONENTIAL" visibilityRange 50 }
Shape { geometry Box{} appearance Appearance { material Material { diffuseColor 1 1 1 } } }
![Page 66: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/66.jpg)
Objetos Com Faces Planas - IndexedFaceSet IndexedFaceSet {
coord Coordinate { point [ ] } NULLcoordIndex [] color NULLcolorIndex []solid TRUEconvex TRUEccw TRUE
}
set_coorIndexset_texCoordIndexset_colorIndexset_normalIndexnormal NULLtexCoord NULL
colorPerVertex TRUE
creaseAngle 0normalIndex []normalPerVertex TRUEtexCoordIndex []
![Page 67: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/67.jpg)
IndexedFaceSet
Construindo Figuras irregulares
x
Y
F=(10, 0, 0)
A=(5, 8.66, 0)B=(-5, 8.66, 0)
D=(-5, -8.66, 0)
C=(-10, 0, 0)
E=(5, -8.66, 0)
R
Hexágono = 60o
R = 10sen() = 0.8660 cos() = 0.5000
Plano = ABCDEF
![Page 68: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/68.jpg)
IndexedFaceSet
Coord Coordinate { point [ <pontos 3D>] } Define as coordenadas 3D dos vértices Vértices serão referenciados por coordIndex
coordIndex Especifica as faces poligonais, indexando as coordenadas contidas
em coord Um índice "-1” indica o fim da definição da face Os N vértices de coord devem ser indexados de 0 a N-1 Cada face definida deve ter:
• Pelo menos 3 vértices (não-coincidentes)• Vértices que definam um polígono plano• Vértices que definam um polígono sem auto-interseção
Exemplo: coord Coordinate { point [ 1 1 0, -1 1 0, -1 -1 0, 1 -1 0 ] }
coordindex [ 0, 1, 2, 3, -1 ]
A face é formada pelos vértices 0, 1, 2 e 3
![Page 69: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/69.jpg)
IndexedFaceSet
Convex Define se o polígono é convexo ou não Valor inicial: TRUE
Solid Define se as duas faces de um polígono serão mostradas Valor inicial: TRUE
CCW Define a relação entre a ordem de criação dos vértices e
a face que deve ser mostrada (ou a normal da face apresentada).
Valor padrão: TRUE (sentido anti-horário) Exemplo:
![Page 70: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/70.jpg)
IndexedFaceSet cont.
color Define cores a serem referenciados por colorIndex
colorIndex Indica as cores para cada face Deve manter a ordem
colorPerVertex
Exemplo: Suponha objeto com 5 faces: # define 3 cores color Color { color [ 1 0 0, 0.5 0.5 0.5, 0.3 0.1 0.1 ] } # define a cor de cada face colorIndex[ 0, 0, 1, 2, 1 ]
Face 1 Face 2 Face 5...
Cor 0 Cor 2Cor 1
![Page 71: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/71.jpg)
IndexedFaceSet cont.
#VRML V2.0 utf8 by Beatriz Castier et alInline { url "../coord.wrl" } #EixosShape { # Desenho do cubo geometry IndexedFaceSet { coord Coordinate {
point [ # vértices do cubo 1 1 1, 1 -1 1, -1 -1 1, -1 1 1, 1 1 -1, 1 -1 -1, -1 -1 -1, -1 1 -1 ]
} coordIndex [ # Faces do cubo
2, 3, 7, 6, -1, 0, 1, 5, 4, -1, # plano ZY0, 4, 7, 3, -1, 1, 2, 6, 5, -1, # plano ZX 0, 3, 2, 1, -1, 4, 5, 6, 7, -1, # plano XY
]
color Color {color [ 1 0 0, 0 1 0, 0 0 1 ] } colorPerVertex FALSE colorIndex [ 0, 0, 1, 1, 2, 2, -1 ] }}
Face 1
Face 6
Vértice 0Vértice 7
Cor 0 Cor 2
Cor da face 1 Cor da face 6
![Page 72: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/72.jpg)
Criando Linhas - IndexedLineSet
IndexedLineSet { coord Coordinate { point [ ] } NULL coordIndex [] color NULL colorIndex [] colorPerVertex TRUE
}
Desenha Linhas Permite criar objetos em wireframe Linhas sem colisão
set_coordIndexset_colorIndex
![Page 73: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/73.jpg)
Criando Linhas - IndexedLineSet
#VRML V2.0 utf8Shape{ appearance Appearance { material Material { emissiveColor 1 0 1 } } geometry IndexedLineSet { coord Coordinate { point [0 0 0, 1 1 0,-1 0 0,-1 -1 0,1 -1 0, 1 0 1, 1 1 1 ] } coordIndex [1 2 3 4 5 6 1 6 2 6 5 3 4 1] } }
#VRML V2.0 utf8Shape{ geometry IndexedLineSet { coord Coordinate { point [0 0 0, 1 1 0,-1 0 0,-1 -1 0,1 -1 0, 1 0 1, 1 1 1 ] } color Color {color [1 0 0, 0 1 0, 0 0 1]} coordIndex [1 2 3 4 5 6 1 6 2 6 5 3 4 1] colorIndex [0 1 2 0 1 2 0 1 2 0 1 2 0 1] colorPerVertex TRUE } }
![Page 74: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/74.jpg)
Criando Pontos - PointSet
PointSet { coord [0.2 0 0.5, 1
1 1] color [1 0 1, 0.2 0
0.5]}
Desenha Pontos Pontos sem colisão
#VRML V2.0 utf8Shape{ geometry PointSet { coord Coordinate { point [0 0 0, 1 1 0,-1 0 0,-1 -1 0,1 -1 0,1 0 1, 1 1 1 ] } color Color { color [1 0 0, 0 1 0, 0 0 1, 1 0 1, 1 1 0, 0 1 1, 1 1 1 ] } } }
![Page 75: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/75.jpg)
Terrenos – ElevationGrid
ElevationGrid { MFFloat height [] SFBool solid TRUE SFInt32 xDimension 0 SFFloat xSpacing 0.0 SFInt32 zDimension 0 SFInt32 zSpacing 0.0
} Criação de terrenos irregulares Matriz de alturas de pontos homogeneamente
distribuídos
set_height color normal texCoordccw colorPerVertex creaseAngle normalPerVertex solid
![Page 76: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/76.jpg)
Ordem dos pontos: Percurso do eixo x da esquerda para a direita a partir de –z (mais distante)
Terrenos – ElevationGrid
#VRML V2.0 utf8
Shape { appearance Appearance { texture ImageTexture { url "grass.jpg" } }
geometry ElevationGrid { xDimension 6 zDimension 6 xSpacing 5.0 zSpacing 5.0 height [ 0, 0, 3, 4, 4, 0, 0, 2, 4, 5, 4, 2, 0, 0, 1, 4, 3, 1, 0, 1, 2, 3, 2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0] }}
yx
zx
zy
![Page 77: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/77.jpg)
Extrusão - Extrusion
Extrusion {beginCap TRUE ccw TRUE convex TRUE crossSection [ 1 1, 1 -1, -1 -1, -1 1, 1 1 ] endCap TRUE orientation 0 0 1 0 scale 1 1 solid TRUE spine [ 0 0 0, 0 1 0 ]
}
set_spineset_crossSectionset_scaleset_orientation
creaseAngle
![Page 78: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/78.jpg)
ExtrusionCont.
Extrusion constrói objetos baseados em um plano-base 2D alongado perpendicularmente através de uma "espinha".
O plano-base é chamado "cross-section". O "cross-section" é definido no plano XZ. O eixo "espinha" é chamado "spine". O "spine" define o caminho que o "cross-section"
irá percorrer para formar o objeto 3D. O "spine" é indicado por vários pontos 3D. O plano cross-section pode sofrer mudanças de
escala e rotações a cada ponto do spine.
![Page 79: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/79.jpg)
ExtrusionCont.
Etapas: Defina o cross-section Defina o spine Defina escalas para cada ponto
do spine Defina rotações
![Page 80: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/80.jpg)
ExtrusionCont.
#VRML V2.0 utf8
Shape { appearance Appearance { material Material { diffuseColor 0 0 1 # azul
}}geometry Extrusion{crossSection [ -1 -1, -1 1, 1 1, 1 -1, -1 -1]spine [0 -1 0, 0 0 0, 0 1 0 ] orientation [0 1 0 0, 0 1 0 0, 0 1 0 0] scale [1 1, 1 1, 1 1]
}} extrusao-1.wrl
![Page 81: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/81.jpg)
ExtrusionCont.
#VRML V2.0 utf8
Shape { appearance Appearance { material Material { diffuseColor 0 0 1 # azul
}}geometry Extrusion{crossSection [ -1 -1, -1 1, 1 1, 1 -1, -1 -1]spine [0 -1 0 , 0 0 0, 0 1 0 ] orientation [0 1 0 0, 0 1 0 0, 0 1 0 0] scale [1 1, 1 1, 1 1]solid FALSEbeginCap FALSEendCap FALSE
} }extrusao-2.wrl
![Page 82: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/82.jpg)
ExtrusionCont.
#VRML V2.0 utf8
Shape { appearance Appearance { material Material { diffuseColor 0 0 1 # azul
}}geometry Extrusion{crossSection [
-1 -1, -1 1, 1 1, 1 -1, -1 –1 ]
spine [0 -1 0 , 0 1 0 ] # escala no ponto finalorientation [0 1 0 0, 0 1 0 0] scale [1 1, .5 .5 ]
}}
extrusao-3.wrl
![Page 83: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/83.jpg)
ExtrusionCont.
#VRML V2.0 utf8
Shape { appearance Appearance { material Material { diffuseColor 0 0 1 # azul
}}geometry Extrusion{crossSection [ -1 -1,
-1 1, 1 1, 1 -1, -1 –1 ]
spine [0 -1 0 , 0 1 0 ] # rotacao no ponto finalorientation [0 1 0 0, 0 1 0 3.14 ] scale [1 1, 1 1 ]
}}
extrusao-4.wrl
![Page 84: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/84.jpg)
ExtrusionCont.
#VRML V2.0 utf8
Shape { appearance Appearance { material Material { diffuseColor 0 0 1 # azul
}}geometry Extrusion{crossSection [ -1 -1,
-1 1, 1 1, 1 -1, -1 –1 ]
spine [0 -1 0 , 0 1 0 ] # escala e rotacao no ponto finalorientation [0 1 0 0, 0 1 0 3.14 ] scale [1 1, .5 .5 ]
}}
extrusao-5.wrl
![Page 85: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/85.jpg)
ExtrusionCont.
#VRML V2.0 utf8
Shape { appearance Appearance { material Material { diffuseColor 0 0 1 # azul
}} # SPINE DE 3 PONTOSgeometry Extrusion{crossSection [ -1 -1, -1 1, 1 1, 1 -1, -1 -1]spine [0 -1 0 , 0 0 0, 0 1 0 ] # rotacao no plano final do spine (45 graus)orientation [0 1 0 0, 0 1 0 0, 0 1 0 0.785 ]scale [1 1, 1 1, 1 1]
}}
extrusao-6.wrl
![Page 86: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/86.jpg)
ExtrusionCont.
#VRML V2.0 utf8Shape { appearance Appearance { material Material { diffuseColor 0 0 1 # azul
}} # SPINE DE 3 PONTOSgeometry Extrusion{crossSection [ -1 -1, -1 1, 1 1, 1 -1, -1 -1]spine [0 -1 0 , 0 0 0, 0 1 0 ] # rotacao no spine médio de 45 graus# rotacao no spine final de 90 grausorientation [0 1 0 0, 0 1 0 0.785, 0 1 0 1.57] scale [1 1, 1 1, 1 1]
} } extrusao-7.wrl
![Page 87: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/87.jpg)
ExtrusionCont.
#VRML V2.0 utf8Shape { appearance Appearance { material Material { diffuseColor 0 0 1 # azul
}}geometry Extrusion{crossSection [ -1 -1, -1 1, 1 1, 1 -1, -1 -1]spine [0 -1 0 , 0 0 0, 0 1 0 ] # rotacao no spine médio de 45 graus# rotacao no spine final de 0 grausorientation [0 1 0 0, 0 1 0 0.785, 0 1 0 0] scale [1 1, 1 1, 1 1]
} } extrusao-8.wrl
![Page 88: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/88.jpg)
ExtrusionCont.
#VRML V2.0 utf8Inline { url "eixo_colorido.wrl" }Shape { appearance Appearance { material Material { diffuseColor 0 0 1 # azul
}}geometry Extrusion{crossSection [ -1 -1, -1 1, 1 1, 1 -1, -1 -1]# spine no PLANO XZspine [-2 0 -2, -2 0 2, 2 0 2, 2 0 -2, -2 0 -2 ]
}
}extrusao-9.wrl
![Page 89: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/89.jpg)
ExtrusionCont.
#VRML V2.0 utf8Inline { url "eixo_colorido.wrl" }Shape { appearance Appearance { material Material { diffuseColor 0 0 1 # azul
}}geometry Extrusion{crossSection [ -1 -1, -1 1, 1 1, 1 -1, -1 -1]# spine no PLANO YZspine [0 -2 -2, 0 -2 2, 0 2 2, 0 2 -2, 0 -2 -2]
}
}extrusao-10.wrl
![Page 90: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/90.jpg)
ExtrusionCont.
#VRML V2.0 utf8Inline { url "eixo_colorido.wrl" }Shape { appearance Appearance { material Material { diffuseColor 0 0 1 # azul
}}geometry Extrusion{crossSection [ -1 -1, -1 1, 1 1, 1 -1, -1 -1]# spine no PLANO XYspine [-2 -2 0, -2 2 0, 2 2 0, 2 -2 0, -2 -2 0]
}
}extrusao-11.wrl
![Page 91: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/91.jpg)
ExtrusionCont.
#VRML V2.0 utf8Inline { url "eixo_colorido.wrl" }Shape { appearance Appearance { material Material { diffuseColor 0 0 1 # azul
}}geometry Extrusion{ccw FALSEspine [ 0 -3 0, 0 3 0 ]crossSection [ 1 0, 0.707 0.707, 0 1, -0.707 0.707, -1 0,
-0.707 -0.707, 0 -1, 0.707 -0.707, 1 0 ]
}}
extrusao-12.wrl
![Page 92: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/92.jpg)
ExtrusionCont.
#VRML V2.0 utf8Inline { url "eixo_colorido.wrl" }Shape { appearance Appearance { material Material { diffuseColor 0 0 1 # azul
}}
geometry Extrusion{ccw FALSEcrossSection [ 1 0, 0.707 0.707, 0 1, -0.707 0.707, -1 0, -0.707 -0.707, 0 -1, 0.707 -0.707, 1 0 ]
spine [2 0 0 , 1.414 0 1.414, 0 0 2, -1.414 0 1.414, -2 0 0,
-1.414 0 -1.414, 0 0 -2, 1.414 0 -1.414, 2 0 0 ]
}} extrusao-13.wrl
![Page 93: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/93.jpg)
Bilboard
Billboard { addChildren
removeChildren axisOfRotation 0 1 0 children [ nó interno ]
bboxCenter 0 0 0 bboxSize -1 -1 -1 }
![Page 94: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/94.jpg)
Billboard Cont.
Billboard constrói objetos que fiquem sempre virados para o usuário que navega no mundo.
Garante efeito tridimensional utilizando-se objetos bidimensionais. Exemplo: árvores.
Ajuda na redução o número de polígonos da cena.
![Page 95: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/95.jpg)
Etapas: Definir objeto a ser aplicado Billboard Definir eixo de rotação do Billboard Inserir o objeto como children do nó Billboard
Precauções Posicionar face correta do objeto para frente do usuário Em caso de uso de imagem, aplicar cor de transparência
• Formato PNG é recomendado• O GIF também pode ser utilizado
Billboard Cont.
![Page 96: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/96.jpg)
Bilboard
Billboard { addChildren
removeChildren axisOfRotation 0 1 0 children []
bboxCenter 0 0 0 bboxSize -1 -1 -1 }
#VRML V2.0 utf8Billboard { axisOfRotation 0.0 1.0 0.0 children [ Transform { scale 15 15 15 children [ Shape { appearance Appearance { texture ImageTexture {url "arvore.png"} } geometry IndexedFaceSet { coord Coordinate { point [-1.0 0.0 0.0, 1.0 0.0 0.0, 1.0 2.0 0.0, -1.0 2.0 0.0, ] } coordIndex [ 0, 1, 2, 3 ] solid FALSE } } ] } #The VRML 2.0 Sourcebook ] #Copyright (c) 1997} #Andrea L. Ames, David R. Nadeau, and John L. Moreland
![Page 97: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/97.jpg)
É possível alterar as cores e as normais por face ou por vértice de nós avançados comoIndexedFaceSetExtrusionElevationGrid
Isso permiteMudar iluminação em partes dos objetosControlar suavização de bordas
Como? Campos: CreaseAngle, NormalPerVertex,
NormalIndex, ccwNós: Normal, Color
Colorido e Normal?
![Page 98: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/98.jpg)
É possível configurar o mapeamento das texturas em objetos avançados comoIndexedFaceSetExtrusionElevationGrid
Isso permite aplicar à texturaRotação, translação e escalaMapeamento vértice a vértice de uma textura
num objeto Como?
Campos: Texture, texCoord, texCoordIndexNós: TextureTransform, TextureCoordinate
Onde está a Textura?
![Page 99: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/99.jpg)
Primitivas Básicas e Avançadas Group Transform Viewpoint Anchor Inline Proto Extern Proto WorldInfo Background Panorama Fog IndexedFaceSet IndexedLineSet PointSet Extrusion Elevation Grid
Billboard DirectionalLight PointLight SpotLight Sound AudioClip NavigationInfo TimeSensor VisibilitySensor ProximitySensor Collision TouchSensor SphereSensor CylinderSensor PlaneSensor
![Page 100: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/100.jpg)
Luzes
Headlight off!Preferences – Navigation - Headlight on X
Processamento de iluminação para polígonoMédia da iluminação em cada vértice
Campos básicosColorIntensityAmbientIntensity
Tipos de luzDirectionalLight: raios de luz numa mesma
direçãoPointLight: lâmpada comumSpotLight: cone de luz
![Page 101: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/101.jpg)
Luzes - DirectionalLight
DirectionalLight { ambientIntensity 0 color 1 1 1direction -1 0 -1intensity 1on TRUE
}
Raios de luz paralelos – luz do sol
![Page 102: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/102.jpg)
Luzes - DirectionalLight
Iluminação hierárquicaIlumina todos abaixo de seu pai na hierarquia
Copyright 1998-2001 Vapour Technology Ltd.
Raiz
Group
![Page 103: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/103.jpg)
Luzes - DirectionalLight
#VRML V2.0 utf8NavigationInfo {headlight FALSE}DirectionalLight { ambientIntensity 1 intensity 1 color 1 1 0 direction -1 -1 -1}Shape { appearance Appearance { material Material { diffuseColor 1 1 1 } } geometry Box {}} Viewpoint { orientation 1 1 0 -0.78 position -4 4 4 description "view 1"}
![Page 104: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/104.jpg)
Luzes - PointLight
PointLight { ambientIntensity 0 attenuation 1 0 0 color 1 1 1 intensity 1 location 0 0 0 on TRUE radius 100
} Luz emana de ponto no espaço – lâmpada
incandescente
![Page 105: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/105.jpg)
Luzes - PointLight
#VRML V2.0 utf8NavigationInfo {headlight FALSE}PointLight { ambientIntensity 1 intensity 1 color 1 1 0 attenuation 0 0.8 0 location 0 0 0 radius 30 }DEF mySphere Transform { translation 2 0 0 children Shape { appearance Appearance { material Material {diffuseColor 1 1 1} } geometry Sphere {} } }Transform { translation 4 0 0children USE mySphere}
Transform { translation -4 0 0children USE mySphere}
Transform {translation -8 0 0children USE mySphere}
![Page 106: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/106.jpg)
Luzes - SpotLight
SpotLight {ambientIntensity 0 attenuation 1 0 0 beamWidth 1.57color 1 1 1 cutOffAngle 0.78direction 0 0 -1 intensity 1 location 0 0 0 on TRUE radius 100
}
Luz em forma de cone, Lâmpada de leitura
Mesmos parâmetros das outras duas luzes, além de:BeamWidthCutOffAngle
cutOffAngle
BeamWidth
raio
![Page 107: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/107.jpg)
Luzes - SpotLight
#VRML V2.0 utf8NavigationInfo {headlight FALSE}SpotLight { ambientIntensity 1 attenuation 0 0.75 0 beamWidth 1.57 color 1 1 1 cutOffAngle 0.7 direction 0 0 -1 intensity 1 location 0 0 5 on TRUE radius 10 }Shape { appearance Appearance { material Material { diffuseColor 1 1 1}} geometry Box {size 10 10 0.1}}
![Page 108: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/108.jpg)
Sound { direction 0 0 1 intensity 1 location 0 0 0 maxBack 10 maxFront 10 minBack 1 minFront 1 priority 0 source NULL spatialize TRUE
}
Sons - Sound
minBack
minFront
maxFront
maxBack
dir
ect
ion
![Page 109: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/109.jpg)
AudioClip { description "" loop FALSE pitch 1.0 startTime 0 stopTime 0 url []
} Define configuração para nó Sound Formatos MIDI “.MID” 1.0 ou “.WAV” sem
compressão
Sons - Sound
![Page 110: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/110.jpg)
Sons - Sound
ExemploMúsica ambiente
#VRML V2.0 utf8Sound { maxBack 50 maxFront 50 minBack 5 minFront 5 source AudioClip { description "Musica ambiente" loop TRUE url "musica.mid"}
spatialize FALSE }
![Page 111: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/111.jpg)
NavigationInfo { avatarSize [0.25, 1.6, 0.75] headlight TRUE speed 1.0 type ["WALK"]visibilityLimit 0.0
} Configura avatar do usuário, sua navegação e
limite de visibilidade
Navegação – NavigationInfo
set_bindisBound
![Page 112: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/112.jpg)
Eventos
São notificações de mudança no valor de algum campo
Campos EventOut eventos que geram informação EventIn aceitam e utilizam informação externa
(EventOut) Campos Exposed possuem EventIn e EventOut
próprios Um evento é composto de
Mensagem TimeStamp
Eventos encadeados tem mesmo timeStamp
![Page 113: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/113.jpg)
Rotas
Efetuam a transmissão de informação entre eventos Ex.: tocar um som quando o mouse for clicado
• Definir nomes únicos para os objetos cujos eventos serão ligados
DEF SENSOR TouchSensor { } DEF SOUND Sound { }
• Conectar campos através do comando RouteROUTE SENSOR.touchTime TO SOUND.startTime
Se houver objetos com mesmo nome, todos serão afetados!
Sensor
EventOut TouchTime
Sound
EventIn StartTimeRoute
![Page 114: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/114.jpg)
Eventos e Rotas cont.
VRML não converte tipos de eventos Criação de Sript de conversão
Um evento é composto de Mensagem TimeStamp
Eventos encadeados tem mesmo TimeStamp Geração de eventos com novo TimeStamp
Scripts Sensores
Nós de animação e interação Sensores Interpoladores Scripts
![Page 115: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/115.jpg)
Eventos
Exemplos
ok
?ok
ok
ok
ok?
Fan out e fan in em mesma cascata
Fan in de cascatasdistintas Loop numa cascata
![Page 116: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/116.jpg)
Sensores
Tipos de sensores Environmental
• TimeSensor• VisibilitySensor• ProximitySensor• Collision
Pointing-device• TouchSensor• SphereSensor• CylinderSensor• PlaneSensor
![Page 117: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/117.jpg)
Contando o tempo – TimeSensor
TimeSensor { exposedField SFBool enabled TRUE
exposedField SFTime cycleInterval 1 exposedField SFBool loop FALSE exposedField SFTime startTime
0 exposedField SFTime stopTime 0 eventOut SFTime cycleTime eventOut SFFloat fraction_changed eventOut SFBool isActive eventOut SFTime time
} Equivalente a cronômetro
![Page 118: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/118.jpg)
Contando o tempo– TimeSensor cont.
Exemplo Som tocado a cada 3 segundos
#VRML V2.0 utf8DEF Cronometer TimeSensor { cycleInterval 3.0 loop TRUE}Sound { minFront 5 minBack 5 maxFront 50 maxBack 50 source DEF MySound AudioClip { url "sound.wav" }}ROUTE Cronometer.cycleTime TO MySound.startTime
![Page 119: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/119.jpg)
Basta ver pra acontecer – VisibilitySensor VisibilitySensor {
exposedField SFVec3f center 0 0 0exposedField SFBool enabled TRUEexposedField SFVec3f size 0 0 0 eventOut SFTime enterTime eventOut SFTime exitTime eventOut SFBool isActive
} Sensores que são ativados quando se encontram
dentro do campo de visão do usuário. Útil para otimização de processamento de
animação
![Page 120: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/120.jpg)
Basta ver pra acontecer – VisibilitySensor cont.
Exemplo Canhão “atira” quando o usuário o vê
#VRML V2.0 utf8DEF mySensor VisibilitySensor { size 1.2 1.2 1.2 center 0 2.7 0 }Sound { minFront 5 minBack 5 maxFront 50 maxBack 50 source DEF mySound AudioClip { loop TRUE url "sound.wav" }}Inline {url "canhao.wrl"}ROUTE mySensor.enterTime TO mySound.startTimeROUTE mySensor.exitTime TO mySound.stopTime
![Page 121: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/121.jpg)
Chegue mais! – ProximitySensor ProximitySensor {
exposedField SFVec3f center 0 0 0exposedField SFBool enabled TRUEexposedField SFVec3f size 0 0 0 eventOut SFTime enterTime eventOut SFTime exitTime eventOut SFBool isActive eventOut SFVec3f position_changed eventOut SFRotation orientation_changed
} Sensores que são ativados quando o usuário de encontra
dentro da área do sensor. Útil para reações de personagens quanto à aproximação do
usuário (falar, atacar, fugir)
![Page 122: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/122.jpg)
Chegue mais! – ProximitySensor cont.
Exemplo Canhão “atira” quando o usuário se aproxima
#VRML V2.0 utf8DEF mySensor ProximitySensor { size 15 15 15}Sound { minFront 10 minBack 10 maxFront 100 maxBack 100 source DEF mySound AudioClip { loop TRUE url "sound.wav"}
}Inline {url "canhao.wrl"}ROUTE mySensor.enterTime TO mySound.startTimeROUTE mySensor.exitTime TO mySound.stopTime
![Page 123: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/123.jpg)
Obstruindo o Caminho – Collision
Collision { exposedField MFNode children []exposedField SFBool collide TRUEeventOut SFTime collideTime field SFNode proxy NULLfield SFVec3f bboxCenter 0 0 0 field SFVec3f bboxSize -1 -1 -1eventIn MFNode addChildren eventIn MFNode removeChildren
} Controla detecção de colisão entre nós Nó de agrupamento
![Page 124: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/124.jpg)
Obstruindo o Caminho – Collision cont.
Exemplo Não é possível encostar no canhão
#VRML V2.0 utf8NavigationInfo{type "WALK"}Collision { children Inline { url "canhao.wrl"} proxy Shape { geometry Box { size 30 30 30 } } collide TRUE}Viewpoint { position 0 0 30}
![Page 125: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/125.jpg)
TouchSensor { exposedField SFBool enabled TRUE eventOut SFBool isOver eventOut SFBool isActive eventOut SFTime touchTime eventOut SFVec2f hitTexCoord_changedeventOut SFVec3f hitNormal_changed eventOut SFVec3f hitPoint_changed
}
Detecção de Toque– TouchSensor
Posição do mouse
hitPosition
hitNormal
Tela do monitor
Objeto com TouchSensor
![Page 126: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/126.jpg)
#VRML V2.0 utf8Group { children [ Group { children [ DEF PositionOrientation TouchSensor {} Inline {url "canhao.wrl"} ] } DEF ShotSensor TouchSensor {} DEF shotAim Transform { children [ Sound { minFront 50 minBack 50 maxFront 100 maxBack 100 source DEF shotSound AudioClip {url "sound.wav"} } Inline {url "seta.wrl"} ] } ] }ROUTE ShotSensor.touchTime TO shotSound.startTimeROUTE PositionOrientation.hitPoint_changed TO shotAim.translation
Detecção de Toque– TouchSensor
Detecção de clique, arraste e sobreposição com o mouse em objetos com mesmo nó pai.
Group
GroupTouchSensor
![Page 127: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/127.jpg)
SphereSensor { exposedField SFBool enabled TRUE
eventOut SFBool isActive exposedField SFBool autoOffset TRUE exposedField SFRotation offset 0 1 0 0eventOut SFRotation rotation_changed eventOut SFVec3f trackPoint_changed }
Rotação Manual – SphereSensor
Posição do mouse
trackPoint
offSet
Tela do monitor
Objeto com SphereSensor
![Page 128: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/128.jpg)
#VRML V2.0 utf8NavigationInfo {type "NONE"}Group { children [ DEF MySensor SphereSensor {autoOffset TRUE} DEF boxTransform Transform { children Shape{ appearance Appearance { material Material { diffuseColor 0 1 1 } } geometry Box{} } } ]}ROUTE MySensor.rotation_changed TO boxTransform.rotation
Rotação Manual – SphereSensor
Detecção de rotação com o mouse em objetos com mesmo nó pai.
![Page 129: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/129.jpg)
CylinderSensor { exposedField SFBool enabled TRUE eventOut SFBool isActive exposedField SFBool autoOffset TRUEexposedField SFFloat offset 0 exposedField SFFloat diskAngle 0.262exposedField SFFloat maxAngle -1 exposedField SFFloat minAngle 0 eventOut SFRotation rotation_changed eventOut SFVec3f trackPoint_changed
}
Rotação Manual Restrita – CylinderSensor
Posição do mouse
trackPoint
offSet
Tela do monitor
Objeto com SphereSensor
DiskAngle
y
2
1
![Page 130: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/130.jpg)
#VRML V2.0 utf8Group { children [ DEF mySensor CylinderSensor {diskAngle 0.28} DEF coneTransform Transform { children Shape { appearance Appearance { material Material { diffuseColor 1 0 0 } } geometry Cone {} } } ]}ROUTE mySensor.rotation_changed TO coneTransform.rotation
Rotação Manual Restrita – CylinderSensor Detecção de rotação no eixo y com o mouse em
objetos com mesmo nó pai.
![Page 131: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/131.jpg)
PlaneSensor { exposedField SFBool enabled TRUE eventOut SFBool isActive exposedField SFBool autoOffset TRUEexposedField SFVec3f offset 0 0 0 exposedField SFVec2f maxPosition -1 -1 exposedField SFVec2f minPosition 0 0eventOut SFVec3f trackPoint_changed eventOut SFVec3f translation_changed
}
Translação Planar Manual – PlaneSensor
maxPosition
minPosition
y
maxPositionminPosition
x
![Page 132: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/132.jpg)
#VRML V2.0 utf8NavigationInfo {type "EXAMINE"}Shape {geometry Box{size 5 5 0.1}}Transform { translation 0 0 1 children [ DEF mySensor PlaneSensor { maxPosition 2.2 2.2 minPosition -2.2 -2.2 } DEF myBox Transform { children Shape { appearance Appearance { material Material {diffuseColor 0.5 0 0} }
geometry Box {size 0.3 0.3 0.3} } } ] }Viewpoint {position 0 0 30}ROUTE mySensor.translation_changed TO myBox.translation
Translação Planar Manual – PlaneSensor Detecção de translação no plano XY com o mouse
em objetos com mesmo nó pai.
![Page 133: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/133.jpg)
Primitivas Avançadas Group Transform Viewpoint Anchor Inline Proto Extern Proto WorldInfo Background Panorama Fog IndexedFaceSet IndexedLineSet PointSet Extrusion Elevation Grid
Billboard DirectionalLight PointLight SpotLight Sound AudioClip NavigationInfo TimeSensor VisibilitySensor ProximitySensor Collision TouchSensor SphereSensor CylinderSensor PlaneSensor
ColorInterpolator CoordinateInterpolator NormalInterpolator OrientationInterpolator PositionInterpolator ScalarInterpolator Bindable Script Switch LOD
![Page 134: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/134.jpg)
Modificam valores de campos ao longo do tempo
FuncionamentoO interpolator acompanha os ciclos do
TimeSensor.Interpolator recebe valor de Fraction_changed
de um TimeSensorEsse valor define o estágio em que o ciclo do
interpolator se encontra.O interpolator emite um valor final para o
campo sendo alterado por ele.
Dando vida a objetos - Interpolators
TimeSensor
fraction_changed
Interpolator
value_changed
set_fraction
Nó do objeto
set_...
![Page 135: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/135.jpg)
Estrutura básica: eventIn SFFloat set_fraction: valor recebido do
TimeSensor exposedField MFFloat key: seqüência de percentuais do
tempo total indicando quando cada valor de interpolação ocorrerá.
exposedField ? keyValue: valores de interpolação em si eventOut ? value_changed: valor enterpoladao a ser
passado para o campo do nó.
Dando vida a objetos - Interpolators
Variação de valores do campo (ex.: rotação)
Percentual de interpolação
Tempo decorrido
0 s 15 s10 s5 s
0 1,00,750,25 0,5
0 6.284.711.57 3.14
Fraction_changed
Keys
KeyValues
21.8% = 0.218
0.218
1.32 Value_changed
![Page 136: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/136.jpg)
#VRML V2.0 utf8DEF mySensor TimeSensor {cycleInterval 30 loop TRUE } DEF myInterpolator ColorInterpolator { key [0, 0.33, 0.66, 1] keyValue [ 1 0 0, 0 1 0, 0 0 1, 1 0 0 ] } Shape { appearance Appearance { material DEF myIntTarget Material {emissiveColor 1 0 0 } } geometry Box { } } ROUTE mySensor.fraction_changed TO myColorInterpolator.set_fraction ROUTE myInterpolator.value_changed TO myIntTarget.set_emissiveColor
ColorInterpolator { eventIn SFFloat set_fraction exposedField MFFloat key [] exposedField MFColor keyValue [] eventOut SFColor value_changed
}
Alterando Cor - ColorInterpolator
Valores iguais garantem continuidade entre ciclos
![Page 137: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/137.jpg)
CoordinateInterpolator { eventIn SFFloat set_fractionexposedField MFFloat key []exposedField MFVec3f keyValue []eventOut MFVec3f value_changed
}
Alterando Vértices - CoordinateInterpolator
#VRML V2.0 utf8DEF mySensor TimeSensor { cycleInterval 30 loop TRUE } DEF myInterpolator CoordinateInterpolator{ key [0, 0.2, 0.4, 0.6, 0.8, 1] keyValue [1 1 0,-1 1 0,-1 -1 0,1 -1 0,2 2 0,-2 2 0,-1 -1 0,1 -1 0 3 3 0,-3 3 0,-2 -2 0,2 -2 0,2 2 0,-2 2 0,-3 -3 0,3 -3 0 1 1 0,-1 1 0,-2 -2 0,2 -2 0,1 1 0,-1 1 0,-1 -1 0,1 -1 0]}Shape {geometry IndexedFaceSet { coord DEF myIntTarget Coordinate {point[1 1 0,-1 1 0,-1 -1 0,1 -1 0]} coordIndex [0 1 2 3 -1] } }ROUTE mySensor.fraction_changed TO myInterpolator.set_fraction ROUTE myInterpolator.value_changed TO myIntTarget.set_point
Valores iguais garantem continuidade entre ciclos
![Page 138: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/138.jpg)
NormalInterpolator { eventIn SFFloat set_fraction exposedField MFFloat key [] exposedField MFVec3f keyValue [] eventOut MFVec3f value_changed
}
Alterando Normais - NormalInterpolator
#VRML V2.0 utf8DEF mySensor TimeSensor { cycleInterval 30 loop TRUE } DEF myInterpolator NormalInterpolator{ key [0, 0.25, 0.5, 0.75, 1] keyValue [0 0 1,0 1 0, 0 0 -1,0 -1 0,0 1 0, 0 0 -1, 0 -1 0, 0 0 1, 0 0 -1, 0 -1 0, 0 0 1, 0 1 0,0 -1 0, 0 0 1, 0 1 0, 0 0 -1, 0 0 1, 0 1 0, 0 0 -1,0 -1 0 ] }Shape {appearance Appearance {material Material {diffuseColor 1 0 0}} geometry IndexedFaceSet { coord Coordinate {point[1 1 0,-1 1 0,-1 -1 0,1 -1 0]} coordIndex [0 1 2 3 -1] normal DEF myIntTarget Normal{vector[0 0 1,0 0 -1,0 1 0 ,0 -1 0]} normalPerVertex TRUE normalIndex [ 0 1 2 3 -1] } }ROUTE mySensor.fraction_changed TO myInterpolator.set_fraction ROUTE myInterpolator.value_changed TO myIntTarget.set_vector
Valores iguais garantem continuidade entre ciclos
![Page 139: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/139.jpg)
OrientationInterpolator { eventIn SFFloat set_fraction exposedField MFFloat key [] exposedField MFRotation keyValue [] eventOut SFRotation value_changed }
Alterando Orientação - OrientationInterpolator
#VRML V2.0 utf8DEF mySensor TimeSensor { cycleInterval 30 loop TRUE} DEF myInterpolator OrientationInterpolator{ key [0, 0.25, 0.5, 0.75, 1] keyValue [1 1 0 0,1 1 0 1.57,1 1 0 3.14,1 1 0 4.71,1 1 0 6.28] }DEF myIntTarget Transform { children Shape { appearance Appearance {material Material {diffuseColor 1 1 1} } geometry Cone {} } }ROUTE mySensor.fraction_changed TO myInterpolator.set_fraction ROUTE myInterpolator.value_changed TO myIntTarget.set_rotation
Valores diferentes, mas com rotações relativas iguais garantem a continuidade entre ciclos
![Page 140: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/140.jpg)
PositionInterpolator { eventIn SFFloat set_fractionexposedField MFFloat key []exposedField MFVec3f keyValue []eventOut SFVec3f value_changed
}
Alterando Posição- PositionInterpolator
#VRML V2.0 utf8DEF mySensor TimeSensor { cycleInterval 10 loop TRUE } DEF myInterpolator PositionInterpolator{ key [0, 0.2, 0.4, 0.6, 0.8, 1] keyValue [0 0 0,1 0 0,0 1 0,-1 0 0,0 -1 0, 0 0 0] }DEF myIntTarget Transform { children Shape { appearance Appearance {material Material {diffuseColor 1 1 1} } geometry Cylinder {} } }ROUTE mySensor.fraction_changed TO myInterpolator.set_fraction ROUTE myInterpolator.value_changed TO myIntTarget.set_translation
Valores iguais garantem continuidade entre ciclos
![Page 141: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/141.jpg)
ScalarInterpolator { eventIn SFFloat set_fractionexposedField MFFloat key []exposedField MFFloat keyValue []eventOut SFFloat value_changed
}
Alterando Escalares - ScalarInterpolator
#VRML V2.0 utf8DEF mySensor TimeSensor { cycleInterval 5 loop TRUE } DEF myInterpolator ScalarInterpolator{ key [0, 0.5, 1] keyValue [0, 0.9, 0] }Shape {geometry Box {size 3 3 0.1} }Shape {appearance Appearance { material DEF myIntTarget Material {diffuseColor 0 1 1} }
geometry Sphere {} }ROUTE mySensor.fraction_changed TO myInterpolator.set_fraction ROUTE myInterpolator.value_changed TO myIntTarget.set_transparency
Valores iguais garantem continuidade entre ciclos
![Page 142: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/142.jpg)
Alteram o estado do mundo Organizados em pilhas Somente o de cima da pilha é utilizado para alterar o mundo. São eles:
Background Fog NavigationInfo Viewpoint
Utilidades Mudança do avatar e da navegação do usuário Mudança do ambiente do mundo (nível de neblina, cores de background) Movimentar usuário entre pontos de vista
Nós de Atuação Singular - Bindable
![Page 143: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/143.jpg)
Funcionamento Nó ativado (bound) vai para cima da pilha
• Recebe TRUE em set_bind• Emite TRUE em isBound
Nó anteriormente ativado fica embaixo• Emite FALSE em isBound
Set_bind = FALSE remove nó da pilha. Se for o ativado:• Emite FALSE em isBound• É removido da pilha• Nó abaixo é ativado
Nós de Atuação Singular - Bindable cont.
![Page 144: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/144.jpg)
Exemplo:
Nós de Atuação Singular - Bindable cont.
#VRML V2.0 utf8DEF mySensor TimeSensor { cycleInterval 5 loop TRUE } Viewpoint { position 0 0 10 description "inicial"}DEF myInterpolator OrientationInterpolator{ key [0, 0.5, 1] keyValue [0 1 0 0,0 1 0 3.14,0 1 0 6.28] }Shape { appearance Appearance { material Material {diffuseColor 0.8 0 0} } geometry Box {size 5 0.1 5} }DEF myIntTarget Transform { children [ DEF myTouchSensor TouchSensor {} Shape {geometry Box {}} DEF boxView Viewpoint {position 0 3 0 orientation 1 0 0 -0.78 description "caixa"} ] }ROUTE mySensor.fraction_changed TO myInterpolator.set_fraction ROUTE myInterpolator.value_changed TO myIntTarget.set_rotationROUTE myTouchSensor.isActive TO boxView.set_bind
![Page 145: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/145.jpg)
Script { exposedField MFString url [] field SFBool directOutput FALSE Field SFBool mustEvaluate FALSE #E mais quantos quiser desses campos: eventIn Type? eventInName field Type? fieldName default value?eventOut Type? eventOutName
} Criação de um nó com quaisquer campos Possbilita integração com linguagens como Javascript e Java
Inserindo código - Script
![Page 146: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/146.jpg)
Exemplo:
Inserindo código - Script cont.
#VRML V2.0 utf8DEF mySensor TimeSensor { cycleInterval 5 loop TRUE } DEF outView Viewpoint { position 0 0 10 description "inicial"}DEF myInterpolator OrientationInterpolator{key [0, 0.5, 1] keyValue [0 1 0 0,0 1 0 3.14,0 1 0 6.28] }Group { children [DEF myTouchSensor2 TouchSensor {} Shape { appearance Appearance {material Material {diffuseColor 0.8 0 0} } geometry Box {size 5 0.1 5} } ] }
DEF myIntTarget Transform { children [DEF myTouchSensor TouchSensor {} Shape {geometry Box {}} DEF boxView Viewpoint {position 0 3 0 orientation 1 0 0 -0.78 description "caixa"} ] }DEF myScript Script { eventIn SFBool input eventOut SFBool output field SFBool boolValue TRUE url "javascript: function input(value, time){ if(value==boolValue)output = TRUE;}"} DEF myScript2 Script { eventIn SFBool input eventOut SFBool output field SFBool boolValue TRUE url "javascript:function input(value, time){ if(value==boolValue)output = TRUE;}"}ROUTE mySensor.fraction_changed TO myInterpolator.set_fraction ROUTE myInterpolator.value_changed TO myIntTarget.set_rotationROUTE myTouchSensor.isActive TO myScript.inputROUTE myScript.output TO boxView.set_bindROUTE myTouchSensor2.isActive TO myScript2.inputROUTE myScript2.output TO outView.set_bind
![Page 147: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/147.jpg)
Switch { exposedField MFNode choice []exposedField SFInt32 whichChoice -1
} Diferentes representações para uma mesma entidade Versões invisíveis continuam ativas Como obter valores inteiros?
Mudança de Conteúdo – Switch
![Page 148: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/148.jpg)
Exemplo:
Mudança de Conteúdo – Switch cont.
#VRML V2.0 utf8DEF myScript Script { eventIn SFTime touchTime field SFInt32 number 4 eventOut SFInt32 output url "javascript: function initialize() {output = 0;} function touchTime(value, time) { if (output == number - 1) output = 0; else ++output;}" }Group { children [ DEF mySensor TouchSensor {}DEF mySwich Switch { whichChoice 0 choice [ Shape {geometry Box {}} Shape {geometry Sphere {}} Shape {geometry Cone {}} Shape {geometry Cylinder {}} ] } ] }
ROUTE mySensor.touchTime TO myScript.touchTimeROUTE myScript.output TO mySwich.whichChoice
![Page 149: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/149.jpg)
LOD { exposedField MFNode level [] field SFVec3f center 0 0 0 field MFFloat range []
}
Níveis de Detalhe – LOD
#VRML V2.0 utf8LOD { range [10 20] level [ Inline {url "cadeiraBemDetalhada.wrl"} Inline {url "cadeiraDetalhada.wrl"} Inline {url "cadeiraSemDetalhes.wrl"} ]}
Diferentes representações para uma mesma entidade
Mudança de representações de acordo com distância do usuário
![Page 150: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/150.jpg)
Linguagem oficial de VRML (Javascript 1.0) Variáveis
Não precisam ter tipos nem valores definidos Podem mudar de tipo!
Uso em VRMLScript {url “javascript: (código)” ou
“myScript.js”} Tipos/Valores básicos
Undefined Null Boolean
Codificação básica - ECMAScript
StringNumberObject
![Page 151: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/151.jpg)
Sintaxe e estrutura semelhante à Java “;” no fim de sentenças
Operadores Unários:-, !, ++, --, typeof Binários: =, -, *, /, % Relacionais: <, <=, >, >=, ==, != Lógicos: &&, ||
Estruturas if(){}else{} ou a?b:c; while(){} for(;;){} arrays: MFString, MFVect3F, MFNode
Codificação básica - ECMAScript cont.
![Page 152: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/152.jpg)
Funções Básicas initialize() shutDown() eventsProcessed() Funções de processamento de eventos
Exemplo:
Codificação básica - ECMAScript cont.
#VRML V2.0 utf8Script { eventIn SFInt32 input eventOut SFInt32 output field SFInt32 mult field SFInt32 result url “javascript: function initialize() { mult = 2; } function input (value, time) {result = value*mult;} function eventsProcessed(){output = result;} function shutDown(){result = mult =0;}”}
![Page 153: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/153.jpg)
ObjetosCriação
• function Vector() { this.x = 0; this.y = 0; this.z = 0; }
Instanciação• myVector1 = new Vector(); • myVector2 = new Vector(1,2,3);
Adição de atributos• myVector2.name = “vetorNinja";
Criação de Métodos• function vectorMultiply(scalar) { this.x *= scalar; this.y *= scalar; this.z *= scalar; } • function Vector() { this.x = 0; this.y = 0; this.z = 0; this.multiply = vectorMultiply; } Exemplo de chamada: myVector2.multiply(a);
Codificação básica - ECMAScript cont.
![Page 154: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/154.jpg)
Objetos VRMLObjetos ECMAScript pré-definidosMapeiam tipos em VRML, adicionando funcionalidades
• SFFloat, SFInt32, SFTime -> Number• SFBool -> Boolean• SFSTRING -> String• ...
Exemplos de funções em objetos ECMAScript• Vector: produto escalar, produto vetorial, tamanho normalização;• Array: tamanho, conversão para String;
Procurar referências de objetos antes de programar!
Codificação básica - ECMAScript cont.
![Page 155: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/155.jpg)
Browser ObjectPermite modificar o mundo virtual e a relação
entre seus objetos Métodos Browser.getName() Browser.getVersion() Browser.getWorldURL() Browser.getCurrentFrameRate() Browser.getCurrentSpeed() Browser.setDescription(string description) Browser.loadURL(MFString url, MFString parameter) Browser.replaceWorld(MFNode nodes) Browser.createVrmlFromString(String string) Browser.createVrmlFromURL(MFString url, SFNode node, String eventIn) Browser.addRoute(SFNode fromNode, String fromEventOut, SFNode toNode,
String toEventIn) Browser.deleteRoute(SFNode fromNode, String fromEventOut, SFNode
toNode, String toEventIn)
Codificação básica - ECMAScript cont.
LEGENDA(campos do nó Script a ativar):•Script.directOutput = TRUE•Script.mustEvaluate = TRUE •Nenhum do dois
![Page 156: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/156.jpg)
VRML permite uso de chamada a classes Java Passos para se gerar uma classe Java compatível
com o nó Script de VRML1. Importa pacote VRML de Java; 2. Classe deve estender classe Script;3. Atrela variáveis do nó Script a variáveis da classe Java; 4. Processa/Captura-se eventos recebidos de VRML;5. Processa os dados...;6. Atribui resultados às variáveis atreladas a eventOut;7. Adiciona localização das classes VRML do navegador VRML
no CLASSPATH;8. Gera o “.class”;9. Adiciona-o ao campo url do nó Script.
Codificação Avançada - Java
![Page 157: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/157.jpg)
Exemplo: gerador de ondas senoidais Objetivo
Transformar sinal de um TimeSensor em valores de seno
Codificação Avançada - Java
TimeSensor
fraction_changed
Script
fraction_changed
set_fraction
Interpolador
set_...
#VRML V2.0 utf8DEF myTimer TimeSensor { cycleInterval 5 loop TRUE startTime 0 stopTime -1 } DEF myScript Script { eventIn SFFloat set_fraction eventOut SFFloat fraction_changed field SFFloat amplitude 1 url “GeraSeno.class" }ROUTE myTimer.fraction_changed TO myScript.set_fraction
![Page 158: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/158.jpg)
Exemplo: GeraSeno.java
Codificação Avançada - Java cont.
import vrml.*; import vrml.node.*; import vrml.field.*;
public class SineGen extends Script {
private SFFloat fraction_changed; private SFFloat amplitude;
public void initialize() { fraction_changed = (SFFloat) getEventOut("fraction_changed"); amplitude = (SFFloat) getField("amplitude"); }
public void processEvent (Event e) { if (e.getName().equals("set_fraction")) { sine((ConstSFFloat)e.getValue()); } }
private void sine (ConstSFFloat fraction) { double result = Math.sin(fraction.getValue() * Math.PI * 2); result *= amplitude.getValue(); fraction_changed.setValue((float)result); }
}
1. Pacotes VRML
2. Extensão de Script
3. Atrelamento entre variáveis
4. Processamento de eventos
5. Processamento de dados
5. Resultados passados para EventOut
![Page 159: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/159.jpg)
Exemplo: Gerando o .class Modifica o classpath
• set CLASSPATH=C:\Arquivos de programas\Arquivos comuns\ParallelGraphics\Cortona\classes.zip;
Gera o class• javac -target 1.1 GeraSeno.java
Adiciona o nome do “.class” ao nó Script• DEF myScript Script {
eventIn SFFloat set_fraction eventOut SFFloat fraction_changed field SFFloat amplitude 1 url “GeraSeno.class"
}
Codificação Avançada - Java
![Page 160: VRML Virtual Reality Modeling Language INTRODUÇÃO AO VRML Márcio Bueno ( masb@cin.ufpe.br ) 09 de maio de 2005 Atualizada por Paulo Gonçalves de Barros.](https://reader037.fdocumentos.com/reader037/viewer/2022103113/552fc16a497959413d8ebb05/html5/thumbnails/160.jpg)
Referências
Transparências comentadas!! Floppy’s VRML 97 Tutorial:
http://web3d.vapourtech.com/tutorials/vrml97/ Web 3D Consortium – VRML Archives
http://www.web3d.org/x3d/vrml/index.html Funções de ECMAScript:
http://www.web3d.org/x3d/specifications/ISO-IEC-19777-FCD-X3dLanguageBindings/Part1/functions.html