예제 #1
0
        private void Triangulate()
        {
            if (numVertices < 3)
            {
                return;
            }
            PVertexLoop list = vers;

            for (int i = 0; i < numVertices; i++)
            {
                if (vers.v.x > list.v.x)
                {
                    vers = list;
                }
                list = list.next;
            }

            vers = GetEar(vers);
            if (vers == null)
            {
                return;
            }
            if (CalcArea(vers.prev.v, vers.v, vers.next.v) > 1E-008F)
            {
                triangles[numTriangles++] = new PPolygon(new Vector2f[] {
                    vers.prev.v, vers.v, vers.next.v
                });
            }
            RemoveVertex(vers);
            vers = vers.next;
            Triangulate();
        }
예제 #2
0
        public PBody Polygon(bool fix, Polygon p, float angle, float density)
        {
            PPolygon             tmp   = p.GetPPolygon(this.scale);
            PConcavePolygonShape shape = new PConcavePolygonShape(tmp.xs, tmp.ys,
                                                                  density);
            PBody body = new PBody(angle, fix, new PShape[] { shape });

            return(body);
        }
예제 #3
0
 public void Triangulate(Vector2f[] vertices, int numVers)
 {
     triangles = new PPolygon[numVers - 2];
     local     = new PPolygon(vertices);
     if (!local.IsClockwise())
     {
         Vector2f[] newVertices = new Vector2f[numVers];
         int        num         = 0;
         for (int i = numVers - 1; i >= 0; i--)
         {
             newVertices[num++] = vertices[i];
         }
         MakeVertexList(newVertices);
     }
     else
     {
         MakeVertexList(vertices);
     }
     numVertices = numVers;
     Triangulate();
 }
예제 #4
0
		public void Triangulate(Vector2f[] vertices, int numVers) {
			triangles = new PPolygon[numVers - 2];
			local = new PPolygon(vertices);
			if (!local.IsClockwise()) {
				Vector2f[] newVertices = new Vector2f[numVers];
				int num = 0;
				for (int i = numVers - 1; i >= 0; i--) {
					newVertices[num++] = vertices[i];
				}
				MakeVertexList(newVertices);
			} else {
				MakeVertexList(vertices);
			}
			numVertices = numVers;
			Triangulate();
		}
예제 #5
0
		private void Triangulate() {
			if (numVertices < 3) {
				return;
			}
			PVertexLoop list = vers;
			for (int i = 0; i < numVertices; i++) {
				if (vers.v.x > list.v.x) {
					vers = list;
				}
				list = list.next;
			}
	
			vers = GetEar(vers);
			if (vers == null) {
				return;
			}
			if (CalcArea(vers.prev.v, vers.v, vers.next.v) > 1E-008F) {
				triangles[numTriangles++] = new PPolygon(new Vector2f[] {
						vers.prev.v, vers.v, vers.next.v });
			}
			RemoveVertex(vers);
			vers = vers.next;
			Triangulate();
		}