コード例 #1
0
ファイル: NavSample.cs プロジェクト: x522758754/recast
    public void ShowRecastNavmesh(DbgRenderMesh renderMesh)
    {
        renderMesh.Clear();
        int vbsize = RecastMove.get_vb_size();

        vbsize = RecastMove.get_tri_vert_count() * 3;
        float[] vb = new float[vbsize];
        //RecastMove.get_vb(vb);
        RecastMove.get_tri_vert_pos(vb);
        Dbgrendermesh.Clear();
        for (int i = 0; i < vbsize;)
        {
            Vector3 a = new Vector3(vb[i], vb[i + 1], vb[i + 2]);
            Vector3 b = new Vector3(vb[i + 3], vb[i + 4], vb[i + 5]);
            Vector3 c = new Vector3(vb[i + 6], vb[i + 7], vb[i + 8]);

            Dbgrendermesh.AddTriangle(new DbgRenderTriangle(a, b, c, _vcolor));
            i += 9;
        }


        renderMesh.Rebuild();
        renderMesh.ComputeBounds();
        _Bounds = new Bounds(renderMesh.m_BBCenter, renderMesh.m_Max - renderMesh.m_Min);

        int obsize = RecastMove.get_ob_count() * 3;

        float[] op = new float[obsize];
        RecastMove.get_ob_info(op);
        for (int i = 0; i != obsize;)
        {
            if (first)
            {
                break;
            }
            first = true;
            Vector3 pos = new Vector3(op[i++], op[i++], op[i++]);
            // radius 1.0f, height 2.0f
            GameObject tempQie  = AssetDatabase.LoadAssetAtPath("Assets/Models/obstacle_perfab/CubeOBBOX.prefab", typeof(GameObject)) as GameObject;
            GameObject tempQie2 = (GameObject)GameObject.Instantiate(tempQie);
            tempQie2.transform.position = pos;
        }
    }