2012-02-28 2 views
0

본문의 조명기를 하나의 축 (x 또는 y)으로 미러링하려면 어떻게해야합니까? 하나만 미러링하려는 경우 어설 션 오류가 발생하지만 미러링 할 때 그것은 두 축에서 문제가 발생하지 않습니다.box2d 및 libgdx에 정점이있는 미러 본문

public Vector2[][] getPolygons(String bodyName, float scaleX, float scaleY) 
{ 
    Vector2[][] vectors = null; 

    Element fixture; 
    Element semiPolygon; 
    float auxX, auxY; 

    this.element = reader.parse(xml); 
    fixture = this.element.getChildByName(bodyName); 

    vectors = new Vector2[fixture.getChildCount()][]; 
    for(int child = 0; child < fixture.getChildCount(); child++) 
    { 
     semiPolygon = fixture.getChild(child); 
     vectors[child] = new Vector2[semiPolygon.getChildCount()]; 
     for(int part = 0; part < semiPolygon.getChildCount(); part++) 
     { 
      auxX = semiPolygon.getChild(part).getFloatAttribute("x")*-scaleX; 
      auxY = semiPolygon.getChild(part).getFloatAttribute("y")*-scaleY; 
      vectors[child][part] = World.toGameCoordinates(auxX, auxY); 
     } 
    } 

    return vectors; 
} 
+0

그래서 ... 어설 션은 어디에서 발생합니까? – iforce2d

답변

1

다각형 버텍스는 시계 반대 방향으로 지정해야합니다. 셰이프가 미러링 될 때마다 권선 순서가 반대로되므로 하나의 미러 만 있으면 순서가 거꾸로됩니다. 그런 다음 다시 미러링하면 발견 한대로 괜찮습니다. 따라서 한 축에 대해서만 대칭을 적용한다면 꼭지점의 순서를 뒤 바꿔야합니다.

+0

Thnaks that :) –