예제 #1
0
    public void DrawBoundingBox()
    {
        if (linesGO == null)
        {
            linesGO = Instantiate(linesPrefab);
            linesGO.transform.SetParent(transform.GetChild(0));
        }

        Lines lines = linesGO.GetComponent <Lines> ();


        lines.DrawLinesWorldCoordinate(new Vector3[] { coordinates[0], coordinates[1], coordinates[2], coordinates[3] }, 0);
        lines.DrawLinesWorldCoordinate(new Vector3[] { coordinates[4], coordinates[5], coordinates[6], coordinates[7] }, 4);

        lines.DrawLinesWorldCoordinate(new Vector3[] { coordinates[0], coordinates[4] }, 8);
        lines.DrawLinesWorldCoordinate(new Vector3[] { coordinates[1], coordinates[5] }, 10);
        lines.DrawLinesWorldCoordinate(new Vector3[] { coordinates[2], coordinates[6] }, 12);
        lines.DrawLinesWorldCoordinate(new Vector3[] { coordinates[3], coordinates[7] }, 14);



        // needs to be changed for local stuff

        /*
         * if (coordinates [0].y > 0) {
         *      Vector3 groundedA = new Vector3 (coordinates [0].x, 0f, coordinates [0].z);
         *      Vector3 groundedB = new Vector3 (coordinates [1].x, 0f, coordinates [1].z);
         *      Vector3 groundedC = new Vector3 (coordinates [2].x, 0f, coordinates [2].z);
         *      Vector3 groundedD = new Vector3 (coordinates [3].x, 0f, coordinates [3].z);
         *
         *      lines.EnhancedDrawLinesWorldCoordinate(new Vector3[] {groundedA,groundedB,groundedC,groundedD}, 16, new Color(0.8f,0.8f,0.8f, 0.4f));
         * }*/
    }
    public void DrawBoundingBox()
    {
        DeleteBoundingBox();

        CalculateBoundingBox();
        GameObject linesGO = Instantiate(linesPrefab);

        linesGO.transform.SetParent(transform);

        Lines lines = linesGO.GetComponent <Lines> ();

        lines.DrawLinesWorldCoordinate(new Vector3[] { coordinatesBoundingBox[0], coordinatesBoundingBox[1], coordinatesBoundingBox[2], coordinatesBoundingBox[3] });
        lines.DrawLinesWorldCoordinate(new Vector3[] { coordinatesBoundingBox[4], coordinatesBoundingBox[5], coordinatesBoundingBox[6], coordinatesBoundingBox[7] });

        /*
         * if (coordinatesBoundingBox [4].y > 0.1f) {
         *      lines.DrawLinesWorldCoordinate(new Vector3[] { new Vector3(coordinatesBoundingBox[4].x,0f,coordinatesBoundingBox[4].z),
         *              new Vector3(coordinatesBoundingBox[5].x,0f,coordinatesBoundingBox[5].z),
         *              new Vector3(coordinatesBoundingBox[6].x,0f,coordinatesBoundingBox[6].z),
         *              new Vector3(coordinatesBoundingBox[7].x,0f,coordinatesBoundingBox[7].z) });
         *
         *      Vector3 centerBottomBB = 0.25f * new Vector3 (coordinatesBoundingBox [4].x, 0f, coordinatesBoundingBox [4].z) +
         *              0.25f *  new Vector3 (coordinatesBoundingBox [5].x, 0f, coordinatesBoundingBox [5].z) +
         *              0.25f *  new Vector3 (coordinatesBoundingBox [6].x, 0f, coordinatesBoundingBox [6].z) +
         *              0.25f *   new Vector3 (coordinatesBoundingBox [7].x, 0f, coordinatesBoundingBox [7].z);
         *
         *      Vector3 centerBottomBBground = 0.25f * coordinatesBoundingBox[4] +
         *              0.25f *  coordinatesBoundingBox[5] +
         *              0.25f *  coordinatesBoundingBox[6] +
         *              0.25f *  coordinatesBoundingBox[7];
         *
         *      lines.DrawLinesWorldCoordinate(new Vector3[] {centerBottomBB, centerBottomBBground});
         * }*/

        lines.DrawLinesWorldCoordinate(new Vector3[] { coordinatesBoundingBox[0], coordinatesBoundingBox[4] });
        lines.DrawLinesWorldCoordinate(new Vector3[] { coordinatesBoundingBox[1], coordinatesBoundingBox[5] });
        lines.DrawLinesWorldCoordinate(new Vector3[] { coordinatesBoundingBox[2], coordinatesBoundingBox[6] });
        lines.DrawLinesWorldCoordinate(new Vector3[] { coordinatesBoundingBox[3], coordinatesBoundingBox[7] });
    }