How does Matrix.setLookAtM
work? I've been searching all over, and can't find an explanation. I understand that the first three coordinates are to define the location of the camera in the world space, and I take it that "center of view" means the x, y, z
coordinate I'm looking at in the world space. That being the case, what does the "up vector" mean/do?
If there is a previous question or tutorial that I've overlooked, I would be happy to accept that.
Up vector is what the camera considers "up", i.e.: If you were looking forward and held your hand up, that is your "up" vector. Just set it to 0, 1, 0
. I'm not an Android developer, but I'm guessing it's similar to gluLookAt()
.
What the function is really doing is setting up a view matrix for you. It needs the eye position to establish where the camera will be. After that, it will subtract eye position from center and normalize it to get a forward vector. Then it will cross the forward vector with the up vector to get a right vector. After normalizing all three, it can construct a matrix from those x, y, z
vectors giving you a basic model view matrix.
It just discretizes the math for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With