Sunday, August 7, 2022
HomeGame Developmentc++ - Find out how to use matrices in 2D

c++ – Find out how to use matrices in 2D


I am making an attempt to wrap my head round matrices, and the way to make the most of them (utilizing glm). From what I’ve seen, it looks as if a neat answer to mutate sprites purely by matrix transformations, like affine transformations talked about right here: https://en.wikipedia.org/wiki/Affine_transformation.

In a second sport, suppose I’ve a sprite at location glm::vec3(10.0f, 0.0f, 0.0f), so x=10 and y and z = 0.

However I additionally might retailer coordinates in a glm::map..to make use of glm::translate, I want a glm::map4 like:

1.0 0.0 0.0 0.0
0.0 1.0 0.0 0.0
0.0 0.0 1.0 0.0
0.0 0.0 0.0 1.0

Now I am confused the way to use all this, and the place to retailer x and y coordinates. Ought to I retailer them in a vector, and a number of/translate by a matrix? Or the opposite method round?

glm::translate() returns a brand new matrix, so I believe my sprite information ought to be in a matrix to start out with?

I hope somebody can present/hyperlink me to a primary instance..have not had a lot luck with tutorials thus far.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments