[solved] Clipping with rotation wizardry

Hi there guys.
I’ll be direct, I’m trying to clip a texture region that rotates on its center.
I have managed to do this but with wizardry. This doesn’t seem to be the correct way of doing it =P.

This is what I wanted and managed to do (all placeholder textures):
Charging launcher indicator:

http://a.pomf.se/yfxmfs.png

Full indicator:

http://a.pomf.se/rhjgux.png

The problem is that this method generates this weird trail:

http://a.pomf.se/mmlocb.png

This shows when you charge (only hold the mouse) a few ms, means low power shot. I believe that this is because I shift the TextureRegion back when I shrink it.
(edit) I think this is because the area after the texture is not an empty region, I believe on low level it just copies the last row of pixels and there is a black shade thingy there that is
creating this trail. I’ll experiment on this. The problem though is that this is not the correct solution. This is just rendering the clipped image and stretching the clipped area with empty pixels
so the image stays in place. The correct way would be to have a ‘empty’ transparent region where the image expands on it cropped without any stretching.

I don’t think this is the right way of rotating TextureRegions with clipping.

The code that produces this:



	...

	public void draw(SpriteBatch batch) {
		// Draw default under texture
		...
		// Draw the top charging texture
		batch.draw(
				overTexture,
				position.x - underTexture.getRegionWidth() * scale / 2,
				(position.y - underTexture.getRegionHeight() * scale / 2) - calculateOTHPerCharge() * scale,
				underTexture.getRegionWidth() * scale / 2,
				(underTexture.getRegionHeight() * scale) / 2f + calculateOTHPerCharge() * scale,
				underTexture.getRegionWidth() * scale,
				underTexture.getRegionHeight() * scale,
				1f,
				1f,
				angle);

	}

	...

	/**
	 * OTH = Over Texture height
	 */
	private float calculateOTHPerCharge() {
		return (1f - chargePercent) * overTexture.getTexture().getHeight();
	}

	public void setChargePercent(float chargePercent) {
		this.chargePercent = chargePercent;
		overTexture.setRegionY(0);
		overTexture.setRegionHeight(overTexture.getTexture().getHeight());
		overTexture.setRegionY((int) calculateOTHPerCharge());
		overTexture.setRegionHeight((int) (overTexture.getRegionHeight() + calculateOTHPerCharge()));
	}