SkinNode.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include <boost/foreach.hpp>
  2. #include "SkinNode.h"
  3. #include "Resources/Skin.h"
  4. #include "SkinPatchNode.h"
  5. #include "Resources/Skeleton.h"
  6. //==============================================================================
  7. // Constructor =
  8. //==============================================================================
  9. SkinNode::SkinNode(bool inheritParentTrfFlag, SceneNode* parent)
  10. : SceneNode(SNT_SKIN, inheritParentTrfFlag, parent)
  11. {}
  12. //==============================================================================
  13. // Destructor =
  14. //==============================================================================
  15. SkinNode::~SkinNode()
  16. {}
  17. //==============================================================================
  18. // init =
  19. //==============================================================================
  20. void SkinNode::init(const char* filename)
  21. {
  22. skin.loadRsrc(filename);
  23. BOOST_FOREACH(const ModelPatch& patch, skin->getModelPatches())
  24. {
  25. patches.push_back(new SkinPatchNode(patch, this));
  26. }
  27. uint bonesNum = skin->getSkeleton().getBones().size();
  28. tails.resize(bonesNum);
  29. heads.resize(bonesNum);
  30. boneRotations.resize(bonesNum);
  31. boneTranslations.resize(bonesNum);
  32. }
  33. //==============================================================================
  34. // moveUpdate =
  35. //==============================================================================
  36. void SkinNode::moveUpdate()
  37. {
  38. visibilityShapeWSpace.set(tails);
  39. visibilityShapeWSpace = visibilityShapeWSpace.getTransformed(
  40. getWorldTransform());
  41. }