I wanted to add a grass texture to my 3D polygon-based game, and thought the easiest way to do it was to use a TexturePaint. Currently, the texture stays fixed while the world rotates which isn't the look I'm going for. In order to fix this, I tried using an AffineTransform to rotate the actual image, so that the pattern would come out rotated and would follow the world as it rotated, but this lead to the texture cropping weirdly and didn't work.
This is the code I tried in order to rotate the texture (which doesn't work correctly):
double rotationRequired = radSpin; double locationX = grassImage.getWidth()/2; double locationY = grassImage.getHeight()/2; AffineTransform tx = AffineTransform.getRotateInstance(rotationRequired, locationX, locationY); AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR); grassTexture = new TexturePaint(op.filter(grassImage, null), new Rectangle((int)worldX, (int)worldY, (int)(scale*128), (int)(scale*128*getShrink)));
This is run every time the game is painted.
This is what my game looks like when I run the failed code: https://youtu.be/9U-9RqyDyj4