Java Code Examples for org.andengine.entity.sprite.Sprite#isFlippedVertical()

The following examples show how to use org.andengine.entity.sprite.Sprite#isFlippedVertical() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LowMemoryUniformColorSpriteVertexBufferObject.java    From tilt-game-android with MIT License 4 votes vote down vote up
@Override
public void onUpdateTextureCoordinates(final Sprite pSprite) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final ITextureRegion textureRegion = pSprite.getTextureRegion(); // TODO Optimize with field access?

	final float u;
	final float v;
	final float u2;
	final float v2;

	if (pSprite.isFlippedVertical()) { // TODO Optimize with field access?
		if (pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		}
	} else {
		if (pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		}
	}

	if (textureRegion.isRotated()) {
		bufferData.put(0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V, v2);

		bufferData.put(3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V, v2);
	} else {
		bufferData.put(0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V, v2);

		bufferData.put(1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V, v2);

		bufferData.put(3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V, v);
	}

	this.setDirtyOnHardware();
}
 
Example 2
Source File: HighPerformanceUniformColorSpriteVertexBufferObject.java    From tilt-game-android with MIT License 4 votes vote down vote up
@Override
public void onUpdateTextureCoordinates(final Sprite pSprite) {
	final float[] bufferData = this.mBufferData;

	final ITextureRegion textureRegion = pSprite.getTextureRegion(); // TODO Optimize with field access?

	final float u;
	final float v;
	final float u2;
	final float v2;

	if (pSprite.isFlippedVertical()) { // TODO Optimize with field access?
		if (pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		}
	} else {
		if (pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		}
	}

	if (textureRegion.isRotated()) {
		bufferData[0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V] = v2;

		bufferData[3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V] = v2;
	} else {
		bufferData[0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V] = v2;

		bufferData[1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V] = v2;

		bufferData[3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V] = v;
	}

	this.setDirtyOnHardware();
}
 
Example 3
Source File: LowMemoryDiamondSpriteVertexBufferObject.java    From tilt-game-android with MIT License 4 votes vote down vote up
@Override
public void onUpdateTextureCoordinates(final Sprite pSprite) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final ITextureRegion textureRegion = pSprite.getTextureRegion();

	final float u;
	final float v;
	final float u2;
	final float v2;

	if (pSprite.isFlippedVertical()) { // TODO Optimize with field access?
		if (pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		}
	} else {
		if (pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		}
	}

	final float uCenter = (u + u2) * 0.5f;
	final float vCenter = (v + v2) * 0.5f;

	if (textureRegion.isRotated()) {
		bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, vCenter);

		bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, uCenter);
		bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, uCenter);
		bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v2);

		bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, vCenter);
	} else {
		bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, uCenter);
		bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v2);

		bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, vCenter);

		bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, vCenter);

		bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, uCenter);
		bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v);
	}

	this.setDirtyOnHardware();
}
 
Example 4
Source File: HighPerformanceSpriteVertexBufferObject.java    From tilt-game-android with MIT License 4 votes vote down vote up
@Override
public void onUpdateTextureCoordinates(final Sprite pSprite) {
	final float[] bufferData = this.mBufferData;

	final ITextureRegion textureRegion = pSprite.getTextureRegion(); // TODO Optimize with field access?

	final float u;
	final float v;
	final float u2;
	final float v2;

	if (pSprite.isFlippedVertical()) { // TODO Optimize with field access?
		if (pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		}
	} else {
		if (pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		}
	}

	if (textureRegion.isRotated()) {
		bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2;

		bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2;
	} else {
		bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2;

		bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2;

		bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v;
	}

	this.setDirtyOnHardware();
}
 
Example 5
Source File: LowMemoryUncoloredSpriteVertexBufferObject.java    From tilt-game-android with MIT License 4 votes vote down vote up
@Override
public void onUpdateTextureCoordinates(final Sprite pSprite) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final ITextureRegion textureRegion = pSprite.getTextureRegion();

	final float u;
	final float v;
	final float u2;
	final float v2;

	if (pSprite.isFlippedVertical()) { // TODO Optimize with field access?
		if (pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		}
	} else {
		if (pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		}
	}

	if (textureRegion.isRotated()) {
		bufferData.put(0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V, v2);

		bufferData.put(3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V, v2);
	} else {
		bufferData.put(0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V, v2);

		bufferData.put(1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V, v2);

		bufferData.put(3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V, v);
	}

	this.setDirtyOnHardware();
}
 
Example 6
Source File: LowMemorySpriteVertexBufferObject.java    From tilt-game-android with MIT License 4 votes vote down vote up
@Override
public void onUpdateTextureCoordinates(final Sprite pSprite) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final ITextureRegion textureRegion = pSprite.getTextureRegion(); // TODO Optimize with field access?

	final float u;
	final float v;
	final float u2;
	final float v2;

	if (pSprite.isFlippedVertical()) { // TODO Optimize with field access?
		if (pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		}
	} else {
		if (pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		}
	}

	if (textureRegion.isRotated()) {
		bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v2);

		bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v2);
	} else {
		bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v2);

		bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v2);

		bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v);
	}

	this.setDirtyOnHardware();
}
 
Example 7
Source File: HighPerformanceDiamondSpriteVertexBufferObject.java    From tilt-game-android with MIT License 4 votes vote down vote up
@Override
public void onUpdateTextureCoordinates(final Sprite pSprite) {
	final float[] bufferData = this.mBufferData;

	final ITextureRegion textureRegion = pSprite.getTextureRegion();

	final float u;
	final float v;
	final float u2;
	final float v2;

	if (pSprite.isFlippedVertical()) { // TODO Optimize with field access?
		if (pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		}
	} else {
		if (pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		}
	}

	final float uCenter = (u + u2) * 0.5f;
	final float vCenter = (v + v2) * 0.5f;

	if (textureRegion.isRotated()) {
		bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = vCenter;

		bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = uCenter;
		bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = uCenter;
		bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2;

		bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = vCenter;
	} else {
		bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = uCenter;
		bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2;

		bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = vCenter;

		bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = vCenter;

		bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = uCenter;
		bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v;
	}

	this.setDirtyOnHardware();
}
 
Example 8
Source File: HighPerformanceUncoloredSpriteVertexBufferObject.java    From tilt-game-android with MIT License 4 votes vote down vote up
@Override
public void onUpdateTextureCoordinates(final Sprite pSprite) {
	final float[] bufferData = this.mBufferData;

	final ITextureRegion textureRegion = pSprite.getTextureRegion(); // TODO Optimize with field access?

	final float u;
	final float v;
	final float u2;
	final float v2;

	if (pSprite.isFlippedVertical()) { // TODO Optimize with field access?
		if (pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		}
	} else {
		if (pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		}
	}

	if (textureRegion.isRotated()) {
		bufferData[0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V] = v2;

		bufferData[3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V] = v2;
	} else {
		bufferData[0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V] = v2;

		bufferData[1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V] = v2;

		bufferData[3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V] = v;
	}

	this.setDirtyOnHardware();
}
 
Example 9
Source File: LowMemoryUniformColorSpriteVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
@Override
public void onUpdateTextureCoordinates(final Sprite pSprite) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final ITextureRegion textureRegion = pSprite.getTextureRegion(); // TODO Optimize with field access?

	final float u;
	final float v;
	final float u2;
	final float v2;

	if(pSprite.isFlippedVertical()) { // TODO Optimize with field access?
		if(pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		}
	} else {
		if(pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		}
	}

	if(textureRegion.isRotated()) {
		bufferData.put(0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V, v2);

		bufferData.put(3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V, v2);
	} else {
		bufferData.put(0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V, v2);

		bufferData.put(2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V, v2);
	}

	this.setDirtyOnHardware();
}
 
Example 10
Source File: HighPerformanceUniformColorSpriteVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
@Override
public void onUpdateTextureCoordinates(final Sprite pSprite) {
	final float[] bufferData = this.mBufferData;

	final ITextureRegion textureRegion = pSprite.getTextureRegion(); // TODO Optimize with field access?

	final float u;
	final float v;
	final float u2;
	final float v2;

	if(pSprite.isFlippedVertical()) { // TODO Optimize with field access?
		if(pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		}
	} else {
		if(pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		}
	}

	if(textureRegion.isRotated()) {
		bufferData[0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V] = v2;

		bufferData[3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V] = v2;
	} else {
		bufferData[0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V] = v2;

		bufferData[2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.TEXTURECOORDINATES_INDEX_V] = v2;
	}

	this.setDirtyOnHardware();
}
 
Example 11
Source File: LowMemoryDiamondSpriteVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
@Override
public void onUpdateTextureCoordinates(final Sprite pSprite) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final ITextureRegion textureRegion = pSprite.getTextureRegion();

	final float u;
	final float v;
	final float u2;
	final float v2;

	if(pSprite.isFlippedVertical()) { // TODO Optimize with field access?
		if(pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		}
	} else {
		if(pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		}
	}

	final float uCenter = (u + u2) * 0.5f;
	final float vCenter = (v + v2) * 0.5f;

	if(textureRegion.isRotated()) {
		bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, uCenter);
		bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, vCenter);

		bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, vCenter);

		bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, uCenter);
		bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v2);
	} else {
		bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, vCenter);

		bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, uCenter);
		bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v2);

		bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, uCenter);
		bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, vCenter);
	}

	this.setDirtyOnHardware();
}
 
Example 12
Source File: HighPerformanceSpriteVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
@Override
public void onUpdateTextureCoordinates(final Sprite pSprite) {
	final float[] bufferData = this.mBufferData;

	final ITextureRegion textureRegion = pSprite.getTextureRegion(); // TODO Optimize with field access?

	final float u;
	final float v;
	final float u2;
	final float v2;

	if(pSprite.isFlippedVertical()) { // TODO Optimize with field access?
		if(pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		}
	} else {
		if(pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		}
	}

	if(textureRegion.isRotated()) {
		bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2;

		bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2;
	} else {
		bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2;

		bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2;
	}

	this.setDirtyOnHardware();
}
 
Example 13
Source File: LowMemoryUncoloredSpriteVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
@Override
public void onUpdateTextureCoordinates(final Sprite pSprite) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final ITextureRegion textureRegion = pSprite.getTextureRegion();

	final float u;
	final float v;
	final float u2;
	final float v2;

	if(pSprite.isFlippedVertical()) { // TODO Optimize with field access?
		if(pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		}
	} else {
		if(pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		}
	}

	final float uCenter = (u + u2) * 0.5f;
	final float vCenter = (v + v2) * 0.5f;

	if(textureRegion.isRotated()) {
		bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, uCenter);
		bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, vCenter);

		bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, vCenter);

		bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, uCenter);
		bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v2);
	} else {
		bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, vCenter);

		bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, uCenter);
		bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v2);

		bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, uCenter);
		bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, vCenter);
	}

	this.setDirtyOnHardware();
}
 
Example 14
Source File: LowMemorySpriteVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
@Override
public void onUpdateTextureCoordinates(final Sprite pSprite) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final ITextureRegion textureRegion = pSprite.getTextureRegion(); // TODO Optimize with field access?

	final float u;
	final float v;
	final float u2;
	final float v2;

	if(pSprite.isFlippedVertical()) { // TODO Optimize with field access?
		if(pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		}
	} else {
		if(pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		}
	}

	if(textureRegion.isRotated()) {
		bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v2);

		bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v2);
	} else {
		bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u);
		bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v2);

		bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v);

		bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U, u2);
		bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V, v2);
	}

	this.setDirtyOnHardware();
}
 
Example 15
Source File: HighPerformanceDiamondSpriteVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
@Override
public void onUpdateTextureCoordinates(final Sprite pSprite) {
	final float[] bufferData = this.mBufferData;

	final ITextureRegion textureRegion = pSprite.getTextureRegion();

	final float u;
	final float v;
	final float u2;
	final float v2;

	if(pSprite.isFlippedVertical()) { // TODO Optimize with field access?
		if(pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		}
	} else {
		if(pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		}
	}

	final float uCenter = (u + u2) * 0.5f;
	final float vCenter = (v + v2) * 0.5f;

	if(textureRegion.isRotated()) {
		bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = uCenter;
		bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = vCenter;

		bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = vCenter;

		bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = uCenter;
		bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2;
	} else {
		bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[0 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = vCenter;

		bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = uCenter;
		bufferData[1 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v2;

		bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = uCenter;
		bufferData[2 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[3 * Sprite.VERTEX_SIZE + Sprite.TEXTURECOORDINATES_INDEX_V] = vCenter;
	}

	this.setDirtyOnHardware();
}
 
Example 16
Source File: HighPerformanceUncoloredSpriteVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
@Override
public void onUpdateTextureCoordinates(final Sprite pSprite) {
	final float[] bufferData = this.mBufferData;

	final ITextureRegion textureRegion = pSprite.getTextureRegion(); // TODO Optimize with field access?

	final float u;
	final float v;
	final float u2;
	final float v2;

	if(pSprite.isFlippedVertical()) { // TODO Optimize with field access?
		if(pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV2();
			v2 = textureRegion.getV();
		}
	} else {
		if(pSprite.isFlippedHorizontal()) { // TODO Optimize with field access?
			u = textureRegion.getU2();
			u2 = textureRegion.getU();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		} else {
			u = textureRegion.getU();
			u2 = textureRegion.getU2();
			v = textureRegion.getV();
			v2 = textureRegion.getV2();
		}
	}

	if(textureRegion.isRotated()) {
		bufferData[0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V] = v2;

		bufferData[3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V] = v2;
	} else {
		bufferData[0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U] = u;
		bufferData[1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V] = v2;

		bufferData[2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V] = v;

		bufferData[3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_U] = u2;
		bufferData[3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.TEXTURECOORDINATES_INDEX_V] = v2;
	}

	this.setDirtyOnHardware();
}