appMesh.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 _APPMESH_H_
  23. #define _APPMESH_H_
  24. #ifndef _MMATH_H_
  25. #include "math/mMath.h"
  26. #endif
  27. #ifndef _TVECTOR_H_
  28. #include "core/util/tVector.h"
  29. #endif
  30. #ifndef _APPMATERIAL_H_
  31. #include "ts/loader/appMaterial.h"
  32. #endif
  33. #ifndef _APPSEQUENCE_H_
  34. #include "ts/loader/appSequence.h"
  35. #endif
  36. class AppNode;
  37. class AppMesh
  38. {
  39. public:
  40. // Mesh and skin elements
  41. Vector<Point3F> points;
  42. Vector<Point3F> normals;
  43. Vector<Point2F> uvs;
  44. Vector<Point2F> uv2s;
  45. Vector<ColorI> colors;
  46. Vector<TSDrawPrimitive> primitives;
  47. Vector<U32> indices;
  48. // Skin elements
  49. Vector<F32> weight;
  50. Vector<S32> boneIndex;
  51. Vector<S32> vertexIndex;
  52. Vector<S32> nodeIndex;
  53. Vector<MatrixF> initialTransforms;
  54. Vector<Point3F> initialVerts;
  55. Vector<Point3F> initialNorms;
  56. U32 flags;
  57. U32 vertsPerFrame;
  58. S32 numFrames;
  59. S32 numMatFrames;
  60. // Loader elements (can be discarded after loading)
  61. S32 detailSize;
  62. MatrixF objectOffset;
  63. Vector<AppNode*> bones;
  64. static Vector<AppMaterial*> appMaterials;
  65. public:
  66. AppMesh();
  67. virtual ~AppMesh();
  68. void computeBounds(Box3F& bounds);
  69. void computeNormals();
  70. // Create a TSMesh object
  71. TSMesh* constructTSMesh();
  72. virtual const char * getName(bool allowFixed=true) = 0;
  73. virtual MatrixF getMeshTransform(F32 time) = 0;
  74. virtual F32 getVisValue(F32 time) = 0;
  75. virtual bool getFloat(const char* propName, F32& defaultVal) = 0;
  76. virtual bool getInt(const char* propName, S32& defaultVal) = 0;
  77. virtual bool getBool(const char* propName, bool& defaultVal) = 0;
  78. virtual bool animatesVis(const AppSequence* appSeq) { return false; }
  79. virtual bool animatesMatFrame(const AppSequence* appSeq) { return false; }
  80. virtual bool animatesFrame(const AppSequence* appSeq) { return false; }
  81. virtual bool isBillboard();
  82. virtual bool isBillboardZAxis();
  83. virtual bool isSkin() { return false; }
  84. virtual void lookupSkinData() = 0;
  85. virtual void lockMesh(F32 t, const MatrixF& objOffset) { }
  86. };
  87. #endif // _APPMESH_H_