Matemática e Computação
 

Nada, jamais, substituirá o companheiro perdido. Velhos camaradas não se criam. Estas amizades não se refazem: ao plantar um carvalho, é vã a esperança de poder gozar brevemente da sua sombra. (Saint-Exupéry)

 

 

Exemplo 56: Animação de um cilindro dentro de um tubo ( outro cilindro )

#VRML V2.0 utf8

Background {
     skyColor 1 1 0
}
Transform {
     rotation 0 0 1 -1.57
     children [
          DEF ES Transform {
          #     translation 0 0.1 0
               children Shape {
                    appearance Appearance {
                         material Material{
                              diffuseColor 0 1 0
                              transparency 0.8
                         }
                    }
                    geometry Cylinder {
                         height 8.3
                         radius 0.55
                    }
               }
          }
          DEF ES Transform {
#               translation -4 0 0
               children Shape {
                    appearance Appearance {
                         material Material{
                              diffuseColor 0 0 1
                              transparency 0.3
                         }
                    }
                    geometry Cylinder {
                         height 0.5
                         radius 0.5
                    }
               }
          }
          DEF PI PositionInterpolator {
               key [0 0.25 0.5 0.75 1]
               keyValue [0 0 0, 0 -4.0 0, 0 0 0, 0 4.0 0, 0 0 0]
          }
          DEF OI OrientationInterpolator {
               key [0 0.25 0.50 0.75 1]
               keyValue [0 0 1 0, 0 0 1 -3.14, 0 0 1 -6.28, 0 0 1 -3.14, 0 0 1 0]
          }
          DEF SI PositionInterpolator{
               key [ 0 0.25 0.5 0.75 1 ]
               keyValue [      1 0.01 1 1 0.5 1 1 1 1 ]
          }
          DEF TS TimeSensor {
                loop TRUE
                cycleInterval 12
          }
          DEF Touch TouchSensor {}
     ]
}
#ROUTE Touch.touchTime TO TS.startTime
ROUTE TS.fraction_changed TO PI.set_fraction
ROUTE PI.value_changed TO ES.translation
#ROUTE TS.fraction_changed TO OI.set_fraction
#ROUTE OI.value_changed TO ES.rotation
#ROUTE TS.fraction_changed TO SI.set_fraction
#ROUTE SI.value_changed TO ES.scale

 

Exemplo 57: - Animação da Esfera com a transformação escala ( aumento do raio de 1 para 5 )

DEF BALL Transform {
.....children[
..........Shape {
...............appearance Appearance {
....................material Material {
.........................transparency 0.5
.........................diffuseColor 1 0 1
....................}
...............}
...............geometry Sphere {
....................radius 1
...............}
..........}
.....]
}

DEF TIMER TimeSensor {
.....cycleInterval 5
.....loop TRUE
}

DEF SIZER PositionInterpolator{
.....key [
..........0  0.5  1
.....]
.....keyValue [
..........0 0 0   5 5 5   0 0 0
.....]
}

ROUTE TIMER.fraction_changed TO SIZER.set_fraction
ROUTE SIZER.value_changed TO BALL.scale