// Initialisation runtime.setCurrentTool( runtime.TOOL_NAME_SPIN ); Lecture =0; // Initialisation des jauges MatriceID = new Matrix4x4(); MatriceID.setIdentity(); PVH = scene.meshes.getByName("JaugePVH"); PVS = scene.meshes.getByName("JaugePVS"); function Jauge(facteurPVHZ,facteurPVSZ){ MatriceDeTransformationPVH = new Matrix4x4(); MatriceDeTransformationPVH = MatriceDeTransformationPVH.scale(1,1,facteurPVHZ);//ScalePVH).translate(PostionPVH0); PVH.transform.set(MatriceDeTransformationPVH); MatriceDeTransformationPVS = new Matrix4x4(); MatriceDeTransformationPVS = MatriceDeTransformationPVS.scale(1,1,facteurPVSZ); PVS.transform.set(MatriceDeTransformationPVS); }; PVH.renderMode="illustration"//"shaded illustration";//"solid outline"; PVS.renderMode="illustration"//"solid outline"; function InitJauges(Jauge){ Jauge.transform.set(MatriceID); } Heure = 6; // initialisation du temps absolu Soleil = scene.meshes.getByName("Soleil"); // Recuperation de l objet Soleil TranslationSoleil = new Vector3(Soleil.transform.translation); //background nuit myImageResourceNight = new Resource("pdf://moon1.png"); myImageNight = null; myImageNight = new Image(myImageResourceNight); //background jour myImageResourceDay = new Resource("pdf://day.png"); myImageDay = null; myImageDay = new Image(myImageResourceDay); //background milieu myImageResourceMid = new Resource("pdf://daystartend.png"); myImageMid = null; myImageMid = new Image(myImageResourceMid); // Recuperation des objets contenu dans le dossier Panneaux et de leurs positions initiales NombrePanneauxHeliostatiques = 126; // entrer le nombre de panneaux DossierPanneaux = new Array(); PositionOriginePanneaux = new Array(); //utilité ? DossierPanneaux[0] = scene.nodes.getByName("Panneaux").firstChild; PositionOriginePanneaux[0] = DossierPanneaux[0].transform.translation; for (i=1; i soleil PositionDeLaCible = cible.transform.translation; PositionDuPanneau = Panneau.transform.translation; VecteurNormal = new Vector3(PositionDeLaCible.x-PositionDuPanneau.x,PositionDeLaCible.y-PositionDuPanneau.y,PositionDeLaCible.z-PositionDuPanneau.z); VecteurNormal.normalize(); return VecteurNormal; } function CalculDuVecteurNormalRetour(Panneau,AngleRetour){ PositionDeLaCibleRetour = new Vector3(0,-150*Math.cos(AngleRetour),150*Math.sin(AngleRetour)); PositionDuPanneau = Panneau.transform.translation; VecteurNormal = new Vector3(PositionDeLaCibleRetour.x-PositionDuPanneau.x,PositionDeLaCibleRetour.y-PositionDuPanneau.y,PositionDeLaCibleRetour.z-PositionDuPanneau.z); VecteurNormal.normalize(); return VecteurNormal; } function CalculDeLAngleRotation(Panneau){ AngleDeRotation = VecteurNormal.dot(new Vector3(0,0,1)); if (AngleDeRotation > Math.PI/6){ AngleDeRotation = Math.PI/6; } else {if (AngleDeRotation < -Math.PI/6){ AngleDeRotation = -Math.PI/6; } return AngleDeRotation; } } function CalculDuVecteurNormalReel(Panneau){ VecteurNormalReel = new Vector3(0,0,1); MatriceDuPanneau = Panneau.transform VecteurNormalReel = MatriceDuPanneau.transformDirection(VecteurNormalReel); VecteurNormalReel.normalize(); return VecteurNormalReel; } function CalculDeLAngleIncident(Panneau){ AngleDeRotationIncident = VecteurNormal.dot(VecteurNormalReel); AngleDeRotationIncident = Math.abs(- AngleDeRotationIncident + Math.PI/2) - 33*Math.PI/180 ; return AngleDeRotationIncident; } function CalculDuVecteurRotation(Panneau){ VecteurRotation = new Vector3(0,0,1).cross(VecteurNormal); return VecteurRotation; } function CalculDeLaTransformationDuPanneau(Panneau){ MatriceDeTransformation = new Matrix4x4(); // MatriceDeTransformation = Panneau.transform; MatriceDeTransformation = MatriceDeTransformation.rotateAboutVector(AngleDeRotation,VecteurRotation); //MatriceDeTransformation = MatriceDeTransformation.rotateAboutVector(-Math.PI/2,new Vector3(0,0,1)); ScalePanneau = ((Panneau.transform.scaleComponent.x,Panneau.transform.scaleComponent.y,Panneau.transform.scaleComponent.z)); MatriceDeTransformation = MatriceDeTransformation.scale(ScalePanneau).translate(PositionOriginePanneaux[i]); // MatriceDeTransformation = Panneau.transform; MatriceDeTransformation; } function AttributionDeLaTransformationDuPanneau(Panneau){ Panneau.transform.set(MatriceDeTransformation); } function RandomVector(){ var V3 = new Vector3(Math.random(),Math.random(),Math.random()); return V3; } function Tracking(){ for (i=0; i< NombrePanneauxHeliostatiques; i++){ CalculDuVecteurNormal( DossierPanneaux[i],Soleil ); CalculDeLAngleRotation( DossierPanneaux[i] ); CalculDuVecteurRotation( DossierPanneaux[i] ); CalculDeLaTransformationDuPanneau( DossierPanneaux[i] ); AttributionDeLaTransformationDuPanneau( DossierPanneaux[i] ); } } function TrackingInverse(AngleRetour){ for (i=0; i< NombrePanneauxHeliostatiques; i++){ CalculDuVecteurNormalRetour( DossierPanneaux[i],AngleRetour ); // Soleil ???? quel Objet? CalculDeLAngleRotation( DossierPanneaux[i] ); CalculDuVecteurRotation( DossierPanneaux[i] ); CalculDeLaTransformationDuPanneau( DossierPanneaux[i] ); AttributionDeLaTransformationDuPanneau( DossierPanneaux[i] ); } } function CalculDelAngleIncidentPanneauxStatiques(){ CalculDuVecteurNormal( DossierPanneaux[1],Soleil ); VecteurNormalReelPanneauStatique = new Vector3(0,696.9,717.2); VecteurNormalReelPanneauStatique.normalize(); AnglePanneauStatique = VecteurNormalReelPanneauStatique.dot(VecteurNormal); //host.getField("AngleStaticoMoy").value = Math.round(Math.PI/2*180/Math.PI - Math.abs(AnglePanneauStatique*180/Math.PI))+"Degres"; host.getField("AngleStaticoMoy").value = 90 - Math.round(Math.abs(AnglePanneauStatique*180/Math.PI))+"Degres"; return AnglePanneauStatique; } function CalculDelAngleIncidentPanneaux(){ SommeIncidence = 0; for (i=0; i0){ AngleSolaire = -Math.acos((new Vector3(0,0,1)).dot(VecteurPositionSoleil))//+Math.PI; } else { AngleSolaire = Math.acos((new Vector3(0,0,1)).dot(VecteurPositionSoleil)); } Heure = ((-AngleSolaire % (2*Math.PI))*24/(2*Math.PI)+12) //% 24; IncidenceStatique = AngleSolaire; if (Math.round(Heure) == 24 & declencheurJour == 1){ Jour++; declencheurJour = 0; } if (Math.round(Heure) == 12){ declencheurJour = 1; } } // Animation des vehicules PositionOrigineCAR1 = new Vector3(scene.meshes.getByName("car1").transform.translation); PositionOrigineCAR2 = new Vector3(scene.meshes.getByName("car1").transform.translation); function AnimationCAR1(distance) { var VehiculeObjet = scene.meshes.getByName("car1"); var Light1 = scene.lights.getByName("car1_PhareDroit"); var Light2 = scene.lights.getByName("car1_phareGauche"); VehiculeObjet.transform.translateInPlace(new Vector3(distance,0,0)); Light1.transform.translateInPlace(new Vector3(distance,0,0)); Light2.transform.translateInPlace(new Vector3(distance,0,0)); PositionVehicule = new Vector3(VehiculeObjet.transform.translation) if (PositionVehicule.x < 50 | PositionVehicule.x > 2400) { VehiculeObjet.visible=false; } else (VehiculeObjet.visible=true); return PositionVehicule } function AnimationCAR2(distance) { var VehiculeObjet = scene.meshes.getByName("car2"); var Light1 = scene.lights.getByName("car2_phareGauche"); var Light2 = scene.lights.getByName("car2_PhareDroit"); VehiculeObjet.transform.translateInPlace(new Vector3(distance,0,0)); Light1.transform.translateInPlace(new Vector3(distance,0,0)); Light2.transform.translateInPlace(new Vector3(distance,0,0)); PositionVehicule = new Vector3(VehiculeObjet.transform.translation) if (PositionVehicule.x < 150 | PositionVehicule.x > 2500) { VehiculeObjet.visible=false; } else (VehiculeObjet.visible=true); return PositionVehicule } VitesseCar1=-8; VitesseCar2=9; function Vivant(){ //animation de l eolienne scene.meshes.getByName("rotor").transform.rotateAboutXInPlace(0.08); Vent = 0; AnimationCAR1(VitesseCar1); if (scene.meshes.getByName("car1").transform.translation.x < -150 ) { scene.meshes.getByName("car1").transform.translateInPlace((new Vector3(3000,0,0)));//.subtract(new Vector3((scene.meshes.getByName("car1").transform.translation.X,0,0))); scene.lights.getByName("car1_PhareDroit").transform.translateInPlace((new Vector3(3000,0,0))); scene.lights.getByName("car1_phareGauche").transform.translateInPlace((new Vector3(3000,0,0))); RandomColor("car1"); VitesseCar1=(-3*Math.random()-8); } AnimationCAR2(VitesseCar2); if (scene.meshes.getByName("car2").transform.translation.x > 2500 ){ scene.meshes.getByName("car2").transform.translateInPlace((new Vector3(-3000,0,0)))//.subtract(new Vector3((scene.meshes.getByName("car2").transform.translation.X,0,0))); scene.lights.getByName("car2_phareGauche").transform.translateInPlace((new Vector3(3000,0,0))); scene.lights.getByName("car2_PhareDroit").transform.translateInPlace((new Vector3(3000,0,0))); RandomColor("car2") ; VitesseCar2=(3*Math.random()+9); } } function Play(){ if (Heure > 6.5 & Heure < 17){ Tracking();// creer animation statique de la journée CalculDelAngleIncidentPanneaux(DossierPanneaux); CalculDelAngleIncidentPanneauxStatiques(); } else { TrackingInverse((-MyTimer+Math.PI));// creer animation statique de la nuit host.getField("AngleHelioMoy").value = "low power"; host.getField("AngleStaticoMoy").value = "low power"; }; } function CourseDuSoleil(Angle,Objet){ //SOLEIL MatrixSoleil = new Matrix4x4(); ScaleSoleil = ((Objet.transform.scaleComponent.x,Objet.transform.scaleComponent.y,Objet.transform.scaleComponent.z)); MatrixSoleil = MatrixSoleil.scale(ScaleSoleil).translate(new Vector3(1441.97,1500+4*TranslationSoleil.y*Math.cos(Angle),-4*TranslationSoleil.y*Math.sin(Angle))); //MatrixSoleil = MatrixSoleil.rotateAboutVector(Angle,new Vector3(1,0,0)); Objet.transform.set(MatrixSoleil); //~ Objet.transform.rotateAboutXInPlace(Angle); //~ Objet.transform.rotateAboutLineInPlace(Angle,(new Vector3(-2541,2541,000)),(new Vector3(2541,2541,000))); } // Declaration des animations Temps = 0; MyTimer = 0; CoefficientVitesse = 1; CoefficientCorrectif = 0.1; Stop =0; HideHelp = function(event){ host.getField("Helpnotice").hidden=true; } HideHelpOnMouseDown = new MouseEventHandler(); HideHelpOnMouseDown.onMouseDown = true; HideHelpOnMouseDown.onEvent = HideHelp; runtime.addEventHandler(HideHelpOnMouseDown); ScalePVH=0; ScalePVS=0; Animation = new TimeEventHandler(); Animation.onEvent = function(event){ if (Lecture ==1 & Stop ==0){ Temps += event.deltaTime*CoefficientVitesse*CoefficientCorrectif; MyTimer = ((Temps) % Math.PI*2 ); TheTime(); host.getField("the_time").value = Jour+"Day"+Math.round(Heure)+"h";//+Math.round(((10*Heure) % 10 *(60/100))/10); CourseDuSoleil(MyTimer,Soleil); Play(); host.getField("runtime.deltaTime").value = event.deltaTime//+" "+; host.getField("runtime.time").value = event.time; if (Heure > 6.5 & Heure < 17){ ScalePVH += (Math.PI/2 - Math.abs(IncidenceHelioStatique))/20; ScalePVS += (Math.PI/2 - Math.abs(IncidenceStatique))/20; Jauge(ScalePVH,ScalePVS) ; } }; if (Stop ==1){ ScalePVH = 1; ScalePVS = 1; Jauge(ScalePVH,ScalePVS); Jour = 0; Temps = 0; MyTimer = 0; CourseDuSoleil(MyTimer,Soleil); TheTime(); host.getField("the_time").value = Jour+"Day"+Math.round(Heure)+"h";//+Math.round(((10*Heure) % 10 *(60/100))/10); CourseDuSoleil(MyTimer,Soleil); Play(); } Vivant(); } runtime.addEventHandler(Animation); //load with eventHandler Ambience = new RenderEventHandler(); Ambience.onEvent = function(event) { if (Heure > 5.5 & Heure < 7){ scene.lightScheme = "night"; event.canvas.background.setImage(myImageMid); } else { if (Heure > 7 & Heure < 17.5){ scene.lightScheme = "cad"; event.canvas.background.setImage(myImageDay); } else { if (Heure > 17.5 & Heure < 19){ scene.lightScheme = "night"; event.canvas.background.setImage(myImageMid); } else { scene.lightScheme = "file"; event.canvas.background.setImage(myImageNight); } } } } runtime.addEventHandler(Ambience); // ASSEMBLAGE CODE 2 runtime.setCurrentTool( runtime.TOOL_NAME_SPIN ); DossierTrees = new Array(); DossierTrees[0] = scene.nodes.getByName("trees").firstChild; for (childCountTrees = 1 ; childCountTrees < scene.meshes.count ; childCountTrees++){ if (DossierTrees[childCountTrees-1].nextSibling.toString() != "[object Mesh]") break; else { DossierTrees[childCountTrees]=DossierTrees[childCountTrees-1].nextSibling; //console.println(DossierTrees[childCountTrees]) } } DossierTrees[childCountTrees]= scene.meshes.getByName("label_solar"); DossierTrees[childCountTrees+1]= scene.meshes.getByName("label_static"); DossierPanneauxHelio = new Array(); DossierPanneauxHelio[0] = scene.nodes.getByName("Panneaux").firstChild; for (childCountPanneauxHelio = 1 ; childCountPanneauxHelio < 126 ; childCountPanneauxHelio++){ //~ if (DossierPanneauxHelio[childCountTrees-1].nextSibling.toString() != "[object Mesh]") //~ break; //~ else { DossierPanneauxHelio[childCountPanneauxHelio]=DossierPanneauxHelio[childCountPanneauxHelio-1].nextSibling; //console.println(DossierPanneauxHelio[childCountTrees]) //~ } } DossierPanneauxStatics = new Array(); DossierPanneauxStatics[0] = scene.nodes.getByName("PanneauxStatics").firstChild; for (childCountPanneauxStatics = 1 ; childCountPanneauxStatics < 62 ; childCountPanneauxStatics++){ //~ if (DossierPanneauxHelio[childCountTrees-1].nextSibling.toString() != "[object Mesh]") //~ break; //~ else { DossierPanneauxStatics[childCountPanneauxStatics]=DossierPanneauxStatics[childCountPanneauxStatics-1].nextSibling; //console.println(DossierPanneauxHelio[childCountTrees]) //~ } } // Couleurs des vehicules aleatoires function RandomColor(vehicule) { var Color = new Vector3(); var x = Math.random(); var y = Math.random(); var z = Math.random(); //console.println(scene.materials.getByName(vehicule).name+Color); scene.materials.getByName(vehicule).diffuseColor.set3(x,y,z); } //This tells Acrobat to disable the default 3D object selection behaviour. runtime.overrideSelection = true; //------------------------------------------------------------------------------ //This will be called when a MouseUp event fires //------------------------------------------------------------------------------ var myMouseHandlingFunction = function( event ) { { clickedMesh = null; //The Hits array actually contains every object that is intersected by //a ray from the Camera in the direction of the mouse click. //We want the first one; the one closest to the camera. if(event.hits.length > 0) clickedMesh = event.hits[0].target; if (clickedMesh == scene.meshes.getByName("target_solar_field")) { for (var i=0; i < childCountPanneauxHelio ; i++){ DossierPanneauxHelio[i].renderMode="shaded illustration"; } scene.meshes.getByName("label_solar").visible=true; scene.meshes.getByName("label_solar").renderMode="illustration"; scene.meshes.getByName("cadre1").visible=true; } else { for (var i=0; i < childCountPanneauxHelio ; i++){ DossierPanneauxHelio[i].renderMode="solid"; } scene.meshes.getByName("label_solar").visible=false; scene.meshes.getByName("cadre1").visible=false; } if (clickedMesh == scene.meshes.getByName("target_static")) { for (var i=0; i < childCountPanneauxStatics ; i++){ DossierPanneauxStatics[i].renderMode="shaded illustration"; } scene.meshes.getByName("label_static").visible=true; scene.meshes.getByName("label_static").renderMode="illustration"; scene.meshes.getByName("cadre2").visible=true; } else { { for (var i=0; i < childCountPanneauxStatics ; i++){ DossierPanneauxStatics[i].renderMode="solid"; } scene.meshes.getByName("label_static").visible=false; scene.meshes.getByName("cadre2").visible=false; } //console.println(clickedMesh.name); { var VecteurCameraXPositonCam =((scene.cameras.getByIndex(0).targetPosition.x)-(scene.cameras.getByIndex(0).position.x)); var VecteurCameraYPositonCam =((scene.cameras.getByIndex(0).targetPosition.y)-(scene.cameras.getByIndex(0).position.y)); var VecteurCameraZPositonCam =((scene.cameras.getByIndex(0).targetPosition.z)-(scene.cameras.getByIndex(0).position.z)); if ((VecteurCameraYPositonCam>0 & VecteurCameraXPositonCam>0) | (VecteurCameraYPositonCam<0 & VecteurCameraXPositonCam>0)) { AngleCamPositonCam=Math.atan((VecteurCameraYPositonCam/VecteurCameraXPositonCam))+Math.PI; } else AngleCamPositonCam=Math.atan((VecteurCameraYPositonCam/VecteurCameraXPositonCam)); for (var i=0; i < childCountTrees+2 ; i++){ m1 = new Matrix4x4().rotateAboutZ(Math.abs(AngleCamPositonCam+Math.PI/2)); t1 = new Vector3(DossierTrees[i].transform.translation); if (i