3
\$\begingroup\$

How would one go about 'flipping' a quad, either horizontally or vertically? (Just a single quad, not everything in view).

I know how to rotate a quad, this is my rotation method:

public void rotate(float x, float y, int angle){

    //Convert co-ordinates (Following section just converts my coordinates

    //Left hand
    xPlotLeft = (-MyGLRenderer.ratio)+((x)*MyGLRenderer.coordStepAmountWidth);
    //Top
    yPlotTop = +1-((y)*MyGLRenderer.coordStepAmountHeight);
    //Right hand
    xPlotRight = xPlotLeft+((quadWidth)*MyGLRenderer.coordStepAmountWidth);
    //Bottom
    yPlotBottom = yPlotTop-((quadHeight)*MyGLRenderer.coordStepAmountHeight);

    //Center of quad (Along the x)
    centreX = xPlotLeft + ((xPlotRight-xPlotLeft)/2);
    //Center of quad (Along the y)
    centreY = yPlotBottom + ((yPlotTop-yPlotBottom)/2);

    //Rotate the quad

    Matrix.setIdentityM(mRotationMatrix, 0);
    Matrix.translateM(mRotationMatrix, 0, centreX, centreY, 0f);
    Matrix.rotateM(mRotationMatrix, 0, -angle, 0, 0, 0.1f);
    Matrix.translateM(mRotationMatrix, 0, -centreX, -centreY, 0f);

}

I'm unsure how to do something similar just to flip (or 'mirror') the quad.

\$\endgroup\$
7
\$\begingroup\$

Create a scale matrix with a scale of -1 on the axis you want to mirror.

\$\endgroup\$
0
\$\begingroup\$

The simplest way to flip it would be to remap texture coordinates so that they are the other way around. Alternatively, keep the texture coordinates as they are and do a switch on the vertex coordinates.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.