Matemática e Computação
 

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

 

 

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