2
0

ConvertToLHProcess.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /** @file Defines a post processing step to convert all data to a left-handed coordinate system.*/
  2. #ifndef AI_CONVERTTOLHPROCESS_H_INC
  3. #define AI_CONVERTTOLHPROCESS_H_INC
  4. #include "../include/aiTypes.h"
  5. #include "BaseProcess.h"
  6. struct aiMesh;
  7. struct aiBoneAnim;
  8. namespace Assimp
  9. {
  10. // ---------------------------------------------------------------------------
  11. /** The ConvertToLHProcess converts all imported data to a left-handed coordinate
  12. * system. This implies inverting the Z axis for all transformation matrices
  13. * invert the orientation of all faces, and adapting skinning and animation
  14. * data in a similar way.
  15. */
  16. class ConvertToLHProcess : public BaseProcess
  17. {
  18. friend class Importer;
  19. protected:
  20. /** Constructor to be privately used by Importer */
  21. ConvertToLHProcess();
  22. /** Destructor, private as well */
  23. ~ConvertToLHProcess();
  24. public:
  25. // -------------------------------------------------------------------
  26. /** Returns whether the processing step is present in the given flag field.
  27. * @param pFlags The processing flags the importer was called with. A bitwise
  28. * combination of #aiPostProcessSteps.
  29. * @return true if the process is present in this flag fields, false if not.
  30. */
  31. bool IsActive( unsigned int pFlags) const;
  32. // -------------------------------------------------------------------
  33. /** Executes the post processing step on the given imported data.
  34. * At the moment a process is not supposed to fail.
  35. * @param pScene The imported data to work at.
  36. */
  37. void Execute( aiScene* pScene);
  38. // -------------------------------------------------------------------
  39. /** Static helper function to convert a vector/matrix from DX coords to OGL coords.
  40. * @param poMatrix The matrix to convert.
  41. */
  42. static void ConvertToOGL( aiVector3D& poVector);
  43. static void ConvertToOGL( aiMatrix3x3& poMatrix);
  44. static void ConvertToOGL( aiMatrix4x4& poMatrix);
  45. // -------------------------------------------------------------------
  46. /** Static helper function to convert a vector/matrix from OGL coords back to DX coords.
  47. * @param poMatrix The matrix to convert.
  48. */
  49. static void ConvertToDX( aiVector3D& poVector);
  50. static void ConvertToDX( aiMatrix3x3& poMatrix);
  51. static void ConvertToDX( aiMatrix4x4& poMatrix);
  52. protected:
  53. // -------------------------------------------------------------------
  54. /** Converts a single mesh to left handed coordinates.
  55. * This simply means the order of all faces is inverted.
  56. * @param pMesh The mesh to convert.
  57. */
  58. void ProcessMesh( aiMesh* pMesh);
  59. // -------------------------------------------------------------------
  60. /** Converts the given animation to LH coordinates.
  61. * The rotation and translation keys are transformed, the scale keys
  62. * work in local space and can therefore be left untouched.
  63. * @param pAnim The bone animation to transform
  64. */
  65. void ProcessAnimation( aiBoneAnim* pAnim);
  66. public:
  67. /** The transformation matrix to convert from DirectX coordinates to OpenGL coordinates. */
  68. static const aiMatrix3x3 sToOGLTransform;
  69. /** The transformation matrix to convert from OpenGL coordinates to DirectX coordinates. */
  70. static const aiMatrix3x3 sToDXTransform;
  71. };
  72. } // end of namespace Assimp
  73. #endif // AI_CONVERTTOLHPROCESS_H_INC