#VRML V2.0 utf8 #anne midenet ######################### # le chni ######################### #-------------------------------------------- # les points de vue #-------------------------------------------- DEF VUE_DE_FACE Viewpoint { position 0 1.8 15 orientation 0 0 0 0 description "vue de face" } DEF VUE_D_EN_HAUT Viewpoint { position 0 20 0 orientation 1 0 0 4.7 description "vue d'en haut" } #-------------------------------------------- # la navigation #-------------------------------------------- DEF WALK_NAVIGATION NavigationInfo { type ["WALK", "ANY"] } DEF FLY_NAVIGATION NavigationInfo { type ["FLY", "ANY"] } ######################### # les protos ######################### #-------------------------------------------- # la montagne # ici un simple cone #-------------------------------------------- PROTO Montagne [ field SFVec3f position 0 0 0 field SFFloat hauteur 0 field SFFloat rayon_montagne 0 ] { Transform { translation IS position children [ Shape { appearance Appearance { material Material { diffuseColor 1 0 0 } } geometry Cone { bottomRadius IS rayon_montagne height IS hauteur side TRUE bottom TRUE } } ] } } #-------------------------------------------- # une courbe de niveau # ici un simple cylindre #-------------------------------------------- PROTO Courbe [ field SFFloat rayon 0 field SFVec3f niveau 0 0 0 ] { Transform { translation IS niveau children [ Shape { appearance Appearance { material Material { diffuseColor 1 1 1 } } geometry Cylinder { radius IS rayon height 0.05 side TRUE bottom FALSE top FALSE } } ] } } #-------------------------------------------- # les boutons #-------------------------------------------- PROTO Bouton [ exposedField MFString nom_du_bouton ["undefd"] field SFVec3f position_du_bouton 0 0 0 field SFColor couleur_du_bouton 0 0.43617 0.29533 field SFVec3f taille_du_bouton 0.7 0.2 0.1 eventOut SFTime instant_bouton_touche ] { Transform { translation IS position_du_bouton children [ DEF TS TouchSensor { touchTime IS instant_bouton_touche } # this paints a Box (10cm behind the text) Transform { translation 0 0 -0.1 children Shape { appearance Appearance { material DEF MAT Material { ambientIntensity 0 diffuseColor IS couleur_du_bouton specularColor 0 0 0 emissiveColor 0 0 0 shininess 0 transparency 0 } } geometry Box { size IS taille_du_bouton } } } # This paints the text Shape { geometry Text { string IS nom_du_bouton fontStyle FontStyle { justify ["MIDDLE", "MIDDLE"] size 0.2 spacing 1 } length 0 } } DEF highliteScript Script { eventIn SFBool isActive eventIn SFBool isOver eventOut SFFloat shininess eventOut SFColor specularColor url ["vrmlscript: function isOver (value) { if (value == TRUE) { shininess = 1; specularColor[0] = 0.6; specularColor[1] = 0.6; specularColor[2] = 0.6; } else { shininess = 0; specularColor[0] = 0; specularColor[1] = 0; specularColor[2] = 0; } }", "javascript: function isOver (value) { if (value == TRUE) { shininess = 1; specularColor[0] = 0.6; specularColor[1] = 0.6; specularColor[2] = 0.6; } else { shininess = 0; specularColor[0] = 0; specularColor[1] = 0; specularColor[2] = 0; } }"] } ] } ROUTE TS.isOver TO highliteScript.isOver ROUTE highliteScript.shininess TO MAT.shininess ROUTE highliteScript.specularColor TO MAT.specularColor } ######################### # la scene ######################### #-------------------------------------------- # la montagne à taille modulable #-------------------------------------------- DEF MONT Montagne { position 0 2.5 0 rayon_montagne 3 hauteur 5 } ROUTE MONT.rayon_montagne TO DESSINE_COURBES.set_set_courbe ROUTE MONT.hauteur TO DESSINE_COURBES.set_courbe #-------------------------------------------- # les courbes # dessinnees par le script DESSINE_COURBES #-------------------------------------------- DEF UNE_COURBE {} ######################### # les boutons ######################### #-------------------------------------------- # pour dessiner les courbes de niveau #-------------------------------------------- DEF InterfacePos Transform { translation 0 0 0 children [ DEF TheInterface Billboard { axisOfRotation 0 1 0 children [ DEF BOUTON_COURBES Bouton { nom_du_bouton "courbes" position_du_bouton 0 0 10 } ] } } ROUTE BOUTON_COURBES.instant_bouton_touche TO DESSINE_COURBES.set_courbe ######################### # les scripts ######################### #-------------------------------------------- # pour faire apparaître les courbes de niveau #-------------------------------------------- DEF DESSINE_COURBES Script { eventIn SFTime set_courbe eventOut SFFloat rayonCourbe eventOut SFVec3f positionCourbe url ["vrmlscript: float hauteur_montagne = 0.0; float diametre_montagne = 0.0; float intervalle = 0.0; float rayon_courbe = 0.0; int positionYcourbe = 0; int nbre_de_courbes = 0, function set_courbe () { diametre_montagne = MONT.rayon_montagne * 2; hauteur_montagne = MONT.hauteur; intervalle = 1.0; positionYcourbe = intervalle; int i = 0; if ( hauteur_montagne > intervalle) { nbre_de_courbes = (hauteur_montagne / intervalle) - 1; for (i = 1; i < nbre_de_courbes; i++) { rayonCourbe = diametre_montagne - ((hauteur_montagne * positionYcourbe) / diametre_montagne); positionCourbe [0] = 0; positionCourbe [1] = positionYcourbe; positionCourbe [2] = 0; ROUTE DESSINE_COURBES.rayonCourbe TO UNE_COURBE.rayon ROUTE DESSINE_COURBES.positionCourbe TO UNE_COURBE.niveau } } }", "javascript: float hauteur_montagne = 0.0; float diametre_montagne = 0.0; float intervalle = 0.0; float rayon_courbe = 0.0; int positionYcourbe = 0; int nbre_de_courbes = 0, function set_courbe () { diametre_montagne = MONT.rayon_montagne * 2; hauteur_montagne = MONT.hauteur; intervalle = 1.0; positionYcourbe = intervalle; int i = 0; if ( hauteur_montagne > intervalle) { nbre_de_courbes = (hauteur_montagne / intervalle) - 1; for (i = 1; i < nbre_de_courbes; i++) { rayonCourbe = diametre_montagne - ((hauteur_montagne * positionYcourbe) / diametre_montagne); positionCourbe [0] = 0; positionCourbe [1] = positionYcourbe; positionCourbe [2] = 0; ROUTE DESSINE_COURBES.rayonCourbe TO UNE_COURBE.rayon ROUTE DESSINE_COURBES.positionCourbe TO UNE_COURBE.niveau } } }"] }