BL_SkinDeformer.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * ***** BEGIN GPL LICENSE BLOCK *****
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software Foundation,
  16. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. *
  18. * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
  19. * All rights reserved.
  20. *
  21. * The Original Code is: all of this file.
  22. *
  23. * Contributor(s): none yet.
  24. *
  25. * ***** END GPL LICENSE BLOCK *****
  26. */
  27. /** \file BL_SkinDeformer.h
  28. * \ingroup bgeconv
  29. */
  30. #ifndef __BL_SKINDEFORMER_H__
  31. #define __BL_SKINDEFORMER_H__
  32. #ifdef _MSC_VER
  33. # pragma warning (disable:4786) /* get rid of stupid stl-visual compiler debug warning */
  34. #endif /* WIN32 */
  35. #include "CTR_HashedPtr.h"
  36. #include "BL_MeshDeformer.h"
  37. #include "BL_ArmatureObject.h"
  38. #include "DNA_mesh_types.h"
  39. #include "DNA_meshdata_types.h"
  40. #include "DNA_object_types.h"
  41. #include "BKE_armature.h"
  42. #include "RAS_Deformer.h"
  43. class BL_SkinDeformer : public BL_MeshDeformer
  44. {
  45. public:
  46. // void SetArmatureController (BL_ArmatureController *cont);
  47. virtual void Relink(CTR_Map<class CTR_HashedPtr, void*>*map);
  48. void SetArmature (class BL_ArmatureObject *armobj);
  49. BL_SkinDeformer(BL_DeformableGameObject *gameobj,
  50. struct Object *bmeshobj,
  51. class RAS_MeshObject *mesh,
  52. BL_ArmatureObject* arma = NULL);
  53. /* this second constructor is needed for making a mesh deformable on the fly. */
  54. BL_SkinDeformer(BL_DeformableGameObject *gameobj,
  55. struct Object *bmeshobj_old,
  56. struct Object *bmeshobj_new,
  57. class RAS_MeshObject *mesh,
  58. bool release_object,
  59. bool recalc_normal,
  60. BL_ArmatureObject* arma = NULL);
  61. virtual RAS_Deformer *GetReplica();
  62. virtual void ProcessReplica();
  63. virtual ~BL_SkinDeformer();
  64. bool Update (void);
  65. bool UpdateInternal (bool shape_applied);
  66. bool Apply (class RAS_IPolyMaterial *polymat);
  67. bool UpdateBuckets(void)
  68. {
  69. // update the deformer and all the mesh slots; Apply() does it well, so just call it.
  70. return Apply(NULL);
  71. }
  72. bool PoseUpdated(void)
  73. {
  74. if (m_armobj && m_lastArmaUpdate!=m_armobj->GetLastFrame()) {
  75. return true;
  76. }
  77. return false;
  78. }
  79. void ForceUpdate()
  80. {
  81. m_lastArmaUpdate = -1.0;
  82. };
  83. virtual bool ShareVertexArray()
  84. {
  85. return false;
  86. }
  87. protected:
  88. BL_ArmatureObject* m_armobj; // Our parent object
  89. float m_time;
  90. double m_lastArmaUpdate;
  91. //ListBase* m_defbase;
  92. float m_obmat[4][4]; // the reference matrix for skeleton deform
  93. bool m_releaseobject;
  94. bool m_poseApplied;
  95. bool m_recalcNormal;
  96. bool m_copyNormals; // dirty flag so we know if Apply() needs to copy normal information (used for BGEDeformVerts())
  97. struct bPoseChannel** m_dfnrToPC;
  98. short m_deformflags;
  99. void BlenderDeformVerts();
  100. void BGEDeformVerts();
  101. void UpdateTransverts();
  102. #ifdef WITH_CXX_GUARDEDALLOC
  103. MEM_CXX_CLASS_ALLOC_FUNCS("GE:BL_SkinDeformer")
  104. #endif
  105. };
  106. #endif /* __BL_SKINDEFORMER_H__ */