예제 #1
0
    void GizmosDrawABrushOfLeaf(int brushIndex)
    {
        Color tc = Gizmos.color;

        // Draw Brush
        Gizmos.color = Color.white;
        BSPFileParser.Brush bsh = _brushes[brushIndex];
        for (int k = bsh.brushside; k < bsh.brushside + bsh.n_brushsides; k++)
        {
            BSPFileParser.Brushside bsd   = _brushsides[k];
            UnityEngine.Plane       plane = planes[bsd.plane];
            GizmosDrawPlane(GetOnePointOnPlane(plane), plane.normal, 5000.0f);
        }
        // Draw Leaf which hold the brushIndex
        Gizmos.color = Color.red;
        for (int i = 0; i < _leafs.Length; i++)
        {
            BSPFileParser.BSPTreeLeaf lf = _leafs[i];
            for (int j = lf.leafbrush; j < lf.leafbrush + lf.n_leafbrushes; j++)
            {
                if (_leafbrushes[j] == brushIndex)
                {
                    Bounds temp = new Bounds();
                    temp.SetMinMax(new Vector3(lf.mins[0], lf.mins[1], lf.mins[2]),
                                   new Vector3(lf.maxs[0], lf.maxs[1], lf.maxs[2]));
                    temp = Right2Left(temp);
                    Gizmos.DrawWireCube(temp.center, temp.size);
                }
            }
        }
        Gizmos.color = tc;
    }
예제 #2
0
    void GizmosDrawLeafBrushes(int whichLeaf)
    {
        Color tc = Gizmos.color;

        Color[] cs         = new Color[] { Color.gray, Color.yellow, Color.magenta, Color.red }; // from light to dark
        int     colorIndex = 0;

        if (whichLeaf >= 0)
        {
            BSPFileParser.BSPTreeLeaf lf = _leafs[whichLeaf];
            for (int j = lf.leafbrush; j < lf.leafbrush + lf.n_leafbrushes; j++)
            {
                int brushIndex          = _leafbrushes[j];
                BSPFileParser.Brush bsh = _brushes[brushIndex];
                Gizmos.color = cs[colorIndex++ % cs.Length];

                for (int k = bsh.brushside; k < bsh.brushside + bsh.n_brushsides; k++)
                {
                    BSPFileParser.Brushside bsd   = _brushsides[k];
                    UnityEngine.Plane       plane = planes[bsd.plane];
                    GizmosDrawPlane(GetOnePointOnPlane(plane), plane.normal, 5000.0f);
                }
            }
            Gizmos.color = tc;
            return;
        }
        // Draw All brushes for leaves
        int len = _leafs.Length;

        for (int i = 0; i < len; i++)
        {
            BSPFileParser.BSPTreeLeaf lf = _leafs[i];
            for (int j = lf.leafbrush; j < lf.leafbrush + lf.n_leafbrushes; j++)
            {
                int brushIndex          = _leafbrushes[j];
                BSPFileParser.Brush bsh = _brushes[brushIndex];
                Gizmos.color = cs[colorIndex++ % cs.Length];
                for (int k = bsh.brushside; k < bsh.brushside + bsh.n_brushsides; k++)
                {
                    BSPFileParser.Brushside bsd   = _brushsides[k];
                    UnityEngine.Plane       plane = planes[bsd.plane];
                    GizmosDrawPlane(GetOnePointOnPlane(plane), plane.normal, 5000.0f);
                }
            }
        }
        Gizmos.color = tc;
    }