How to Apply transformation to Polygon object in Java

后端 未结 1 758
太阳男子
太阳男子 2021-01-26 02:08

i have made a transform and rendered a Polygon object with it(mesh is of type Polygon):

    at.setToTranslation(gameObject.position.x, gameObject.position.y);
           


        
1条回答
  •  忘了有多久
    2021-01-26 02:43

    If AffineTransform#createTransformedShape doesn't provide the desired result for Polygons (as it seems to be the case), you can split the Polygon into Points, transform each Point and combine into a new Polygon. Try:

    //Polygon mesh
    //AffineTransform at
    
    int[] x = mesh.xpoints;
    int[] y = mesh.ypoints;
    int[] rx = new int[x.length];
    int[] ry = new int[y.length];
    
    for(int i=0; i

    0 讨论(0)
提交回复
热议问题