Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        VD    = GetComponent <VertexDriver>();
        Inter = Intersector.Instance;

        // create target
        TargetI = (float)(TargetDistance * Math.Tan(DegToRad(VD.TargetFOV.x / 2.0)));
        TargetJ = (float)(TargetDistance * Math.Tan(DegToRad(VD.TargetFOV.y / 2.0)));
        Vector3 TargetBotLeft  = new Vector3(-TargetI, -TargetJ, TargetDistance);
        Vector3 TargetBotRight = new Vector3(TargetI, -TargetJ, TargetDistance);
        Vector3 TargetTopLeft  = new Vector3(-TargetI, TargetJ, TargetDistance);
        Vector3 TargetTopRight = new Vector3(TargetI, TargetJ, TargetDistance);

        TargetLines = new List <Vector3[]>();
        TargetLines.Add(new Vector3[] { TargetBotLeft, TargetBotRight });  // bottom
        TargetLines.Add(new Vector3[] { TargetBotRight, TargetTopRight }); // right
        TargetLines.Add(new Vector3[] { TargetTopRight, TargetTopLeft });  // top
        TargetLines.Add(new Vector3[] { TargetTopLeft, TargetBotLeft });   // left

        OcLines = new List <Vector3[]>();
        for (int i = 1; i < Inter.OccGridSize.x; i++)
        {
            float   offset = i * (2f * Math.Abs(TargetI)) / Inter.OccGridSize.x;
            Vector3 bot    = new Vector3(TargetBotLeft.x + offset, TargetBotLeft.y, TargetBotLeft.z);
            Vector3 top    = new Vector3(TargetTopLeft.x + offset, TargetTopLeft.y, TargetTopLeft.z);
            OcLines.Add(new Vector3[] { bot, top });
        }
        for (int i = 1; i < Inter.OccGridSize.y; i++)
        {
            float   offset = i * (2f * Math.Abs(TargetJ)) / Inter.OccGridSize.y;
            Vector3 left   = new Vector3(TargetBotLeft.x, TargetBotLeft.y + offset, TargetBotLeft.z);
            Vector3 right  = new Vector3(TargetBotRight.x, TargetBotRight.y + offset, TargetBotRight.z);
            OcLines.Add(new Vector3[] { left, right });
        }

        TargetContainer      = new GameObject();
        TargetContainer.name = "TargetContainer";
        for (int i = 0; i < TargetLines.Count; i++)
        {
            Vector3[] line = TargetLines[i];
            VertexDriver.DrawLine(line[0], line[1], TargetContainer, TargetSize, TargetMaterial, i.ToString());
        }
        OcContainer      = new GameObject();
        OcContainer.name = "OcContainer";
        for (int i = 0; i < OcLines.Count; i++)
        {
            Vector3[] line = OcLines[i];
            VertexDriver.DrawLine(line[0], line[1], OcContainer, OcGridSize, TargetMaterial, i.ToString());
        }


        // create diagnostics panel
        Diagnostics = new GameObject();
        Diagnostics.transform.position           = DiagnosticsPosition;
        DiagnosticsText.transform.parent         = Diagnostics.transform;
        DiagnosticsText.transform.position       = Diagnostics.transform.TransformPoint(DiagnosticsText.transform.position);
        DiagnosticsBackground.transform.parent   = Diagnostics.transform;
        DiagnosticsBackground.transform.position = Diagnostics.transform.
                                                   TransformPoint(DiagnosticsBackground.transform.position);
    }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        VD = GetComponent <VertexDriver>();

        // create target
        TargetI              = (float)(TargetDistance * Math.Tan(DegToRad(VD.TargetFOV.x / 2.0)));
        TargetJ              = (float)(TargetDistance * Math.Tan(DegToRad(VD.TargetFOV.y / 2.0)));
        TargetBotLeft        = new Vector3(-TargetI, -TargetJ, TargetDistance);
        TargetBotRight       = new Vector3(TargetI, -TargetJ, TargetDistance);
        TargetTopLeft        = new Vector3(-TargetI, TargetJ, TargetDistance);
        TargetTopRight       = new Vector3(TargetI, TargetJ, TargetDistance);
        TargetContainer      = new GameObject();
        TargetContainer.name = "TargetContainer";
        VertexDriver.DrawLine(TargetBotLeft, TargetBotRight, TargetContainer, TargetSize, TargetMaterial, "bottom");
        VertexDriver.DrawLine(TargetBotRight, TargetTopRight, TargetContainer, TargetSize, TargetMaterial, "right");
        VertexDriver.DrawLine(TargetTopRight, TargetTopLeft, TargetContainer, TargetSize, TargetMaterial, "top");
        VertexDriver.DrawLine(TargetTopLeft, TargetBotLeft, TargetContainer, TargetSize, TargetMaterial, "left");

        // create diagnostics panel
        Diagnostics = new GameObject();
        Diagnostics.transform.position           = DiagnosticsPosition;
        DiagnosticsText.transform.parent         = Diagnostics.transform;
        DiagnosticsText.transform.position       = Diagnostics.transform.TransformPoint(DiagnosticsText.transform.position);
        DiagnosticsBackground.transform.parent   = Diagnostics.transform;
        DiagnosticsBackground.transform.position = Diagnostics.transform.
                                                   TransformPoint(DiagnosticsBackground.transform.position);
    }