Scaling in a second pivot point

304 views Asked by At

I'm currently working with transformation matrices for game dev. One feature we have is a basic scaling, this is done when a user pinches the screen. Now we know that in order to scale/zoom in a point, we need to use the mid-point between the two fingers of the user, and I implemented this one.

Transformation order:

Matrix.translateM(matrix, 0, xPivot + xTranslate, yPivot + yTranslate, 0f)
Matrix.scaleM(matrix, 0, scale, scale, 1f)
Matrix.translateM(matrix, 0, -xPivot, -yPivot, 0f)

Problem is when user scale in another part of the object while recently performed another scale, or as the title says, scaling in a different pivot point. My current implementation jitters and teleports the object in a certain distance and performs the scaling in that area. So;

  • How to scale in a second pivot point?
  • do I need to have a reference to the previous pivot point?
  • How do the two pivot point relate to each other, and how to translate them into matrix transform.
0

There are 0 answers