Open Source Tomb Raider Engine
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
  2. /*===============================================================
  3. * Project: Mongoose Tool Kit
  4. * Author : Terry 'Mongoose' Hendrix
  5. * Website: http://www.westga.edu/~stu7440/
  6. * Email : stu7440@westga.edu
  7. * Object :
  8. * Comment: 3d functions.
  9. *
  10. *-- History -----------------------------------------------
  11. *
  12. * 2001.11.23:
  13. * Mongoose - GL compatible matrix type
  14. *
  15. * 2001.07.05:
  16. * Mongoose - Backport of OpenRaider mtk3d
  17. *
  18. * 1999.06.14:
  19. * Mongoose - Created
  20. ==============================================================*/
  21. #ifndef GUARD__MONGOOSE_MTK_3D_MTK3D_H
  22. #define GUARD__MONGOOSE_MTK_3D_MTK3D_H
  23. #include <stdlib.h>
  24. #define MTK_PI 3.14159265358979323846 /* pi */
  25. #define MTK_PI_OVER_2 1.57079632679489661923 /* pi/2 */
  26. #define MTK_2_PI 6.28318530717958647692 /* pi*2 */
  27. #define MTK_PI_OVER_4 0.78539816339744830962 /* pi/4 */
  28. typedef float vec_t;
  29. typedef vec_t vec2_t[2];
  30. typedef vec_t vec3_t[3];
  31. typedef vec_t vec4_t[4];
  32. typedef vec_t matrix_t[16];
  33. typedef struct quaternion_s
  34. {
  35. float w, x, y, z;
  36. } quaternion_t;
  37. vec_t mtkRandNum(vec_t from, vec_t to);
  38. vec_t mtkDist2d(vec_t x, vec_t y, vec_t x2, vec_t y2);
  39. vec_t mtkDist3d(vec_t x, vec_t y, vec_t z,
  40. vec_t x2, vec_t y2, vec_t z2);
  41. //////////////////////////////////////////////////
  42. vec_t mtkDegToRad(vec_t degrees);
  43. vec_t mtkRadToDeg(vec_t rad);
  44. //////////////////////////////////////////////////
  45. void mtkVectorMatrixMult4dv(double v[4], matrix_t m, double result[4]);
  46. void mtkVectorMatrixMult(vec3_t v, matrix_t m, vec3_t result);
  47. void mtkVectorSubtract(vec3_t a, vec3_t b, vec3_t result);
  48. void mtkVectorAdd(vec3_t a, vec3_t b, vec3_t result);
  49. vec_t mtkVectorNorm(vec3_t v);
  50. void mtkVectorNormalize(vec3_t v, vec3_t result); // v can be result
  51. void mtkVectorCrossProduct(vec3_t a, vec3_t b, vec3_t normal);
  52. vec_t mtkVectorDotProduct(vec3_t a, vec3_t b);
  53. void mtkMatrixConvert3x3ToMtk(float *m3x3, matrix_t dest);
  54. void mtkMatrixMult(matrix_t m1, matrix_t m2, matrix_t mp);
  55. void mtkMatrixCopy(matrix_t source, matrix_t dest);
  56. void mtkMatrixTransform(matrix_t t, vec3_t p);
  57. void mtkMatrixIdentity(matrix_t matrix);
  58. void mtkMatrixScale(matrix_t matrix, vec_t sx, vec_t sy, vec_t sz);
  59. void mtkMatrixRotate(matrix_t matrix, vec_t ax, vec_t ay, vec_t az);
  60. void mtkMatrixTranslate(matrix_t matrix, vec_t tx, vec_t ty, vec_t tz);
  61. //////////////////////////////////////////////////
  62. void mtkQuaternionIdentity(quaternion_t q);
  63. void mtkQuaternionCopy(quaternion_t source, quaternion_t dest);
  64. void mtkQuaternionSlerp(quaternion_t qI, quaternion_t qA, quaternion_t qB,
  65. float time);
  66. void mtkQuaternionFrom3x3Matrix(float *m3x3, quaternion_t q);
  67. void mtkQuaternionFromMatrix(matrix_t m, quaternion_t q);
  68. void mtkQuaternionToMatrix(quaternion_t q, matrix_t m);
  69. void mtkQuaternionSet(quaternion_t q, float angle, float x, float y, float z);
  70. void mtkQuaternionMult(quaternion_t a, quaternion_t b, quaternion_t result);
  71. void mtkQuaternionNormalize(quaternion_t q);
  72. #endif