示例#1
0
文件: Shape.cs 项目: wibble82/mmbot
 public Mesh CreateConvex()
 {
     Mesh m = new Mesh();
     m.Shape = this;
     Convexes.Add(m);
     return m;
 }
示例#2
0
文件: Mesh.cs 项目: wibble82/mmbot
 public Mesh Split2d(Point3D raystart, Vector3D raydir, ESplitMode split_mode, ref Mesh target_mesh)
 {
     Face[] tosplit = Faces.ToArray();
     foreach (Face f in tosplit)
     {
         Face inside_face,outside_face;
         f.SplitByRay(raystart, raydir, out inside_face, out outside_face);
         if (split_mode == ESplitMode.KEEP_INSIDE)
         {
             if(outside_face != null)
                 TransferFaceTo(outside_face, target_mesh);
         }
         else if (split_mode == ESplitMode.KEEP_OUTSIDE)
         {
             if(inside_face != null)
                 TransferFaceTo(inside_face, target_mesh);
         }
     }
     return this;
 }
示例#3
0
文件: Mesh.cs 项目: wibble82/mmbot
 public void Clip2d(Mesh clip_mesh, List<Mesh> outside)
 {
     Mesh new_mesh = Shape.CreateConvex();
     foreach (Edge clip_edge in clip_mesh.Edges)
     {
         Point3D raystart = clip_edge.Vertices[0].Pos;
         Vector3D raydir = clip_edge.Direction;
         Split2d(raystart, raydir, ESplitMode.KEEP_INSIDE, new_mesh);
         if (new_mesh.Faces.Count != 0)
         {
         }
     }
 }
示例#4
0
文件: Mesh.cs 项目: wibble82/mmbot
        public void TransferFaceTo(Face f, Mesh mesh)
        {
            if (mesh.Shape != Shape)
                throw new System.ApplicationException("Can not transfer faces between shapes");

            //transfer the face
            Faces.Remove(f);
            mesh.Faces.Add(f);
            f.OwnerMesh = mesh;

            //go over each edge in the face and copy it over
            for(int edgeidx = 0; edgeidx < f.Edges.Count; edgeidx++)
            {
                //get the edge and remove the face from it
                Edge e = f.Edges[edgeidx];
                e.OwnerFaces.Remove(f);

                //create a new edge and replace it
                Edge newedge = mesh.CreateEdge();
                newedge.OwnerFaces.Add(f);
                f.Edges[edgeidx] = newedge;

                //set the 2 vertex references
                newedge.SetVertex(0, e.Vertices[0]);
                newedge.SetVertex(1, e.Vertices[1]);
            }
        }
示例#5
0
 public Node SplitByRay(double raystart_x, double raystart_y, double raystart_z, double raydir_x, double raydir_y, double raydir_z, Mesh.ESplitMode sm, params Node[] nodes)
 {
     return new SplitByRayNode(new Point3D(raystart_x,raystart_y,raystart_z), new Vector3D(raydir_x,raydir_y,raydir_z), sm, nodes);
 }
示例#6
0
文件: Shape.cs 项目: wibble82/mmbot
 public bool ContainsMesh(Mesh m)
 {
     if (Convexes != null && Convexes.Contains(m))
         return true;
     if (PolyMesh == m)
         return true;
     if (TriMesh == m)
         return true;
     return false;
 }
示例#7
0
文件: Shape.cs 项目: wibble82/mmbot
 public Shape Split2d(Point3D raystart, Vector3D raydir, Mesh.ESplitMode sm)
 {
     Mesh[] convexes = Convexes.ToArray();
     foreach (Mesh m in convexes)
     {
         Mesh newmesh = null;
         if (sm != Mesh.ESplitMode.KEEP_BOTH)
             newmesh = CreateConvex();
         m.Split2d(raystart, raydir, sm, newmesh);
     }
     Convexes = convexes.ToList();
     return this;
 }
示例#8
0
 public SplitByRayNode(Point3D raystart, Vector3D raydir, Mesh.ESplitMode sm, params Node[] nodes)
 {
     SetChildren(nodes);
     RayStart = raystart;
     RayDir = raydir;
     SplitMode = sm;
 }