que tienen este código para trazar mi fondo de paralajeParallax XY y la rotación - el cálculo de baldosas
pGLState.pushModelViewGLMatrix();
final float cameraWidth = pCamera.getWidth();
final float cameraHeight = pCamera.getHeight();
final float shapeWidthScaled = this.mShape.getWidthScaled();
final float shapeHeightScaled = this.mShape.getHeightScaled();
//reposition
float baseOffsetX = (pParallaxValueX * this.mParallaxFactorX);
if (this.mRepeatX) {
baseOffsetX = baseOffsetX % shapeWidthScaled;
while(baseOffsetX > 0) {
baseOffsetX -= shapeWidthScaled;
}
}
float baseOffsetY = (pParallaxValueY * this.mParallaxFactorY);
if (this.mRepeatY) {
baseOffsetY = baseOffsetY % shapeHeightScaled;
while(baseOffsetY > 0) {
baseOffsetY -= shapeHeightScaled;
}
}
//draw
pGLState.translateModelViewGLMatrixf(baseOffsetX, baseOffsetY, 0);
float currentMaxX = baseOffsetX;
float currentMaxY = baseOffsetY;
do {
//rows
this.mShape.onDraw(pGLState, pCamera);
if (this.mRepeatY) {
currentMaxY = baseOffsetY;
//columns
do {
pGLState.translateModelViewGLMatrixf(0, shapeHeightScaled, 0);
currentMaxY += shapeHeightScaled;
this.mShape.onDraw(pGLState, pCamera);
} while(currentMaxY < cameraHeight);
//end columns
pGLState.translateModelViewGLMatrixf(0, -currentMaxY + baseOffsetY, 0);
}
pGLState.translateModelViewGLMatrixf(shapeWidthScaled, 0, 0);
currentMaxX += shapeWidthScaled;
} while (this.mRepeatX && currentMaxX < cameraWidth);
//end rows
pGLState.popModelViewGLMatrix();
todo funciona bien cuando la cámara no se gira.
Cuando se gira, creo que el mosaico (this.mShape
) debe dibujarse cuatro veces más (arriba, abajo, izquierda y derecha) para que no quede espacio vacío en la esquina. Por ejemplo, cuando la rotación es de 45 grados, pero no puedo encontrar la manera de hacerlo.
¿Puedes poner una imagen que explique el problema? Creo que sé a qué te refieres, pero solo quiero asegurarme. – Tim