2
0

SkeletalMeshComponent.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // ----------------------------------------------------------------
  2. // From Game Programming in C++ by Sanjay Madhav
  3. // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
  4. //
  5. // Released under the BSD License
  6. // See LICENSE in root directory for full details.
  7. // ----------------------------------------------------------------
  8. #pragma once
  9. #include "MeshComponent.h"
  10. #include "MatrixPalette.h"
  11. class SkeletalMeshComponent : public MeshComponent
  12. {
  13. public:
  14. SkeletalMeshComponent(class Actor* owner);
  15. // Draw this mesh component
  16. void Draw(class Shader* shader) override;
  17. void Update(float deltaTime) override;
  18. // Setters
  19. void SetSkeleton(class Skeleton* sk) { mSkeleton = sk; }
  20. // Play an animation. Returns the length of the animation
  21. float PlayAnimation(class Animation* anim, float playRate = 1.0f);
  22. TypeID GetType() const override { return TSkeletalMeshComponent; }
  23. void LoadProperties(const rapidjson::Value& inObj) override;
  24. void SaveProperties(rapidjson::Document::AllocatorType& alloc,
  25. rapidjson::Value& inObj) const override;
  26. protected:
  27. void ComputeMatrixPalette();
  28. MatrixPalette mPalette;
  29. class Skeleton* mSkeleton;
  30. class Animation* mAnimation;
  31. float mAnimPlayRate;
  32. float mAnimTime;
  33. };