COGS
Computer Graphics Structures library
BoneTransform.h
1 /*
2  Copyright (C) Skeletex Research, s.r.o. - All Rights Reserved
3  Unauthorized copying of this file, via any medium is strictly prohibited
4  Proprietary and confidential
5 */
6 #ifndef COGS_BONE_TRANSFORM_H
7 #define COGS_BONE_TRANSFORM_H
8 #include <glm/glm.hpp>
9 #include <Utils/GeometryStructures.h>
10 #include <COGS/Transform.h>
11 
12 
13 namespace cogs
14 {
15 
24  class COGS_API BoneTransform : public Transform
25  {
26  public:
27 
29  BoneTransform() = default;
30 
42  const glm::vec3 &global_tail,
43  const glm::mat4 &global_parent_tail_transform,
44  const float basis_roll_angle = 0.0f
45  );
46 
47  BoneTransform(const BoneTransform &) = default;
48  BoneTransform &operator=(const BoneTransform &) = default;
49  BoneTransform(BoneTransform &&) noexcept = default;
50  BoneTransform &operator=(BoneTransform &&) noexcept = default;
51 
53  void StretchLength(const float &length_change);
54 
56  void SetLength(const float &new_length);
57 
59  [[nodiscard]] const float &GetLength() const;
60 
62  [[nodiscard]] const glm::mat4 &GetHeadMat4() const;
63 
65  [[nodiscard]] const glm::mat4 &GetTailMat4() const;
66 
78  void InterpolateTo(const BoneTransform &target_transform, const float target_weight, BoneTransform *out_transform) const;
79 
81  virtual void SaveToStream(std::ostream &ostr) const override;
82 
84  virtual void LoadFromStream(std::istream &istr) override;
85 
86  protected:
87 
89  void OnInvariantChange() override;
90 
91  private:
92 
93  using Transform::GetMat4; // hides inherited implementation, uses GetHeadMat4() method instead
94 
95  float length = 1.0f;
96  mutable bool is_tailmat_invalid = true; // whether tail matrix should be re-calculated
97  mutable glm::mat4 tail_matrix; // cached tail transformation, re-calculated only when required
98  };
99 
100 }
101 
102 #endif /* !COGS_BONE_TRANSFORM_H */
Namespace of "Computer Graphic Structures" library, which implement many core classes and structures...
Definition: AabbHierarchy.h:8
Class used for effective management of transformation matrix by handling translation, rotation and scaling separately.
Definition: Transform.h:26
Class used for effective management and manipulation with bone transformation.
Definition: BoneTransform.h:24
virtual const glm::mat4 & GetMat4() const
Returns composed matrix of final transformation: scaling > rotation > translation.