dd_matrix.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef DD_MATRIX_H
  2. #define DD_MATRIX_H
  3. /* a series of functions to manipulate a 4x4 matrix.
  4. * a matrix can be created anyway the programmer likes, as long as they
  5. * pass a pointer to it.
  6. * these functions allow transformation, scale and rotation (experimental)
  7. */
  8. /* identity matrix
  9. * identity : makes an identity matrix
  10. * identityt : makes an identity matrix, except from translation
  11. (so it cancels rotation and scale)
  12. */
  13. void dd_matrix_identity (float mat[16]);
  14. void dd_matrix_identityt(float mat[16]);
  15. /* Translate - Seperated in add, set and multiply
  16. * add : adds fixed translation to the matrix
  17. * set : sets (overwrites) fixed translation to the matrix
  18. * multiply : creates a new matrix with given translation and
  19. multiplies the given matrix with it
  20. */
  21. void dd_matrix_translatea(float mat[16], float x, float y, float z);
  22. void dd_matrix_translates(float mat[16], float x, float y, float z);
  23. void dd_matrix_translatem(float mat[16], float x, float y, float z);
  24. /* Scale - Seperated in add and set */
  25. void dd_matrix_scalea(float mat[16], float x, float y, float z);
  26. void dd_matrix_scales(float mat[16], float x, float y, float z);
  27. /* Rotate - experimental functions */
  28. void dd_matrix_rotate_x(float mat[16], float rad);
  29. void dd_matrix_rotate_y(float mat[16], float rad);
  30. void dd_matrix_rotate_z(float mat[16], float rad);
  31. void dd_matrix_rotatelocal_x(float mat[16], float rad);
  32. void dd_matrix_rotatelocal_y(float mat[16], float rad);
  33. void dd_matrix_rotatelocal_z(float mat[16], float rad);
  34. /* Matrix multiplication */
  35. void dd_matrix_mult(float mat1[16], float mat2[16]);
  36. void dd_matrix_copy(float mat1[16], float mat2[16]);
  37. /* Getters */
  38. float dd_matrix_x(float mat[16]);
  39. float dd_matrix_y(float mat[16]);
  40. float dd_matrix_z(float mat[16]);
  41. /* Print matrix - don't use this */
  42. void dd_matrix_print(float mat[16]);
  43. /* these are experimental, they are meant to behave like glPush glPop and glMatrixMultf */
  44. void dd_matrix_push();
  45. void dd_matrix_pop ();
  46. void dd_matrix_globalmult(float mat[16]);
  47. void dd_matrix_globalset(float mat[16]);
  48. #endif