Exemplo n.º 1
0
    public void ReloadConvexInfo()
    {
        geom_convex_list_.Clear();

        nav_editor.editor_geom_get_convex_info(ref my_convex_info);
        for (int i = 0; i < my_convex_info.convex_num; ++i)
        {
            IntPtr p = new IntPtr(my_convex_info.convex.ToInt64() + (uint)(i * Marshal.SizeOf(typeof(nav_editor.MyConvexVolume))));
            nav_editor.MyConvexVolume convex = nav_editor.PtrToStructure <nav_editor.MyConvexVolume>(p);

            ConvexInfo info = new ConvexInfo();
            info.id   = i;
            info.hmin = convex.hmin;
            info.hmax = convex.hmax;
            info.area = convex.area;

            for (int k = 0; k < convex.nverts; ++k)
            {
                IntPtr pv  = new IntPtr(convex.verts.ToInt64() + (uint)(3 * k * Marshal.SizeOf(typeof(float))));
                IntPtr pv1 = new IntPtr(pv.ToInt64() + 1 * Marshal.SizeOf(typeof(float)));
                IntPtr pv2 = new IntPtr(pv.ToInt64() + 2 * Marshal.SizeOf(typeof(float)));

                Vector3 pos = Vector3.zero;
                pos.x = -nav_editor.PtrToStructure <float>(pv);
                pos.y = nav_editor.PtrToStructure <float>(pv1);
                pos.z = nav_editor.PtrToStructure <float>(pv2);

                info.vertexs.Add(pos);
            }
            geom_convex_list_.Add(info);
        }
    }
Exemplo n.º 2
0
    public void ModifyConvex(int id, int area)
    {
        ConvexInfo info = GetConvexById(id);

        if (info == null)
        {
            return;
        }

        nav_editor.editor_geom_delete_convex_volume(id);
        AddConvex(info.vertexs, area, info.hmin, info.hmax);
    }
Exemplo n.º 3
0
 public void DoPaintConvex()
 {
     UnityEditor.Handles.color = Color.white;
     for (int i = 0; i < geom_convex_list_.Count; ++i)
     {
         ConvexInfo info = geom_convex_list_[i];
         for (int k = 0; k < info.vertexs.Count - 1; ++k)
         {
             UnityEditor.Handles.DrawLine(info.vertexs[k], info.vertexs[k + 1]);
         }
     }
 }
Exemplo n.º 4
0
 void OnSelected()
 {
     if (selected_convex_id_ < 0)
     {
         current_area_ = 0;
     }
     else
     {
         ConvexInfo convex = convex_.GetConvexById(selected_convex_id_);
         current_area_ = (int)convex.area;
     }
 }