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
                                   }

6.8.5 - Múltiplos Interpolatores

Exemplo 70: Translação, rotação e escalonamento.

Background {
       skyColor 0.3 0.5 0
}
DEF tr Transform {
       children [
              DEF No1 Shape {
                     appearance DEF Verd Appearance {
                            material DEF mat1 Material {
                                   diffuseColor .286 .502 .675
                                   specularColor .235 .298 .196
                                   emissiveColor .357 .325 .725
                            }
                     }
                     geometry Cylinder {
                            radius 0.1
                            height 3.2
                     }
              }
              DEF No2 Shape {
                     appearance DEF Azul Appearance {
                            material DEF mat2 Material {
                                   diffuseColor 0 0 .965
                                   specularColor .831 .592 .349
                                   emissiveColor .216 .267 .592
                            }
                            texture ImageTexture {
                                   url "C:/Meu Site/Imagens/Imagem96.jpg"
                            }
                     }
                     geometry Sphere {
                            radius 0.1
                     }
              }
              DEF No3 Shape {
                     appearance DEF Verm Appearance {
                            material DEF mat3 Material {
                                   diffuseColor 1 .275 .118
                                   specularColor .157 .471 .784
                                   emissiveColor .0745 .353 .588
                            }
                            texture ImageTexture {
                                   url "C:/Meu Site/Imagens/SarahBrightman.JPG"
                            }
                     }
                     geometry Sphere {
                            radius 0.2
                     }
              }
              Transform {
                     rotation 0 0 1 1.57
                     children USE No1
              }
              Transform {
                     rotation 1 0 0 1.57
                     children USE No1
              }
              Transform {
                     translation 0 2 0
                     scale 5 5 5
                     children USE No2
              }
              Transform {
                     translation 0 0 0
                     scale 5 5 5
                     children USE No3
              }
              Transform {
                     translation 0 -2 0
                     scale 5 5 5
                     children USE No2
              }
              Transform {
                     translation 2 0 0
                     scale 5 5 5
                     children USE No2
              }
              Transform {
                     translation -2 0 0
                     scale 5 5 5
                     children USE No2
              }
              Transform {
                     translation 0 0 -2
                     scale 5 5 5
                     children USE No2
              }
              Transform {
                     translation 0 0 2
                     scale 5 5 5
                     children USE No2
              }
              DEF pi PositionInterpolator {
                     key [ 0 0.25 0.5 0.75 1]
                     keyValue [ 5 0 0, -5 0 0, 0 4 0, 0 -4 0, 5 0 0]
              }
              DEF pi2 PositionInterpolator {
                     key [ 0 0.25 0.5 0.75 1]
                     keyValue [ 1 1 1, 2 1 1, 3 0.5 1, 2 1 1, 1 1 1]
              }
              DEF ts TimeSensor {
                     cycleInterval 16
                     loop TRUE
              }
              DEF oi2 OrientationInterpolator {
                     key [ 0 1 ]
                     keyValue [ 0 1 0 0,
                     0 1 0 3.14, # rotate right
                     0 0 1 6.28] # rotate down
              }
              DEF ts2 TimeSensor {
                     cycleInterval 6
                     loop TRUE
              }
       ]
}
ROUTE ts.fraction_changed TO pi.set_fraction
ROUTE pi.value_changed TO tr.set_translation
ROUTE ts2.fraction_changed TO oi2.set_fraction
ROUTE oi2.value_changed TO tr.set_rotation
ROUTE ts.fraction_changed TO pi2.set_fraction
ROUTE pi2.value_changed TO tr.scale

Exemplo 71: Sistema planetário.

Viewpoint {
      position 0 0 30
}
Transform {
      # rotation 1 0 0 -1.57
      children [
            Group {
                  children [
                        # Stationary Sun
                        Shape {
                              appearance DEF White Appearance {
                                    material Material {
                                          diffuseColor .773 .514 0
                                          specularColor .651 1 .839
                                          emissiveColor .78 .255 0
                                          ambientIntensity .00333
                                          shininess .12
                                    }
                              }
                              geometry Sphere {radius 0.5}
                        },
                        # Several orbiting planets
                        DEF Planet1 Transform {
                              translation 2.0 0.0 0.0
                              center -2.0 0.0 0.0
                              children Shape {
                                    appearance Appearance {
                                          material Material {
                                                diffuseColor .21 .02 .06
                                                specularColor .94 .58 .55
                                                emissiveColor .1 .01 .03
                                                ambientIntensity .00333
                                                shininess .1
                                          }
                                    }
                                    geometry Sphere { radius 0.2 }
                              }
                        },
                        DEF Planet2 Transform {
                              translation 4.0 0.0 0.0
                              center -4.0 0.0 0.0
                              children Shape {
                                    appearance Appearance {
                                          material Material {
                                                diffuseColor 0 .33 .45
                                                specularColor 0 .52 .83
                                                emissiveColor 0 .06 .1
                                                ambientIntensity .04
                                                shininess .12
                                          }
                                    }
                                    geometry Sphere { radius 0.3 }
                              }
                        },
                        DEF Planet3 Transform {
                              translation 6.0 0.0 0.0
                              center -6.0 0.0 0.0
                              children Shape {
                                    appearance Appearance {
                                          material Material {
                                                diffuseColor .733 0 .098
                                                specularColor 1 .424 .278
                                                emissiveColor .537 .122 .102
                                                ambientIntensity .00333
                                                shininess .1
                                          }
                                    }
                                    geometry Sphere { radius 0.25 }
                              }
                        },
                        DEF Planet4 Transform {
                              translation 8.0 0.0 0.0
                              center -8.0 0.0 0.0
                              children Shape {
                                    appearance Appearance {
                                          material Material {
                                                diffuseColor .41 .39 .03
                                                specularColor .941 .722 0
                                                emissiveColor .294 .298 .118
                                                ambientIntensity .00667
                                                shininess .12
                                          }
                                    }
                                    geometry Sphere { radius 0.15 }
                              }
                        },
                        DEF Planet5 Transform {
                              translation 10.0 0.0 0.0
                              center -9.0 0.0 0.0
                              children Shape {
                                    appearance Appearance {
                                          material Material {
                                                diffuseColor .23 .5 0
                                                specularColor .741 .741 .729
                                                emissiveColor .408 .404 .196
                                                ambientIntensity .0533
                                                shininess .12
                                          }
                                    }
                                    geometry Sphere { radius 0.18 }
                              }
                        },
                        DEF Planet6 Transform {
                              translation 15.0 0.0 0.0
                              center -12.0 0.0 0.0
                              children Shape {
                                    appearance Appearance {
                                          material Material {
                                                diffuseColor .0118 .361 .4
                                                specularColor 1 .91 .38
                                                emissiveColor .306 .31 .318
                                                ambientIntensity .05
                                                shininess .12
                                          }
                                    }
                                    geometry Sphere { radius 0.22 }
                              }
                        },
                        # Animation clocks, one per planet
                        DEF Clock1 TimeSensor {
                              cycleInterval 3.0
                              loop TRUE
                        },
                        DEF Clock2 TimeSensor {
                              cycleInterval 4.0
                              loop TRUE
                        },
                        DEF Clock3 TimeSensor {
                              cycleInterval 5.0
                              loop TRUE
                        },
                        DEF Clock4 TimeSensor {
                              cycleInterval 6.0
                              loop TRUE
                        },
                        DEF Clock5 TimeSensor {
                              cycleInterval 8.0
                              loop TRUE
                        },
                        DEF Clock6 TimeSensor {
                              cycleInterval 10.0
                              loop TRUE
                        },
                        # Animation paths, one per planet
                        DEF PlanetPath1 OrientationInterpolator {
                              key [ 0.0, 0.50, 1.0 ]
                              keyValue [
                                    0.0 0.0 1.0 0.0,
                                    0.0 0.0 1.0 3.14,
                                    0.0 0.0 1.0 6.28
                              ]
                        },
                        DEF PlanetPath2 OrientationInterpolator {
                              key [ 0.0, 0.50, 1.0 ]
                              keyValue [
                                    0.0 0.0 1.0 0.0,
                                    0.0 0.0 1.0 3.14,
                                    0.0 0.0 1.0 6.28
                              ]
                        },
                        DEF PlanetPath3 OrientationInterpolator {
                              key [ 0.0, 0.50, 1.0 ]
                              keyValue [
                                    0.0 0.0 1.0 0.0,
                                    0.0 0.0 1.0 3.14,
                                    0.0 0.0 1.0 6.28
                              ]
                        }
                        DEF PlanetPath4 OrientationInterpolator {
                              key [ 0.0, 0.50, 1.0 ]
                              keyValue [
                                    0.0 0.0 1.0 0.0,
                                    0.0 0.0 1.0 3.14,
                                    0.0 0.0 1.0 6.28
                              ]
                        }
                        DEF PlanetPath5 OrientationInterpolator {
                              key [ 0.0, 0.50, 1.0 ]
                              keyValue [
                                    0.0 0.0 1.0 0.0,
                                    0.0 0.0 1.0 3.14,
                                    0.0 0.0 1.0 6.28
                              ]
                        }
                        DEF PlanetPath6 OrientationInterpolator {
                              key [ 0.0, 0.50, 1.0 ]
                              keyValue [
                                    0.0 0.0 1.0 0.0,
                                    0.0 0.0 1.0 3.14,
                                    0.0 0.0 1.0 6.28
                              ]
                        }
                  ]
            }
      ]
}
ROUTE Clock1.fraction_changed TO PlanetPath1.set_fraction
ROUTE Clock2.fraction_changed TO PlanetPath2.set_fraction
ROUTE Clock3.fraction_changed TO PlanetPath3.set_fraction
ROUTE Clock4.fraction_changed TO PlanetPath4.set_fraction
ROUTE Clock5.fraction_changed TO PlanetPath5.set_fraction
ROUTE Clock6.fraction_changed TO PlanetPath6.set_fraction
ROUTE PlanetPath1.value_changed TO Planet1.set_rotation
ROUTE PlanetPath2.value_changed TO Planet2.set_rotation
ROUTE PlanetPath3.value_changed TO Planet3.set_rotation
ROUTE PlanetPath4.value_changed TO Planet4.set_rotation
ROUTE PlanetPath5.value_changed TO Planet5.set_rotation
ROUTE PlanetPath6.value_changed TO Planet6.set_rotation