Matemática e Computação
 

Mensagens
Não te abandones em lugares onde a luz da tua harmonia não esteja presente.

 


8 - Textura e Textos

O VRML 2.0 permite que você use imagens, filmes e imagens definidas para texturizar suas formas. Ao texturizar uma forma a textura é aplicada por defaut a cada uma das faces da forma.

A seguinte figura mostra um exemplo usando uma textura sobre todas as formas primitivas:

Podemos também especificar neste nó se a textura deve ser repetida para cada uma das faces da forma. A seguinte figura mostra um exemplo para uma única face quadrada usando a mesma imagem que acima como textura.

Como você pode ver do exemplo acima a imagem pode ser repetida verticalmente, horizontalmente ou não. Há ainda mais, você pode transladar, e girar a textura como a figura seguinte mostra.

A imagem é transladada , e a textura é girada finalmente de 90 graus (recorde que no VRML os ângulos estão medidos em radianos, a rotação usada em radianos é de 1.5708).

No exemplos a seguir os números das imagens é ajustado em 1 1, 4 1, 1 4, 4 4 e 8 4 em ambas as dimensões.

     

      

Uma textura é representada em um sistema de coordenadas 2-D onde cada ponto (s,t) tem suas coordenadas s e t variando de 0 a 1.

As operações geométricas mencionadas acima, a escala, a translação e a rotação, são aplicadas neste sistema de coordenadas.

8.1 - Nó ImageTexture

Este nó especifica a posição da imagem a ser usada para texturizar a forma, como também se a imagem deve ser repetida verticalmente, ou horizontalmente, ao longo de cada uma das faces da forma.

Três campos estão presentes neste nó:

      URL - que especifica a posição da imagem. Os formatos válidos da imagem são JPEG, GIF e png. Você pode especificar posições múltiplas se você desejar, o browser procurará dados naquelas posições em ordem decrescente de preferência.

      repetS - o qual especifica se a imagem deve ser repetida verticalmente.

      repeatT - que especifica se a imagem deve ser repetida horizontalmente.

Todos os campos são opcionais, os valores de defaut que estão sendo aplicados nos campos não foram especificados.

Nota: se você não especificar a posição da imagem, na URL, então nenhuma texturia ocorre.

Syntaxdo nó ImageTexture:

ImageTexture {
        url [ ]
        repeatS TRUE
        repeatT TRUE
}

8.1.1 - textureTransform - define mudanças na textura do material. Este nó permite que você execute transformações geométricas simples, escala, rotação, e a translação, em coordenadas da textura.

Syntaxdo nó textureTransform :

textureTransform TextureTransform {
        center 1 2
        rotation 1.57
        scale 3 4
        translation 2 4
}

Os valores do campo center especificam o ponto central em relação ao qual a rotação e a escala ocorrem. Quando todos os campos são usados na combinação então as coordenadas especificadas no nó de TextureCoordinate são escaladas primeiramente, giradas em relação ao ponto center, e transladadas finalmente.

Os seguintes formatos devem ser reconhecidos por browsers de VRML: JPEG, JPG e GIF.

Exemplo 136: Exemplos de ImageTexture

Shape {
     appearance DEF Textura1 Appearance {
          material Material {
          }
          texture ImageTexture {
               url "Textura01.JPG"
          }
          textureTransform TextureTransform {
          }
     }
}
Transform {
     children [
          Shape {
               appearance USE Textura1
               geometry Box {
                    size 2 2 0.1
               }
          }
     ]
}

Exemplo 137: Repetir o exercício anterior com

Shape {
     appearance DEF Textura1 Appearance {
          material Material {
          }
          texture ImageTexture {
               url "Textura01.JPG"
               repeatS TRUE

               repeatT TRUE

          }
          textureTransform TextureTransform {
               scale 4  1

          }
     }
}
Transform {
     children [
          Shape {
               appearance USE Textura1
               geometry Box {
                    size 6  6  0.1
               }
          }
     ]
}

Exemplo 138: Exemplos de ImageTexture

Shape {
     appearance DEF Textura1 Appearance {
          material Material {
          }
          texture ImageTexture {
               url "Textura01.JPG"
               repeatS TRUE

               repeatT TRUE

          }
          textureTransform TextureTransform {
               scale 1  4

          }
     }
}
Transform {
     children [
          Shape {
               appearance USE Textura1
               geometry Box {
                    size 6  6  0.1
               }
          }
     ]
}

Exemplo 139: Repetir o exempolo anterior com

               scale 4  4

Exemplo 140: Repetir o exempolo anterior com

               scale 8  4

               size 12   6  0.1

Exemplo 141: Repetir o exempolo anterior com

Shape {
     appearance DEF Textura1 Appearance {
          material Material {
          }
          texture ImageTexture {
               url "Textura01.JPG"
          }
          textureTransform TextureTransform {
#               rotation 1.5708

          }
     }
}
Shape {
     appearance DEF Textura2 Appearance {
          material Material {
          }
          texture ImageTexture {
               url "Textura01.JPG"
          }
          textureTransform TextureTransform {
               rotation 1.5708

          }
     }
}
Shape {
     appearance DEF Textura3 Appearance {
          material Material {
          }
          texture ImageTexture {
               url "Textura01.JPG"
          }
          textureTransform TextureTransform {
               rotation 3.1416

          }
     }
}
Shape {
     appearance DEF Textura4 Appearance {
          material Material {
          }
          texture ImageTexture {
               url "Textura01.JPG"
          }
          textureTransform TextureTransform {
               rotation -1.5708

          }
     }
}
Transform {
     translation -1 -1 0
     children [
          Shape {
               appearance USE Textura1
               geometry Box {
                    size 2 2 0.1
               }
          }
     ]
}
Transform {
     translation -1  1 0
     children [
          Shape {
               appearance USE Textura2
               geometry Box {
                    size 2 2 0.1
               }
          }
     ]
}
Transform {
     translation  1  1 0
     children [
          Shape {
               appearance USE Textura3
               geometry Box {
                    size 2 2 0.1
               }
          }
     ]
}
Transform {
     translation  1 -1 0
     children [
          Shape {
               appearance USE Textura4
               geometry Box {
                    size 2 2 0.1
               }
          }
     ]
}

Exemplo 142: ImageTexture com Texto

Viewpoint {
        description "Text texture test"
        position 1.3 0 5
}
NavigationInfo {
        type [ "EXAMINE" "ANY" ]
}
Shape {
        appearance Appearance {
                texture ImageTexture {
                        url [ "Textura02.jpg" ]
                }
        }
        geometry Text {
                string [ "VRML" " 20052" ]
                fontStyle FontStyle {
                        style "BOLD"
                }
        }
}

Exemplo 143:Cilindro com ImageTexture diferentes em cada face

Background {
        skyColor 1 1 0
}
Shape {
        appearance Appearance {
                material Material {
                        diffuseColor 0 1 0
                }
                texture ImageTexture {
                        url ["Textura02.jpg"]
                        repeatS TRUE
                        repeatT TRUE
                }
        }
        geometry Cylinder {
                bottom TRUE
                side FALSE
                top FALSE
                height 3
                radius 1
        }
}
Shape {
        appearance Appearance {
                material Material {
                        diffuseColor 0 1 0
                }
                texture ImageTexture {
                        url ["Textura08.jpg"]
                        repeatS TRUE
                        repeatT TRUE
                }
        }
        geometry Cylinder {
                bottom FALSE
                side TRUE
                top FALSE
                height 3
                radius 1
        }
}
Shape {
        appearance Appearance {
                material Material {
                        diffuseColor 0 1 0
                }
                texture ImageTexture {
                        url ["Textura05.jpg"]
                        repeatS TRUE
                        repeatT TRUE
                }
        }
        geometry Cylinder {
                bottom FALSE
                side FALSE
                top TRUE
                height 3
                radius 1
        }
}

Exemplo 144: Duplicação da ImageTexture em cada face

Shape {
        appearance Appearance {
                material Material {
                        diffuseColor 0 1 0
                }
                texture ImageTexture {
                        url ["Textura06.jpg"]
                        repeatS TRUE
                        repeatT TRUE
                }
                textureTransform TextureTransform {
                        scale 4 4
                }
        }
        geometry Box {
                size 3 3 3
        }
}

Exemplo 145: Duplicação da ImageTexture em cada face com rotação de 45 graus.

Shape {
        appearance Appearance {
                material Material {
                        diffuseColor 0 1 0
                }
                texture ImageTexture {
                        url ["Textura06.jpg"]
                        repeatS TRUE
                        repeatT TRUE
                }
                textureTransform TextureTransform {
                        scale 4 4
                        rotation 0.785
                }
        }
        geometry Box {
                size 3 3 3
        }
}