[C++] The IN55 project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.9KB

  1. /*
  2. * Skia < lordbanana25 AT mailoo DOT org >
  3. *
  4. * Beerware licensed software - 2015
  5. */
  6. #include <utils.h>
  7. #include <assimp/cimport.h>
  8. #include <assimp/scene.h>
  9. #include <assimp/postprocess.h>
  10. const aiNodeAnim *findNodeAnim(const aiAnimation *anim, aiString name) {
  11. for (unsigned int i = 0; i < anim->mNumChannels; i++) {
  12. if (anim->mChannels[i]->mNodeName == name) {
  13. return anim->mChannels[i];
  14. }
  15. }
  16. return NULL;
  17. }
  18. aiVector3D operator*( float num, aiVector3D v ) {
  19. return aiVector3D(v.x * num, v.y * num, v.z * num);
  20. }
  21. aiQuaternion operator*( float num, aiQuaternion v ) {
  22. return aiQuaternion(v.w * num, v.x * num, v.y * num, v.z * num);
  23. }
  24. aiMatrix4x4 operator*( float n, aiMatrix4x4 m ) {
  25. return aiMatrix4x4(
  26. n*m.a1, n*m.a2, n*m.a3, n*m.a4,
  27. n*m.b1, n*m.b2, n*m.b3, n*m.b4,
  28. n*m.c1, n*m.c2, n*m.c3, n*m.c4,
  29. n*m.d1, n*m.d2, n*m.d3, n*m.d4
  30. );
  31. }
  32. aiMatrix4x4 operator+( aiMatrix4x4 m1, aiMatrix4x4 m2 ) {
  33. return aiMatrix4x4(
  34. m1.a1+m2.a1, m1.a2+m2.a2, m1.a3+m2.a3, m1.a4+m2.a4,
  35. m1.b1+m2.b1, m1.b2+m2.b2, m1.b3+m2.b3, m1.b4+m2.b4,
  36. m1.c1+m2.c1, m1.c2+m2.c2, m1.c3+m2.c3, m1.c4+m2.c4,
  37. m1.d1+m2.d1, m1.d2+m2.d2, m1.d3+m2.d3, m1.d4+m2.d4
  38. );
  39. }
  40. aiVector3D getPosition( aiMatrix4x4 mat ) {
  41. return aiVector3D(mat.a4, mat.b4, mat.c4);
  42. }
  43. aiVector3D getScale( aiMatrix4x4 mat ) {
  44. return aiVector3D(mat.a1, mat.b2, mat.c3);
  45. }
  46. std::ostream& operator<<(std::ostream& os, const aiMatrix4x4& m) {
  47. return os <<
  48. "Mat: " << m.a1 << " " << m.a2 << " " << m.a3 << " " << m.a4 << "\n" <<
  49. " " << m.b1 << " " << m.b2 << " " << m.b3 << " " << m.b4 << "\n" <<
  50. " " << m.c1 << " " << m.c2 << " " << m.c3 << " " << m.c4 << "\n" <<
  51. " " << m.d1 << " " << m.d2 << " " << m.d3 << " " << m.d4 << "\n";
  52. }