Transformations - Fish-In-A-Suit/Conquest GitHub Wiki

This class uses the functionality of underlying math classes (Matrix4f, Vector3f, Vector4f) to provide methods regarding transformations - that is, methods which create transformation and projection matrices. Currently, only translation and perspective projection matrices are supported.

Class layout

Imports

  • math.Matrix4f;
  • math.Vector3f;

Private instance fields

  • Matrix4f translationMatrix;
  • Matrix4f projectionMatrix;

Public instance fields

Constructors

  • default
    • translationMatrix = new Matrix4f()
    • projectionMatrix = new Matrix4f()

Public methods

  • Matrix4f getTranslationMatrix(float x, float y, float z);
  • Matrix4f getTranslationMatrix(Vector3f vec)
  • Matrix4f getProjectionMatrix(float fovy, int width, int height, float zNear, float zFar)

Explanation

This class currently holds two fields: Matrix4f translationMatrix and Matrix4f projectionMatrix which are used to create translation and perspective projection matrices respectively.

getTranslationMatrix(float x, float y, float z) creates a translation matrix out of x, y and z parameters, stores them inside translationMatrix and returns it.

getTranslationMatrix(Vector3f vec) calls translate(Vector3f vec) of Matrix4f class on translationMatrix. It returns the modified translationMatrix.

getProjectionMatrix(float fovy, int width, int height, float zNear, float zFar) first calculates the aspect ratio using width and height parameters which refer to the width and height of the window. Then, it modifies the projectionMatrix variable to be a persoective projection matrix using the perspective(float fovy, float aspectRatio, float zNear, float zFar) method of Matrix4f class.