//Setup all the touch down zone lights. private void SetupTDZLights(ref List <SpriteLights.LightData> lightData, ApproachLightData allApproachLightData, RunwayData runwayData, bool randomBrightness, float brightness, float size) { for (int side = 0; side < 2; side++) { if (runwayData.lightingType[side] != LightingType.NONE) { SvgData[] svgData = allApproachLightData.GetApproachLightData(runwayData.lightingType[side]); //Set TDZ lights. if (runwayData.TDZ[side]) { svgData = allApproachLightData.GetApproachLightData(LightingType.TDZ); for (int i = 0; i < svgData.Length; i++) { if (svgData[i].materialString == whiteDirectionalSinglesideCString) { SpriteLights.LightData data = new SpriteLights.LightData(); Vector3 position = (runwayData.rotation[side] * svgData[i].position) + runwayData.thresholdPosition[side]; data.frontColor = whiteLight; data.brightness = SetBrightness(randomBrightness, brightness); data.position = position; //Set the direction and upward rotation of the light. data.rotation = runwayData.rotation[side] * Quaternion.Euler(Vector3.right * runwayData.lightAngle); data.size = size; lightData.Add(data); } } } } } }
//Setup all the strobe lights. private void SetupStrobeLights(ref List <SpriteLights.LightData> lightData, ApproachLightData allApproachLightData, RunwayData runwayData, float strobeTimeStep) { float groupID = Random.Range(0.0f, 0.99f); for (int side = 0; side < 2; side++) { if (runwayData.lightingType[side] != LightingType.NONE) { SvgData[] svgData = allApproachLightData.GetApproachLightData(runwayData.lightingType[side]); if ((runwayData.strobeType[side] == StrobeType.ODALS) || (runwayData.strobeType[side] == StrobeType.BOTH)) { for (int i = 0; i < svgData.Length; i++) { SpriteLights.LightData data = new SpriteLights.LightData(); Vector3 position = (runwayData.rotation[side] * svgData[i].position) + runwayData.thresholdPosition[side]; if (svgData[i].materialString == strobeCString) { data.position = position; //Set the direction and upward rotation of the light. data.rotation = runwayData.rotation[side] * Quaternion.Euler(Vector3.right * runwayData.lightAngle); data.strobeID = svgData[i].id * strobeTimeStep; data.strobeGroupID = groupID; lightData.Add(data); } } } if ((runwayData.strobeType[side] == StrobeType.REIL) || (runwayData.strobeType[side] == StrobeType.BOTH)) { float distanceOffset = 0; Vector3 sideOffsetDir = Math3d.GetRightVector(runwayData.rotation[side]); //If threshold wing bars are used, the REIL distance must be bigger, otherwise they overlap. if (runwayData.thresholdWingbar[side] == ThresholdWingbar.LARGE) { distanceOffset = 15.5f; } if ((runwayData.thresholdWingbar[side] == ThresholdWingbar.SMALL) || (runwayData.thresholdWingbar[side] == ThresholdWingbar.NONE)) { distanceOffset = 12f; } //Right strobe. Vector3 startOffsetAVec = Math3d.SetVectorLength(sideOffsetDir, (runwayData.width * 0.5f) + distanceOffset); Vector3 position = runwayData.thresholdPosition[side] + startOffsetAVec; SpriteLights.LightData data = new SpriteLights.LightData(); data.position = position; //Set the direction and upward rotation of the light. data.rotation = runwayData.rotation[side] * Quaternion.Euler(Vector3.right * runwayData.lightAngle); //The strobe ID is 0, so it will flash at the same time as all other strobes with ID 0. //The group ID is the same as the walking strobe, so it is synchronized with that. data.strobeID = 0; data.strobeGroupID = groupID; lightData.Add(data); //Left strobe. position = runwayData.thresholdPosition[side] - startOffsetAVec; data = new SpriteLights.LightData(); data.position = position; //Set the direction and upward rotation of the light. data.rotation = runwayData.rotation[side] * Quaternion.Euler(Vector3.right * runwayData.lightAngle); data.strobeGroupID = groupID; lightData.Add(data); } } } }
//Procedurally crate the runway lights. public void CreateRunwayLights() { int index; //Create an array which holds every possible runway. RunwayData[] runways = new RunwayData[2]; bool randomBrightness = false; float brightness = 0.8f; //0.6f float smallerLightSize = 0.7f; //0.8f index = 0; runways[index] = new RunwayData(); runways[index].SetThresholdPosition(new Vector3(0, 0, 0), 3000); runways[index].thresholdHeight[0] = 0; runways[index].thresholdHeight[1] = 0; runways[index].midHeight = 0; runways[index].SetThresholdRotation(0); runways[index].width = 45; runways[index].lightingType[0] = LightingType.ALSF2; runways[index].lightingType[1] = LightingType.ALSF2; runways[index].strobeType[0] = StrobeType.ODALS; runways[index].strobeType[1] = StrobeType.BOTH; runways[index].papiType[0] = PapiType.PAPIBOTH; runways[index].papiType[1] = PapiType.PAPIBOTH; runways[index].centerlineLights = true; runways[index].centerlineLightsSpacing = 15; runways[index].edgeLights = true; runways[index].edgeLightsSpacing = 60; runways[index].thresholdWingbar[0] = ThresholdWingbar.LARGE; runways[index].thresholdWingbar[1] = ThresholdWingbar.LARGE; runways[index].TDZ[0] = true; runways[index].TDZ[1] = true; index = 1; runways[index] = new RunwayData(); runways[index].SetThresholdPosition(new Vector3(200, 0, 0), 3000); runways[index].thresholdHeight[0] = 0; runways[index].thresholdHeight[1] = 0; runways[index].midHeight = 0; runways[index].SetThresholdRotation(0); runways[index].width = 45; runways[index].lightingType[0] = LightingType.ALSF1; runways[index].lightingType[1] = LightingType.ALSF1; runways[index].strobeType[0] = StrobeType.BOTH; runways[index].strobeType[1] = StrobeType.BOTH; runways[index].papiType[0] = PapiType.PAPILEFT; runways[index].papiType[1] = PapiType.PAPILEFT; runways[index].centerlineLights = true; runways[index].centerlineLightsSpacing = 15; runways[index].edgeLights = true; runways[index].edgeLightsSpacing = 60; runways[index].thresholdWingbar[0] = ThresholdWingbar.LARGE; runways[index].thresholdWingbar[1] = ThresholdWingbar.LARGE; runways[index].TDZ[0] = true; runways[index].TDZ[1] = true; /* * index = 2; * runways[index] = new RunwayData(); * runways[index].SetThresholdPosition(new Vector3(400, 0, 0), 2500); * runways[index].thresholdHeight[0] = 0; * runways[index].thresholdHeight[1] = 0; * runways[index].midHeight = 0; * runways[index].SetThresholdRotation(0); * runways[index].width = 40; * runways[index].lightingType[0] = LightingType.SALS; * runways[index].lightingType[1] = LightingType.SALS; * runways[index].strobeType[0] = StrobeType.BOTH; * runways[index].strobeType[1] = StrobeType.BOTH; * runways[index].papiType[0] = PapiType.PAPILEFT; * runways[index].papiType[1] = PapiType.PAPILEFT; * runways[index].centerlineLights = false; * runways[index].centerlineLightsSpacing = 15; * runways[index].edgeLights = true; * runways[index].edgeLightsSpacing = 60; * runways[index].thresholdWingbar[0] = ThresholdWingbar.SMALL; * runways[index].thresholdWingbar[1] = ThresholdWingbar.SMALL; * runways[index].TDZ[0] = false; * runways[index].TDZ[1] = false; * * index = 3; * runways[index] = new RunwayData(); * runways[index].SetThresholdPosition(new Vector3(600, 0, 0), 3000); * runways[index].thresholdHeight[0] = 0; * runways[index].thresholdHeight[1] = 0; * runways[index].midHeight = 0; * runways[index].SetThresholdRotation(0); * runways[index].width = 45; * runways[index].lightingType[0] = LightingType.CALVERT2; * runways[index].lightingType[1] = LightingType.CALVERT2; * runways[index].strobeType[0] = StrobeType.NONE; * runways[index].strobeType[1] = StrobeType.NONE; * runways[index].papiType[0] = PapiType.PAPIBOTH; * runways[index].papiType[1] = PapiType.PAPIBOTH; * runways[index].centerlineLights = true; * runways[index].centerlineLightsSpacing = 15; * runways[index].edgeLights = true; * runways[index].edgeLightsSpacing = 60; * runways[index].thresholdWingbar[0] = ThresholdWingbar.LARGE; * runways[index].thresholdWingbar[1] = ThresholdWingbar.LARGE; * runways[index].TDZ[0] = true; * runways[index].TDZ[1] = true; * * index = 4; * runways[index] = new RunwayData(); * runways[index].SetThresholdPosition(new Vector3(800, 0, 0), 3000); * runways[index].thresholdHeight[0] = 0; * runways[index].thresholdHeight[1] = 0; * runways[index].midHeight = 0; * runways[index].SetThresholdRotation(0); * runways[index].width = 45; * runways[index].lightingType[0] = LightingType.CALVERT1; * runways[index].lightingType[1] = LightingType.CALVERT1; * runways[index].strobeType[0] = StrobeType.NONE; * runways[index].strobeType[1] = StrobeType.NONE; * runways[index].papiType[0] = PapiType.PAPIRIGHT; * runways[index].papiType[1] = PapiType.PAPIRIGHT; * runways[index].centerlineLights = true; * runways[index].centerlineLightsSpacing = 15; * runways[index].edgeLights = true; * runways[index].edgeLightsSpacing = 60; * runways[index].thresholdWingbar[0] = ThresholdWingbar.LARGE; * runways[index].thresholdWingbar[1] = ThresholdWingbar.LARGE; * runways[index].TDZ[0] = true; * runways[index].TDZ[1] = true; */ //Get the strobe timestep variable. strobeTimeStep = InitRunwayLights(runways); //Create temporary lists to store the light data,. List <SpriteLights.LightData> directionalLightData = new List <SpriteLights.LightData>(); List <SpriteLights.LightData> omnidirectionalLightData = new List <SpriteLights.LightData>(); List <SpriteLights.LightData> strobeLightData = new List <SpriteLights.LightData>(); List <SpriteLights.LightData> papiLightData = new List <SpriteLights.LightData>(); ApproachLightData allApproachLightData = new ApproachLightData(); //Get the position and color of the lights from an svg file. allApproachLightData.StoreApproachLightData(); //Loop through all runways. for (int i = 0; i < runways.Length; i++) { //Create the light data and store in a temporary buffer. SetupApproachLights(ref directionalLightData, allApproachLightData, runways[i], randomBrightness, brightness, 1f); SetupTDZLights(ref directionalLightData, allApproachLightData, runways[i], randomBrightness, brightness, smallerLightSize); SetupStrobeLights(ref strobeLightData, allApproachLightData, runways[i], strobeTimeStep); SetupThresholdLights(ref directionalLightData, runways[i], false, 0.6f, 1f); SetupCenterlineLights(ref directionalLightData, runways[i], randomBrightness, brightness, smallerLightSize); SetupEdgeLights(ref omnidirectionalLightData, runways[i], randomBrightness, brightness, 1f); SetupPapiLights(ref papiLightData, runways[i], false); } //Create a parent object. GameObject parentObject = new GameObject("RunwayLights"); //Take all the light data lists and create the actual ligth mesh from it. GameObject[] lightObjects = SpriteLights.CreateLights("Runway directional lights", directionalLightData.ToArray(), directionalLightsMat); MakeChild(parentObject, lightObjects); lightObjects = SpriteLights.CreateLights("Runway omnidirectional lights", omnidirectionalLightData.ToArray(), omnidirectionalRunwayLightsMat); MakeChild(parentObject, lightObjects); lightObjects = SpriteLights.CreateLights("Runway strobe lights", strobeLightData.ToArray(), strobeLightsMat); MakeChild(parentObject, lightObjects); lightObjects = SpriteLights.CreateLights("Runway PAPI lights", papiLightData.ToArray(), papiLightsMat); MakeChild(parentObject, lightObjects); parentObject.transform.position = new Vector3(-2941, 0, 10936); parentObject.transform.rotation = Quaternion.Euler(0, -111.5163f, 0); }
//Setup all the touch down zone lights. private void SetupTDZLights(ref List<SpriteLights.LightData> lightData, ApproachLightData allApproachLightData, RunwayData runwayData, bool randomBrightness, float brightness, float size){ for(int side = 0; side < 2; side++){ if(runwayData.lightingType[side] != LightingType.NONE){ SvgData[] svgData = allApproachLightData.GetApproachLightData(runwayData.lightingType[side]); //Set TDZ lights. if(runwayData.TDZ[side]){ svgData = allApproachLightData.GetApproachLightData(LightingType.TDZ); for(int i = 0; i < svgData.Length; i++){ if(svgData[i].materialString == whiteDirectionalSinglesideCString){ SpriteLights.LightData data = new SpriteLights.LightData(); Vector3 position = (runwayData.rotation[side] * svgData[i].position) + runwayData.thresholdPosition[side]; data.frontColor = whiteLight; data.brightness = SetBrightness(randomBrightness, brightness); data.position = position; //Set the direction and upward rotation of the light. data.rotation = runwayData.rotation[side] * Quaternion.Euler(Vector3.right * runwayData.lightAngle); data.size = size; lightData.Add(data); } } } } } }
//Setup all the strobe lights. private void SetupStrobeLights(ref List<SpriteLights.LightData> lightData, ApproachLightData allApproachLightData, RunwayData runwayData, float strobeTimeStep){ float groupID = Random.Range(0.0f, 0.99f); for(int side = 0; side < 2; side++){ if(runwayData.lightingType[side] != LightingType.NONE){ SvgData[] svgData = allApproachLightData.GetApproachLightData(runwayData.lightingType[side]); if((runwayData.strobeType[side] == StrobeType.ODALS) || (runwayData.strobeType[side] == StrobeType.BOTH)){ for(int i = 0; i < svgData.Length; i++){ SpriteLights.LightData data = new SpriteLights.LightData(); Vector3 position = (runwayData.rotation[side] * svgData[i].position) + runwayData.thresholdPosition[side]; if(svgData[i].materialString == strobeCString){ data.position = position; //Set the direction and upward rotation of the light. data.rotation = runwayData.rotation[side] * Quaternion.Euler(Vector3.right * runwayData.lightAngle); data.strobeID = svgData[i].id * strobeTimeStep; data.strobeGroupID = groupID; lightData.Add(data); } } } if((runwayData.strobeType[side] == StrobeType.REIL) || (runwayData.strobeType[side] == StrobeType.BOTH)){ float distanceOffset = 0; Vector3 sideOffsetDir = Math3d.GetRightVector(runwayData.rotation[side]); //If threshold wing bars are used, the REIL distance must be bigger, otherwise they overlap. if(runwayData.thresholdWingbar[side] == ThresholdWingbar.LARGE){ distanceOffset = 15.5f; } if((runwayData.thresholdWingbar[side] == ThresholdWingbar.SMALL) || (runwayData.thresholdWingbar[side] == ThresholdWingbar.NONE)){ distanceOffset = 12f; } //Right strobe. Vector3 startOffsetAVec = Math3d.SetVectorLength(sideOffsetDir, (runwayData.width * 0.5f) + distanceOffset); Vector3 position = runwayData.thresholdPosition[side] + startOffsetAVec; SpriteLights.LightData data = new SpriteLights.LightData(); data.position = position; //Set the direction and upward rotation of the light. data.rotation = runwayData.rotation[side] * Quaternion.Euler(Vector3.right * runwayData.lightAngle); //The strobe ID is 0, so it will flash at the same time as all other strobes with ID 0. //The group ID is the same as the walking strobe, so it is synchronized with that. data.strobeID = 0; data.strobeGroupID = groupID; lightData.Add(data); //Left strobe. position = runwayData.thresholdPosition[side] - startOffsetAVec; data = new SpriteLights.LightData(); data.position = position; //Set the direction and upward rotation of the light. data.rotation = runwayData.rotation[side] * Quaternion.Euler(Vector3.right * runwayData.lightAngle); data.strobeGroupID = groupID; lightData.Add(data); } } } }
//Procedurally crate the runway lights. public void CreateRunwayLights(){ int index; //Create an array which holds every possible runway. RunwayData[] runways = new RunwayData[2]; bool randomBrightness = false; float brightness = 0.8f; //0.6f float smallerLightSize = 0.7f; //0.8f index = 0; runways[index] = new RunwayData(); runways[index].SetThresholdPosition(new Vector3(0, 0, 0), 3000); runways[index].thresholdHeight[0] = 0; runways[index].thresholdHeight[1] = 0; runways[index].midHeight = 0; runways[index].SetThresholdRotation(0); runways[index].width = 45; runways[index].lightingType[0] = LightingType.ALSF2; runways[index].lightingType[1] = LightingType.ALSF2; runways[index].strobeType[0] = StrobeType.ODALS; runways[index].strobeType[1] = StrobeType.BOTH; runways[index].papiType[0] = PapiType.PAPIBOTH; runways[index].papiType[1] = PapiType.PAPIBOTH; runways[index].centerlineLights = true; runways[index].centerlineLightsSpacing = 15; runways[index].edgeLights = true; runways[index].edgeLightsSpacing = 60; runways[index].thresholdWingbar[0] = ThresholdWingbar.LARGE; runways[index].thresholdWingbar[1] = ThresholdWingbar.LARGE; runways[index].TDZ[0] = true; runways[index].TDZ[1] = true; index = 1; runways[index] = new RunwayData(); runways[index].SetThresholdPosition(new Vector3(200, 0, 0), 3000); runways[index].thresholdHeight[0] = 0; runways[index].thresholdHeight[1] = 0; runways[index].midHeight = 0; runways[index].SetThresholdRotation(0); runways[index].width = 45; runways[index].lightingType[0] = LightingType.ALSF1; runways[index].lightingType[1] = LightingType.ALSF1; runways[index].strobeType[0] = StrobeType.BOTH; runways[index].strobeType[1] = StrobeType.BOTH; runways[index].papiType[0] = PapiType.PAPILEFT; runways[index].papiType[1] = PapiType.PAPILEFT; runways[index].centerlineLights = true; runways[index].centerlineLightsSpacing = 15; runways[index].edgeLights = true; runways[index].edgeLightsSpacing = 60; runways[index].thresholdWingbar[0] = ThresholdWingbar.LARGE; runways[index].thresholdWingbar[1] = ThresholdWingbar.LARGE; runways[index].TDZ[0] = true; runways[index].TDZ[1] = true; /* index = 2; runways[index] = new RunwayData(); runways[index].SetThresholdPosition(new Vector3(400, 0, 0), 2500); runways[index].thresholdHeight[0] = 0; runways[index].thresholdHeight[1] = 0; runways[index].midHeight = 0; runways[index].SetThresholdRotation(0); runways[index].width = 40; runways[index].lightingType[0] = LightingType.SALS; runways[index].lightingType[1] = LightingType.SALS; runways[index].strobeType[0] = StrobeType.BOTH; runways[index].strobeType[1] = StrobeType.BOTH; runways[index].papiType[0] = PapiType.PAPILEFT; runways[index].papiType[1] = PapiType.PAPILEFT; runways[index].centerlineLights = false; runways[index].centerlineLightsSpacing = 15; runways[index].edgeLights = true; runways[index].edgeLightsSpacing = 60; runways[index].thresholdWingbar[0] = ThresholdWingbar.SMALL; runways[index].thresholdWingbar[1] = ThresholdWingbar.SMALL; runways[index].TDZ[0] = false; runways[index].TDZ[1] = false; index = 3; runways[index] = new RunwayData(); runways[index].SetThresholdPosition(new Vector3(600, 0, 0), 3000); runways[index].thresholdHeight[0] = 0; runways[index].thresholdHeight[1] = 0; runways[index].midHeight = 0; runways[index].SetThresholdRotation(0); runways[index].width = 45; runways[index].lightingType[0] = LightingType.CALVERT2; runways[index].lightingType[1] = LightingType.CALVERT2; runways[index].strobeType[0] = StrobeType.NONE; runways[index].strobeType[1] = StrobeType.NONE; runways[index].papiType[0] = PapiType.PAPIBOTH; runways[index].papiType[1] = PapiType.PAPIBOTH; runways[index].centerlineLights = true; runways[index].centerlineLightsSpacing = 15; runways[index].edgeLights = true; runways[index].edgeLightsSpacing = 60; runways[index].thresholdWingbar[0] = ThresholdWingbar.LARGE; runways[index].thresholdWingbar[1] = ThresholdWingbar.LARGE; runways[index].TDZ[0] = true; runways[index].TDZ[1] = true; index = 4; runways[index] = new RunwayData(); runways[index].SetThresholdPosition(new Vector3(800, 0, 0), 3000); runways[index].thresholdHeight[0] = 0; runways[index].thresholdHeight[1] = 0; runways[index].midHeight = 0; runways[index].SetThresholdRotation(0); runways[index].width = 45; runways[index].lightingType[0] = LightingType.CALVERT1; runways[index].lightingType[1] = LightingType.CALVERT1; runways[index].strobeType[0] = StrobeType.NONE; runways[index].strobeType[1] = StrobeType.NONE; runways[index].papiType[0] = PapiType.PAPIRIGHT; runways[index].papiType[1] = PapiType.PAPIRIGHT; runways[index].centerlineLights = true; runways[index].centerlineLightsSpacing = 15; runways[index].edgeLights = true; runways[index].edgeLightsSpacing = 60; runways[index].thresholdWingbar[0] = ThresholdWingbar.LARGE; runways[index].thresholdWingbar[1] = ThresholdWingbar.LARGE; runways[index].TDZ[0] = true; runways[index].TDZ[1] = true; */ //Get the strobe timestep variable. strobeTimeStep = InitRunwayLights(runways); //Create temporary lists to store the light data,. List<SpriteLights.LightData> directionalLightData = new List<SpriteLights.LightData>(); List<SpriteLights.LightData> omnidirectionalLightData = new List<SpriteLights.LightData>(); List<SpriteLights.LightData> strobeLightData = new List<SpriteLights.LightData>(); List<SpriteLights.LightData> papiLightData = new List<SpriteLights.LightData>(); ApproachLightData allApproachLightData = new ApproachLightData(); //Get the position and color of the lights from an svg file. allApproachLightData.StoreApproachLightData(); //Loop through all runways. for(int i = 0; i < runways.Length; i++){ //Create the light data and store in a temporary buffer. SetupApproachLights(ref directionalLightData, allApproachLightData, runways[i], randomBrightness, brightness, 1f); SetupTDZLights(ref directionalLightData, allApproachLightData, runways[i], randomBrightness, brightness, smallerLightSize); SetupStrobeLights(ref strobeLightData, allApproachLightData, runways[i], strobeTimeStep); SetupThresholdLights(ref directionalLightData, runways[i], false, 0.6f, 1f); SetupCenterlineLights(ref directionalLightData, runways[i], randomBrightness, brightness, smallerLightSize); SetupEdgeLights(ref omnidirectionalLightData, runways[i], randomBrightness, brightness, 1f); SetupPapiLights(ref papiLightData, runways[i], false); } //Create a parent object. GameObject parentObject = new GameObject("RunwayLights"); //Take all the light data lists and create the actual ligth mesh from it. GameObject[] lightObjects = SpriteLights.CreateLights("Runway directional lights", directionalLightData.ToArray(), directionalLightsMat); MakeChild(parentObject, lightObjects); lightObjects = SpriteLights.CreateLights("Runway omnidirectional lights", omnidirectionalLightData.ToArray(), omnidirectionalRunwayLightsMat); MakeChild(parentObject, lightObjects); lightObjects = SpriteLights.CreateLights("Runway strobe lights", strobeLightData.ToArray(), strobeLightsMat); MakeChild(parentObject, lightObjects); lightObjects = SpriteLights.CreateLights("Runway PAPI lights", papiLightData.ToArray(), papiLightsMat); MakeChild(parentObject, lightObjects); parentObject.transform.position = new Vector3(-2941, 0, 10936); parentObject.transform.rotation = Quaternion.Euler(0, -111.5163f, 0); }