assimpAppNode.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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_APPNODE_H_
  23. #define _ASSIMP_APPNODE_H_
  24. #ifndef _TDICTIONARY_H_
  25. #include "core/tDictionary.h"
  26. #endif
  27. #ifndef _APPNODE_H_
  28. #include "ts/loader/appNode.h"
  29. #endif
  30. #ifndef _COLLADA_EXTENSIONS_H_
  31. #include "ts/collada/colladaExtensions.h"
  32. #endif
  33. class AssimpAppNode : public AppNode
  34. {
  35. typedef AppNode Parent;
  36. friend class AssimpAppMesh;
  37. MatrixF getTransform(F32 time);
  38. void buildMeshList();
  39. void buildChildList();
  40. protected:
  41. const struct aiScene* mScene;
  42. const struct aiNode* mNode; ///< Pointer to the node in the Collada DOM
  43. AssimpAppNode* appParent; ///< Parent node in Collada-space
  44. public:
  45. AssimpAppNode(const struct aiScene* scene, const struct aiNode* node, AssimpAppNode* parent = 0);
  46. virtual ~AssimpAppNode()
  47. {
  48. //
  49. }
  50. //-----------------------------------------------------------------------
  51. const char *getName() { return mName; }
  52. const char *getParentName() { return mParentName; }
  53. bool isEqual(AppNode* node)
  54. {
  55. const AssimpAppNode* appNode = dynamic_cast<const AssimpAppNode*>(node);
  56. return (appNode && (appNode->mNode == mNode));
  57. }
  58. // Property look-ups: only float properties are stored, the rest are
  59. // converted from floats as needed
  60. bool getFloat(const char* propName, F32& defaultVal)
  61. {
  62. //Map<StringTableEntry,F32>::Iterator itr = mProps.find(propName);
  63. //if (itr != mProps.end())
  64. // defaultVal = itr->value;
  65. return false;
  66. }
  67. bool getInt(const char* propName, S32& defaultVal)
  68. {
  69. F32 value = defaultVal;
  70. bool ret = getFloat(propName, value);
  71. defaultVal = (S32)value;
  72. return ret;
  73. }
  74. bool getBool(const char* propName, bool& defaultVal)
  75. {
  76. F32 value = defaultVal;
  77. bool ret = getFloat(propName, value);
  78. defaultVal = (value != 0);
  79. return ret;
  80. }
  81. MatrixF getNodeTransform(F32 time);
  82. bool animatesTransform(const AppSequence* appSeq);
  83. bool isParentRoot() { return (appParent == NULL); }
  84. };
  85. #endif // _ASSIMP_APPNODE_H_