Exemplo n.º 1
0
    void ParseRecHits(string eventFile, string locName, Material boxColor, bool shouldAnimate = false, float cutOff = 0.5f)
    {
        int tracksLoc = eventFile.IndexOf(locName);

        eventFile = eventFile.Substring(tracksLoc);
        tracksLoc = eventFile.IndexOf(":");
        eventFile = eventFile.Substring(tracksLoc);
        int tracksEnd = eventFile.IndexOf("\"");

        eventFile = eventFile.Substring(3, tracksEnd - 10);
        string[] lines = eventFile.Split("\n"[0]);
        for (int i = 0; i < lines.Length; i++)
        {
            //"EBRecHits_V2": [["energy", "double"],["eta", "double"],["phi", "double"],["time", "double"],["detid", "int"],["front_1", "v3d"],["front_2", "v3d"],["front_3", "v3d"],["front_4", "v3d"],["back_1", "v3d"],["back_2", "v3d"],["back_3", "v3d"],["back_4", "v3d"]]
            //[0.452491, 1.47677, -2.29626, -2.03797, 838970095, [-0.866318, -0.95971, 2.70935], [-0.879687, -0.976194, 2.69763], [-0.862247, -0.989843, 2.69763], [-0.849168, -0.973133, 2.70935], [-0.93539, -1.04485, 2.91156], [-0.949748, -1.06256, 2.89897], [-0.930778, -1.0774, 2.89897], [-0.916732, -1.05946, 2.91156]]
            string[] values = lines [i].Split(","[0]);
            if (float.Parse(values [0].Substring(1)) > cutOff)
            {
                Vector3[] verts = new Vector3[8];
                for (int j = 0; j < 8; j++)
                {
                    values [5 + (j * 3)] = values [5 + (j * 3)].Substring(2);
                    values [6 + (j * 3)] = values [6 + (j * 3)].Substring(1);
                    values [7 + (j * 3)] = values [7 + (j * 3)].Substring(1);
                    values [7 + (j * 3)] = values [7 + (j * 3)].Split("]" [0]) [0];
                    //Debug.Log (values [5 + (j*3)] + " -- " + values [6 + (j*3)] + " -- " + values [7 + (j*3)]);
                    verts [j] = new Vector3(float.Parse(values [5 + (j * 3)]), float.Parse(values [6 + (j * 3)]), float.Parse(values [7 + (j * 3)]));
                    //GameObject vertMarker = new GameObject ();
                    //vertMarker.transform.position = verts [j];
                }
                GameObject go = MakeCube(verts [0], verts [1], verts [2], verts [3], verts [4], verts [5], verts [6], verts [7], boxColor);
                go.name = locName + " - " + i;
                go.transform.SetParent(transform);
                //go.transform.localScale = new Vector3 (1, 1, -1);

                if (shouldAnimate)
                {
                    JetMovement jm = go.AddComponent <JetMovement> ();
                    float       r  = UnityEngine.Random.value + 0.5f;
                    //jm.targetScale = new Vector3 (1*r, 1*r, -1*r);
                    jm.startingScale        = new Vector3(0.2f * r, 0.2f * r, -0.2f * r);
                    jm.targetScale          = new Vector3(1, 1, -1);
                    jm.isJet                = false;
                    go.transform.localScale = Vector3.zero;
                }

                hitsArrayList.Add(go);
                if (!sm.showHits)
                {
                    go.SetActive(false);
                }
            }
            //return;
        }
    }
Exemplo n.º 2
0
    void Transport(JetMovement move)
    {
        int distance = Random.Range (0, move.boundary);
        float xDir = Random.Range (-360.0f,360.0f);
        float yDir = Random.Range (-360.0f,360.0f);
        float zDir = Random.Range (-360.0f,360.0f);

        Vector3 direction = new Vector3 (xDir,yDir,zDir);
        direction.Normalize();
        direction *= distance;

        transform.position = direction;
    }
Exemplo n.º 3
0
    GameObject MakeJet(float[] data, float selectionCutOff)
    {
        float et = data[0];

        float theta = data[2];
        float phi   = data[3];

        float ct = (float)Math.Cos(theta);
        float st = (float)Math.Sin(theta);
        float cp = (float)Math.Cos(phi);
        float sp = (float)Math.Sin(phi);

        float maxZ = 4.0f;
        float maxR = 2.0f;

        float length1 = maxZ / Math.Abs(ct);
        float length2 = maxR / Math.Abs(st);
        float length  = length1 < length2 ? length1 : length2;
        //var radius = 0.3 * (1.0 /(1 + 0.001));

        GameObject jet = Instantiate(cone) as GameObject;

        JetMovement jm = jet.AddComponent <JetMovement> ();

        jm.targetScale = new Vector3(length * 0.5f, length * 0.5f, length);
        jm.isJet       = true;
        //jet.transform.localScale = new Vector3 (length*0.5f,length*0.5f,length);
        jet.transform.localScale = Vector3.zero;

        jet.gameObject.transform.LookAt(new Vector3(length * 0.5f * st * cp, length * 0.5f * st * sp, length * 0.5f * ct));

        if (et < selectionCutOff)
        {
            jet.SetActive(false);
        }
        else
        {
            jetsArrayList.Add(jet);
        }

        if (!sm.showJets)
        {
            jet.SetActive(false);
        }

        return(jet);
    }