Matemática e Computação
 

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

 

 

6.8.2- OrientationInterpolator

Exemplo 63: Rotação de uma Esfera em torno do seu eixo.

      DEF TR Transform {
            children [
                  Shape {
                        appearance Appearance {
                              material DEF mat Material { diffuseColor 1 0 0 }
                        }
                        geometry Sphere {}
                  }
                  DEF OI OrientationInterpolator {
                        key [ 0 1 ]
                        keyValue [ 0 1 0 0,     0 1 0 3.14,     0 0 1 3.14  ] 
                  }
                  DEF TS TimeSensor {
                        cycleInterval 4
                        loop TRUE
                  }
            ]
      }
      ROUTE TS.fraction_changed TO OI.set_fraction
      ROUTE OI.value_changed TO TR.set_rotation

Exemplo 64: Rotação de um Cubo em várias direções.

DEF tr Transform {
       children [
              Shape {
                     appearance Appearance {
                            material DEF mat Material { diffuseColor 1 0 0 }
                            texture ImageTexture {
                                   url ["C:/Sites/Imagens/Imagem50.jpg"]
                            }
                     }
                     geometry Box {}
              }
              DEF OI OrientationInterpolator {
                     key [ 0 0.125 0.25 0.375 0.50 0.625 0.75 0.875 1 ]
                     keyValue [ 1 0 0 0
                                    1 0 0 1.57,
                                    0 1 0 1.57,
                                    0 0 1 1.57,
                                    1 1 0 1.57,
                                    1 0 1 1.57,
                                    0 1 1 1.57,
                                    1 0 0 1.57]
              }
              DEF TS TimeSensor {
                     cycleInterval 16
                     loop TRUE
              }
       ]
}
ROUTE TS.fraction_changed TO OI.set_fraction
ROUTE OI.value_changed TO TR.set_rotation

Exemplo 65: Rotação de um Grupo em direções diferentes.

       DEF tr Transform {
              children [
                     Shape {
                            appearance Appearance {
                                   material DEF mat Material { diffuseColor 1 0 0 }
                               }
                            geometry Sphere {}
                     }
                     Transform {
                            translation 2 0 0
                            children [
                                   Shape {
                                          appearance Appearance {
                                                 material Material {
                                                        diffuseColor 1 0 1
                                                 }
                                          }
                                          geometry Cylinder {
                                                 radius 1
                                                 height 2
                                          }
                                   }
                            ]
                     }
                     Transform {
                            translation 0 2 0
                            children [
                                   Shape {
                                          appearance Appearance {
                                                 material Material {
                                                        diffuseColor 0 0 1
                                                 }
                                          }
                                          geometry Cone {
                                                 bottomRadius 1
                                                 height 2
                                          }
                                   }
                            ]
                     }
                     DEF OI OrientationInterpolator {
                            key [ 0 0.25 0.5 0.75 1 ]
                            keyValue [ 1 0 0 3.14,
                                           0 1 0 3.14,
                                           0 0 1 3.14,
                                           1 0 0 3.14,
                                           1 0 0 3.14 ]
                     }
                     DEF TS TimeSensor {
                            cycleInterval 6
                            loop TRUE
                     }
              ]
       }
       ROUTE ts.fraction_changed TO oi.set_fraction
       ROUTE oi.value_changed TO tr.set_rotation

6.8.3 - ColorInterpolator

Exemplo 66: Interpolação de cores em uma esfera.

       Background {
              skyColor 1 1 0 }
       Shape {
              appearance Appearance {
                     material DEF Cor Material {
                            diffuseColor 0 0 1
                     }
              }

              geometry Sphere {
                     radius 2
              }
       }

       DEF TS TimeSensor {
              loop TRUE
              cycleInterval 5
       }

       DEF CI ColorInterpolator {
              key[ 0   0.25   0.50   0.75   1 ]
              keyValue [ 1 0 1 0 1 1 1 0 1 1 1 0 1 0 1 ] # end keyValue
       }

       ROUTE TS.fraction_changed TO CI.set_fraction
       ROUTE colorChanger.value_changed TO Cor.diffuseColor
       ROUTE colorChanger.value_changed TO Cor.emissiveColor
       ROUTE colorChanger.value_changed TO Cor.specularColor

Exemplo 67: Interpolação de cores em uma esfera com Sensor de toque.

       Group {
             
children [
                    
Shape {
                           
appearance Appearance {
                                  
material DEF Cor Material {
                                         
diffuseColor 1 0 1
                                  
}
                           
}

                           
geometry Sphere {
                                  
radius 2
                           
}
                    
}

                    
DEF ToS TouchSensor {
                           
enabled TRUE
                    
}
             
]
      
}

      
DEF timer TimeSensor {
             
loop FALSE
             
cycleInterval 10
      
}

      
DEF colorChanger ColorInterpolator {
             
key[ 0   0.33   0.66   1 ]
             
keyValue [ 1 0 0    0 1 0    0 0 1    1 0 1 ]
      
} # end colorChanger

      
ROUTE toucher.touchTime TO timer.startTime
      
ROUTE timer.fraction_changed TO colorChanger.set_fraction
       ROUTE colorChanger.value_changed TO Cor.diffuseColor
       ROUTE colorChanger.value_changed TO Cor.emissiveColor
       ROUTE colorChanger.value_changed TO Cor.specularColor


6.8.4 - ScaleInterpolator

Exemplo 68: Interpolação escalar em um cubo.

       Group {
              children [
                     DEF Bola Transform {
                            children Shape {
                                   appearance Appearance {
                                          material Material {
                                                 diffuseColor 1 0 0
                                          }
                                   }
                                   geometry Box {
                                          size 2 2 2
                                   }
                            }
                     }
                     DEF TS TimeSensor {
                            loop TRUE
                            cycleInterval 10
                     }
                     DEF SI PositionInterpolator {
                            key[ 0    0.25    0.50    0.75    1 ]
                            keyValue [ 1 1 1    1 2 1    1 3 1     1 2 1    1 1 1 ]
                     }
              ]
       }
       ROUTE TS.fraction_changed TO SI.set_fraction
       ROUTE SI.value_changed TO Bola.set_scale

Exemplo 69: Interpolação escalar em uma esfera.

                                   geometry Sphere {
                                          radius 2
                                   }