assimpAppMesh.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. AssimpAppMesh(const struct aiMesh* mesh, AssimpAppNode* node);
  44. ~AssimpAppMesh()
  45. {
  46. //delete geomExt;
  47. }
  48. void lookupSkinData();
  49. static void fixDetailSize(bool fixed, S32 size=2)
  50. {
  51. fixedSizeEnabled = fixed;
  52. fixedSize = size;
  53. }
  54. /// Get the name of this mesh
  55. ///
  56. /// @return A string containing the name of this mesh
  57. const char *getName(bool allowFixed=true);
  58. //-----------------------------------------------------------------------
  59. /// Get a floating point property value
  60. ///
  61. /// @param propName Name of the property to get
  62. /// @param defaultVal Reference to variable to hold return value
  63. ///
  64. /// @return True if a value was set, false if not
  65. bool getFloat(const char *propName, F32 &defaultVal)
  66. {
  67. return appNode->getFloat(propName,defaultVal);
  68. }
  69. /// Get an integer property value
  70. ///
  71. /// @param propName Name of the property to get
  72. /// @param defaultVal Reference to variable to hold return value
  73. ///
  74. /// @return True if a value was set, false if not
  75. bool getInt(const char *propName, S32 &defaultVal)
  76. {
  77. return appNode->getInt(propName,defaultVal);
  78. }
  79. /// Get a boolean property value
  80. ///
  81. /// @param propName Name of the property to get
  82. /// @param defaultVal Reference to variable to hold return value
  83. ///
  84. /// @return True if a value was set, false if not
  85. bool getBool(const char *propName, bool &defaultVal)
  86. {
  87. return appNode->getBool(propName,defaultVal);
  88. }
  89. /// Return true if this mesh is a skin
  90. bool isSkin()
  91. {
  92. return mIsSkinMesh;
  93. }
  94. /// Generate the vertex, normal and triangle data for the mesh.
  95. ///
  96. /// @param time Time at which to generate the mesh data
  97. /// @param objectOffset Transform to apply to the generated data (bounds transform)
  98. void lockMesh(F32 time, const MatrixF& objOffset);
  99. /// Get the transform of this mesh at a certain time
  100. ///
  101. /// @param time Time at which to get the transform
  102. ///
  103. /// @return The mesh transform at the specified time
  104. MatrixF getMeshTransform(F32 time);
  105. F32 getVisValue(F32 t);
  106. };
  107. #endif // _COLLADA_APPMESH_H_