2
0

mat4.lua 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. local ffi = require("ffi")
  2. ffi.cdef
  3. [[
  4. typedef struct
  5. {
  6. float r1c1;
  7. float r2c1;
  8. float r3c1;
  9. float r4c1;
  10. float r1c2;
  11. float r2c2;
  12. float r3c2;
  13. float r4c2;
  14. float r1c3;
  15. float r2c3;
  16. float r3c3;
  17. float r4c3;
  18. float r1c4;
  19. float r2c4;
  20. float r3c4;
  21. float r4c4;
  22. } Mat4;
  23. Mat4* mat4(float r1c1, float r2c1, float r3c1, float r1c2, float r2c2, float r3c2, float r1c3, float r2c3, float r3c3);
  24. Mat4* mat4_add(Mat4* self, Mat4* m);
  25. Mat4* mat4_subtract(Mat4* self, Mat4* m);
  26. Mat4* mat4_multiply(Mat4* self, Mat4* m);
  27. Mat4* mat4_multiply_by_scalar(Mat4* self, float k);
  28. Mat4* mat4_divide_by_scalar(Mat4* self, float k);
  29. void mat4_build_rotation_x(Mat4* self, float radians);
  30. void mat4_build_rotation_y(Mat4* self, float radians);
  31. void mat4_build_rotation_z(Mat4* self, float radians);
  32. void mat4_build_rotation(Mat4* self, const Vec3* n, float radians);
  33. void mat4_build_projection_perspective_rh(Mat4* self, float fovy, float aspect, float near, float far);
  34. void mat4_build_projection_perspective_lh(Mat4* self, float fovy, float aspect, float near, float far);
  35. void mat4_build_projection_ortho_rh(Mat4* self, float width, float height, float near, float far);
  36. void mat4_build_projection_ortho_lh(Mat4* self, float width, float height, float near, float far);
  37. void mat4_build_projection_ortho_2d_rh(Mat4* self, float width, float height, float near, float far);
  38. void mat4_build_look_at_rh(Mat4* self, const Vec3* pos, const Vec3* target, const Vec3* up);
  39. void mat4_build_look_at_lh(Mat4* self, const Vec3* pos, const Vec3* target, const Vec3* up);
  40. void mat4_build_viewpoint_billboard(Mat4* self, const Vec3* pos, const Vec3* target, const Vec3* up);
  41. void mat4_build_axis_billboard(Mat4* self, const Vec3* pos, const Vec3* target, const Vec3* axis);
  42. Mat4* mat4_transpose(Mat4* self);
  43. float mat4_determinant(Mat4* self);
  44. Mat4* mat4_invert(Mat4* self);
  45. void mat4_load_identity(Mat4* self);
  46. Vec3* mat4_get_translation(Mat4* self);
  47. void mat4_set_translation(Mat4* self, const Vec3* trans);
  48. Vec3* mat4_get_scale(Mat4* self);
  49. void mat4_set_scale(Mat4* self, const Vec3* scale);
  50. void mat4_print(Mat4* self);
  51. ]]