Ejemplo n.º 1
0
    //Setup all the shader variables.
    private float InitRunwayLights(RunwayData[] runways)
    {
        float strobeTimeStep = runways[0].GetTimeStep();

        SpriteLights.Init(strobeTimeStep, globalBrightnessOffset, FOV, screenHeight);

        return(strobeTimeStep);
    }
Ejemplo n.º 2
0
    //Generates random lights in the specified area.
    private void GenerateRandomLights(int amount, Vector2 area, Material material)
    {
        SpriteLights.LightData[] lightData = new SpriteLights.LightData[amount];

        for (int i = 0; i < amount; i++)
        {
            lightData[i]          = new SpriteLights.LightData();
            lightData[i].position = new Vector3(Random.Range(area.x, area.y), 0, Random.Range(area.x, area.y));
        }

        SpriteLights.CreateLights("RandomLights", lightData, material);
    }
Ejemplo n.º 3
0
    public void Update()
    {
        //For debugging purposes, the global brightness offset might be changed. This is not normally done each frame.
        SpriteLights.Init(strobeTimeStep, globalBrightnessOffset, FOV, screenHeight);

        /*
         *      //Create runway lights at runtime.
         *      if(Input.GetKeyDown("space")){
         *              CreateRunwayLights();
         *      }
         */
    }
    //private Tonemapping tonemapping;
    //private Bloom bloom;

    // Use this for initialization
    private void Start()
    {
        camera    = GetComponent <Camera>();
        behaviour = GetComponent <PostProcessingBehaviour>();
        //tonemapping = GetComponent<Tonemapping>();
        //bloom = GetComponent<Bloom>();

        SetQuality();

        // WIP: When some of this parameters are changed we have to recall SpriteLights.Init again
        SpriteLights.Init(0, 0, Camera.main.fieldOfView, Screen.height);
    }
Ejemplo n.º 5
0
        public virtual void Draw(DrawBatch drawBatch)
        {
            sprite.Draw(drawBatch, DrawBatch.DrawCall.Tag.GameObject, PositionXY + new Vector2(0, -position.Z), rotation, origin, scale, DrawBatch.CalculateDepth(PositionXY));

            if (hasLight)
            {
                SpriteLights.Draw(drawBatch, DrawBatch.DrawCall.Tag.Light, PositionXY + new Vector2(0, -position.Z), rotation, origin, scale, DrawBatch.CalculateDepth(PositionXY) - .0000001f);
            }
            if (sprite.Finished)
            {
                remove = true;
            }
        }
Ejemplo n.º 6
0
            public override void Draw(DrawBatch drawBatch)
            {
                sprite.Draw(drawBatch, DrawBatch.DrawCall.Tag.GameObject, PositionXY + new Vector2(0, -position.Z), rotation, origin, scale, DrawBatch.CalculateDepth(PositionXY));
                //sprite.frame -= sprite.speed;
                //sprite.Draw(drawBatch, DrawBatch.DrawCall.Tag.Light, PositionXY + new Vector2(0, -position.Z), rotation, origin, scale, DrawBatch.CalculateDepth(PositionXY) + .01f);

                if (hasLight)
                {
                    SpriteLights.Draw(drawBatch, DrawBatch.DrawCall.Tag.Light, PositionXY + new Vector2(0, -position.Z), rotation, origin * 2, scale * 2, Color.Lerp(Color.LightGoldenrodYellow, Color.OrangeRed, sprite.frame / sprite.frames), DrawBatch.CalculateDepth(PositionXY) + .01f);
                }

                base.Draw(drawBatch);
            }
Ejemplo n.º 7
0
    //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);
    }