Beispiel #1
0
 //=========================================================================
 public static void Init(int inumobjs)
 {
     objs = new EchoList <EchoPFXAreaEffect>(inumobjs);
 }
Beispiel #2
0
    //=========================================================================
    public void PrepareForRuntime(Camera[] icameras, float ifps)
    {
        int           loop;
        int           screenWidth;
        int           screenHeight;
        EchoPFXEffect epe;
        string        shaderName;
        float         per;

        _mainTexID = Shader.PropertyToID("_echoScreen");

        passCount = 1;
        if (possibleOpts2.Count > 0)
        {
            passCount++;
        }

        ValidateOptions();

        _autoDetailTargetTime = (int)((1.0f / ((float)ifps - autoDetailFudge)) * 10000.0f);

        // hold the final shader keywords
        _finalKeywords    = new string[2][];
        _finalKeywords[0] = new string[possibleOpts1.Count];
        _finalKeywords[1] = new string[possibleOpts2.Count];

        // used to accumylate the effects that are in use
        _finalKeyFlags    = new int[2][];
        _finalKeyFlags[0] = new int[possibleOpts1.Count];
        _finalKeyFlags[1] = new int[possibleOpts2.Count];

        // used to compare if anything has changed from last frame
        _prevKeyFlags    = new int[2][];
        _prevKeyFlags[0] = new int[possibleOpts1.Count];
        _prevKeyFlags[1] = new int[possibleOpts2.Count];

        FindCameras(icameras);
        CreateMesh();

        _echoRenderMaterial = new EchoPFXRenderMaterial[passCount];

        for (loop = 0; loop < passCount; loop++)
        {
            shaderName = "echoLogin/PFX/echologin_postfx_group" + id + "_pass" + (loop + 1);

            Shader shd = Shader.Find(shaderName);

            _echoRenderMaterial[loop] = new EchoPFXRenderMaterial(new Material(shd));
        }

        _renTex = new EchoPFXRenderTexture[2];

        if (!EchoPFXManager.unityPro)
        {
            rtAdjustSize = ECHORTADJUST.DEVICE_SIZE;
        }

        // Find Render Tex Size
        switch (rtAdjustSize)
        {
        case ECHORTADJUST.AUTO_DETAIL:
            screenWidth  = Screen.width;
            screenHeight = Screen.height;

            _autoTexPass1    = new  EchoPFXRenderTexture[autoDetailLevels];
            _autoTexPass1[0] = new EchoPFXRenderTexture(screenWidth, screenHeight, 16, rtFilterMode[0]);

            for (loop = 1; loop < autoDetailLevels; loop++)
            {
                per = Mathf.Lerp(1.0f, autoDetailMin, ((float)loop / (float)(autoDetailLevels - 1)));
                _autoTexPass1[loop] = new EchoPFXRenderTexture((int)((float)screenWidth * per), (int)((float)screenHeight * per), 16, rtFilterMode[0]);
            }

            if (passCount > 1)
            {
                _autoTexPass2    = new EchoPFXRenderTexture[autoDetailLevels];
                _autoTexPass2[0] = new EchoPFXRenderTexture(screenWidth, screenHeight, 0, rtFilterMode[0]);

                for (loop = 1; loop < autoDetailLevels; loop++)
                {
                    per = Mathf.Lerp(1.0f, autoDetailMin, ((float)loop / (float)(autoDetailLevels - 1)));
                    _autoTexPass2[loop] = new EchoPFXRenderTexture((int)((float)screenWidth * per), (int)((float)screenHeight * per), 0, rtFilterMode[0]);
                }
            }

            _autoTex    = new EchoPFXRenderTexture[2][];
            _autoTex[0] = _autoTexPass1;
            _autoTex[1] = _autoTexPass2;
            break;

        case ECHORTADJUST.DIVIDE:
            screenWidth  = Screen.width / rtAdjustWidth;
            screenHeight = Screen.height / rtAdjustHeight;
            break;

        case ECHORTADJUST.CUSTOM:
            screenWidth  = rtAdjustWidth;
            screenHeight = rtAdjustHeight;
            break;

        default:
        case ECHORTADJUST.DEVICE_SIZE:
            screenWidth  = Screen.width;
            screenHeight = Screen.height;
            break;
        }

        if (screenWidth < 4)
        {
            screenWidth = 4;
        }

        if (screenHeight < 4)
        {
            screenHeight = 4;
        }

        if (rtAdjustSize == ECHORTADJUST.AUTO_DETAIL)
        {
            _renTex[0] = _autoTexPass1[0];

            if (passCount > 1)
            {
                _renTex[1] = _autoTexPass2[0];
            }
        }
        else
        {
            _renTex[0] = new EchoPFXRenderTexture(screenWidth, screenHeight, 16, rtFilterMode[0]);
            if (passCount > 1)
            {
                _renTex[1] = new EchoPFXRenderTexture(screenWidth, screenHeight, 0, rtFilterMode[1]);
            }
        }


        epeEchoList = new EchoList <EchoPFXEffect>(epeList);

        for (loop = 0; loop < epeList.Count; loop++)
        {
            epe = epeList[loop];

            if (epe.active)
            {
                epe.Start();
                epeEchoList.Activate(epe);
            }
        }

        _renTex[0].SetCamerasRenderTarget(_camList);

        if (!EchoPFXManager.unityPro)
        {
            if (_camList.Count > 0)
            {
                EchoPFXUnityFreeCamCopy uscript;
                uscript            = _camList[0].gameObject.AddComponent <EchoPFXUnityFreeCamCopy>();
                uscript.echoRenTex = _renTex[0];

                EchoPFXUnityFreeCamSetRect rscript;
                rscript            = _camList[_camList.Count - 1].gameObject.AddComponent <EchoPFXUnityFreeCamSetRect>();
                rscript.echoRenTex = _renTex[0];
            }
        }
    }
Beispiel #3
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            Cursor   = Cursors.WaitCursor;
            SendFile = new StreamReader(InputStreamFile);
            EchoFile = new StreamReader(OutputStreamFile);
            string line;

            string[] lineItems;

            try
            {
                // read send file info
                while ((line = SendFile.ReadLine()) != null)
                {
                    lineItems = line.Split(',');
                    SendList.Add(Tuple.Create("send", lineItems[0].Trim(), DateTime.Parse(lineItems[1].Trim())));
                }
                SendFile.Close();


                // read echo file info
                while ((line = EchoFile.ReadLine()) != null)
                {
                    lineItems = line.Split(',');
                    EchoList.Add(Tuple.Create("echo", lineItems[0].Trim(), DateTime.Parse(lineItems[1].Trim())));
                }
                EchoFile.Close();


                // create new list sorted by packet number from send and echo lists
                var sortedList = new List <Tuple <string, string, DateTime> >((SendList.Concat(EchoList)).OrderBy(combinedList => int.Parse(combinedList.Item2)).ToList());

                // flag to indicate the beginning of a cross over
                bool inCrossOver = false;

                // determine whether or not cross over exists
                // TODO: review this to make sure the logic is correct concerning the time condition
                DateTime start = DateTime.Now;
                DateTime end   = DateTime.Now;
                for (int i = 0; i < sortedList.Count - 1; i++)
                {
                    if (sortedList[i].Item1.Equals("send"))
                    { // if next packet is send packet and it's number is less than prev send packet
                        if (!inCrossOver)
                        {
                            start = sortedList[i].Item3;
                        }
                        if (sortedList[i + 1].Item1.Equals("send") /* && int.Parse(sortedList[i+1].Item2) < int.Parse(sortedList[i].Item2)*/)
                        {
                            inCrossOver = true;
                            crossovers.Add(sortedList[i].Item1 + " - " + sortedList[i].Item2 + " - " + sortedList[i].Item3.ToString("hh:mm:ss.fff"));
                        }
                        else if (inCrossOver && sortedList[i + 1].Item1.Equals("echo") /* && int.Parse(sortedList[i+1].Item2) < int.Parse(sortedList[i].Item2)*/)
                        {
                            end         = sortedList[i + 1].Item3;
                            inCrossOver = false;
                            crossoverCount++;
                            crossovers.Add(sortedList[i].Item1 + " - " + sortedList[i].Item2 + " - " + sortedList[i].Item3.ToString("hh:mm:ss.fff"));
                            crossovers.Add(sortedList[i + 1].Item1 + " - " + sortedList[i + 1].Item2 + " - " + sortedList[i + 1].Item3.ToString("hh:mm:ss.fff"));
                            TimeSpan span = end.Subtract(start);
                            crossovers.Add("RTT: " + span.Milliseconds.ToString() + " ms");
                            crossovers.Add("----------------------------------------");
                        }
                    }
                }

                // format results
                if (crossovers.Count < 1)
                {
                    results = "No Cross Over packets detected!";
                }
                else
                {
                    results = "Cross Over packets detected!\n" + "Cross Over Count: " + crossoverCount + "\n----------------------------------------\nSend/Echo - Packet# - Timestamp" + "\n----------------------------------------\n";
                    foreach (var item in crossovers)
                    {
                        results += item + "\n";
                    }
                }

                // output and ask user if they want to save results
                if (MessageBox.Show("Save Results?", "Save?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    SaveFileDialog sfd = new SaveFileDialog
                    {
                        InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                        Filter           = "txt files (*.txt)|*.txt",
                    };

                    if (sfd.ShowDialog() == DialogResult.OK && sfd.FileName != "")
                    {
                        File.WriteAllText(sfd.FileName, results);
                    }
                    MessageBox.Show(results, "Results");
                }
                else
                {
                    MessageBox.Show(results, "Results");
                }
                crossoverCount = 0;
                crossovers.Clear();
                SendList.Clear();
                EchoList.Clear();
            }
            catch (Exception)
            {
                MessageBox.Show("Unable to read send or echo text file!");
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }