assimpAppMesh.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _ASSIMP_APPMESH_H_
  23. #define _ASSIMP_APPMESH_H_
  24. #ifndef _APPMESH_H_
  25. #include "ts/loader/appMesh.h"
  26. #endif
  27. #ifndef _TSSHAPELOADER_H_
  28. #include "ts/loader/tsShapeLoader.h"
  29. #endif
  30. #ifndef _ASSIMP_APPNODE_H_
  31. #include "ts/assimp/assimpAppNode.h"
  32. #endif
  33. class AssimpAppMesh : public AppMesh
  34. {
  35. typedef AppMesh Parent;
  36. protected:
  37. class AssimpAppNode* appNode; ///< Pointer to the node that owns this mesh
  38. const struct aiMesh* mMeshData;
  39. bool mIsSkinMesh;
  40. static bool fixedSizeEnabled; ///< Set to true to fix the detail size to a particular value for all geometry
  41. static S32 fixedSize; ///< The fixed detail size value for all geometry
  42. public:
  43. void computeBounds(Box3F& bounds) override;
  44. TSMesh* constructTSMesh() override;
  45. AssimpAppMesh(const struct aiMesh* mesh, AssimpAppNode* node);
  46. ~AssimpAppMesh()
  47. {
  48. //delete geomExt;
  49. }
  50. void lookupSkinData() override;
  51. static void fixDetailSize(bool fixed, S32 size=2)
  52. {
  53. fixedSizeEnabled = fixed;
  54. fixedSize = size;
  55. }
  56. /// Get the name of this mesh
  57. ///
  58. /// @return A string containing the name of this mesh
  59. const char *getName(bool allowFixed=true) override;
  60. //-----------------------------------------------------------------------
  61. /// Get a floating point property value
  62. ///
  63. /// @param propName Name of the property to get
  64. /// @param defaultVal Reference to variable to hold return value
  65. ///
  66. /// @return True if a value was set, false if not
  67. bool getFloat(const char *propName, F32 &defaultVal) override
  68. {
  69. return appNode->getFloat(propName,defaultVal);
  70. }
  71. /// Get an integer property value
  72. ///
  73. /// @param propName Name of the property to get
  74. /// @param defaultVal Reference to variable to hold return value
  75. ///
  76. /// @return True if a value was set, false if not
  77. bool getInt(const char *propName, S32 &defaultVal) override
  78. {
  79. return appNode->getInt(propName,defaultVal);
  80. }
  81. /// Get a boolean property value
  82. ///
  83. /// @param propName Name of the property to get
  84. /// @param defaultVal Reference to variable to hold return value
  85. ///
  86. /// @return True if a value was set, false if not
  87. bool getBool(const char *propName, bool &defaultVal) override
  88. {
  89. return appNode->getBool(propName,defaultVal);
  90. }
  91. /// Return true if this mesh is a skin
  92. bool isSkin() override
  93. {
  94. return mIsSkinMesh;
  95. }
  96. /// Generate the vertex, normal and triangle data for the mesh.
  97. ///
  98. /// @param time Time at which to generate the mesh data
  99. /// @param objectOffset Transform to apply to the generated data (bounds transform)
  100. void lockMesh(F32 time, const MatrixF& objOffset) override;
  101. /// Get the transform of this mesh at a certain time
  102. ///
  103. /// @param time Time at which to get the transform
  104. ///
  105. /// @return The mesh transform at the specified time
  106. MatrixF getMeshTransform(F32 time) override;
  107. F32 getVisValue(F32 t) override;
  108. };
  109. #endif // _COLLADA_APPMESH_H_