Matemática e Computação
 

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

 


7.4 – Luzes no ambiente VRML

Em geral os objetos são iluminados pela soma de todas as luzes da cena que os afetam. Isto inclui a contribuição tanto da iluminação direta como da ambiente das fontes de luz.

Existem três tipos de luzes em VRML:

PointLight - luzes pontuais que irradiam em todas as direções a partir de um ponto; têm uma posição no espaço;

PointLight {
       on TRUE
       intensity 1
       ambientIntensity 0
       color 1 1 1
       location 0 0 0
       attenuation 1 0 0
       radius 100
}

PointLight {
       on TRUE ( habilita ou desabilita )
       intensity 1 ( entre 0 e 1 )
       ambientIntensity 0 ( entre 0 e 1 )
       color 1 1 1 ( especifica a cor )
       direction 0 0 1 ( especifica a direção )
       location 0 0 0 ( especifica a posição )
       radius 100 ( especifica o raio de ação )
}

Exemplo 79: Iluminação PointLight

PointLight {
      
on FALSE          # luz vermelha não habilitada
      
location 0 10 0
      
color 1 0 0 # luz vermelha
      
intensity 1
}
PointLight {
      
on TRUE
      
location 10 0 0
      
color 0 1 0 # luz verde
      
intensity 1
}

Shape {
       appearance Appearance {
              material Material {
                     diffuseColor 0.5 0.5 0.0
              }
       }
       geometry Box { }
}

Exemplo 80: Iluminação PointLight

PointLight {
      
on TRUE         # luz vermelha habilitada
      
location 0 10 0
      
color 1 0 0 # luz vermelha
      
intensity 1
}
PointLight {
      
on TRUE
      
location 10 0 0
      
color 0 1 0 # luz verde
      
intensity 1
}

Shape {
       appearance Appearance {
              material Material {
                     diffuseColor 0.5 0.5 0.0
              }
       }
       geometry Box { }
}

Exemplo 81: Iluminação PointLight (luz vermelha e verde na mesma face = luz amarela)

PointLight {
      
on TRUE         # luz vermelha
      
location 10 0 0
      
color 1 0 0 # luz vermelha
      
intensity 1
}
PointLight {
      
on TRUE
      
location 10 0 0
      
color 0 1 0 # luz verde
      
intensity 1
}

Shape {
       appearance Appearance {
              material Material {
                     diffuseColor 0.5 0.5 0.0
              }
       }
       geometry Box { }
}

Exemplo 82: Iluminação PointLight (luz vermelha e verde na mesma face = luz amarela)

PointLight {
     on TRUE
     location 0 0 0
     color 0 0 1 # luz azul
     intensity 1
}
PointLight {
     on TRUE
     location 0 0 0
     color 0 1 0 # luz verde
     intensity 1
}

Transform {
     translation 4 0 0
     children [
          DEF Esfera Shape {
               appearance Appearance {
                    material Material {
                         diffuseColor 0.5 0.5 0.0
                    }
               }
               geometry Sphere { }
          }
     ]
}
Transform {
     translation 0 4 0
     children USE Esfera
}
Transform {
     translation 0 -4 0
     children USE Esfera
}
Transform {
     translation -4 0 0
     children USE Esfera
}
Transform {
     translation 0 0 -4
     children USE Esfera
}

Exemplo 83: Iluminação PointLight (luz vermelha e verde na mesma face = luz amarela)

NavigationInfo {
     headlight FALSE
     type "EXAMINE"
}
Transform {
     translation -5 0 0
     children [
          PointLight {
               color 1 1 0
               intensity 1
               ambientIntensity 0.5
               location 0 0 0
               radius 5
               attenuation 0 1 0
          }
          DEF SPHERETHING Group {
               children [
                    Transform {
                         translation 0 1 0
                         children [
                              DEF SPHERE Shape {
                                   appearance Appearance {
                                        material Material {
                                             diffuseColor 1 1 1
                                        }
                                   }
                                   geometry Sphere {
                                        radius 0.5
                                   }
                              }
                         ]
                    }
                    Transform {
                         translation 0 2 0
                         children [
                              USE SPHERE
                         ]
                    }
                    Transform {
                         translation 0 3 0
                         children [
                              USE SPHERE
                         ]
                    }
                    Transform {
                         translation 0 -1 0
                         children [
                              USE SPHERE
                         ]
                    }
                    Transform {
                         translation 0 -2 0
                         children [
                              USE SPHERE
                         ]
                    }
                    Transform {
                         translation 0 -3 0
                         children [
                              USE SPHERE
                         ]
                    }
               ]
          }
          Transform {
               rotation 0 0 1 1.57
               children [
                    USE SPHERETHING
               ]
          }
     ]
}
Transform {
     translation 5 0 0
     children [
          PointLight {
               color 0 0 1
               intensity 1
               ambientIntensity 0.5
               location 0 0 0
               radius 5
               attenuation 0 0 1
          }
          USE SPHERETHING
          Transform {
               rotation 0 0 1 1.57
               children [
                    USE SPHERETHING
               ]
          }
     ]
}