class cogs::BoneTransform
Overview
Class used for effective management and manipulation with bone transformation. More…
#include <BoneTransform.h> class BoneTransform: public cogs::Transform { public: // construction BoneTransform(); BoneTransform(const glm::vec3& global_tail, const glm::mat4& global_parent_tail_transform, const float basis_roll_angle = 0.0f); BoneTransform(const BoneTransform&); BoneTransform(BoneTransform&&); // methods BoneTransform& operator=(const BoneTransform&); BoneTransform& operator=(BoneTransform&&); void StretchLength(const float& length_change); void SetLength(const float& new_length); const float& GetLength() const; const glm::mat4& GetHeadMat4() const; const glm::mat4& GetTailMat4() const; void InterpolateTo(const BoneTransform& target_transform, const float target_weight, BoneTransform* out_transform) const; virtual void SaveToStream(std::ostream& ostr) const; virtual void LoadFromStream(std::istream& istr); protected: // methods virtual void OnInvariantChange(); };
Inherited Members
public: // methods Transform& operator=(const Transform&); Transform& operator=(Transform&&); void Translate(const glm::vec3& move_vector); void SetPosition(const glm::vec3& position); const glm::vec3 GetPosition() const; void Rotate(const glm::quat& rotation); void SetRotation(const glm::quat& rotation); const glm::quat GetRotation() const; void Scale(const glm::vec3& scale); void SetScaling(const glm::vec3& scale); const glm::vec3 GetScaling() const; void Set(const glm::mat4& trans_mat); virtual const glm::mat4& GetMat4() const; void AddTransform(const Transform& transform); void InterpolateWith(const Transform& target, const float target_weight, Transform* out_transform) const; virtual void SaveToStream(std::ostream& ostr) const; virtual void LoadFromStream(std::istream& istr); Transform operator*(const Transform& t) const; operator glm::mat4() const; protected: // methods virtual void OnInvariantChange();
Detailed Documentation
Class used for effective management and manipulation with bone transformation.
Position represents offset from parent tail node in parent space. All the transformations are relative to parent bone transformation.
Construction
BoneTransform()
Creates identity bone with unit length.
BoneTransform(const glm::vec3& global_tail, const glm::mat4& global_parent_tail_transform, const float basis_roll_angle = 0.0f)
Creates child bone, oriented and stretched in length. Relative to the parent.
Parameters:
global_tail |
Global position of tail node of bone. |
global_parent_tail_transform |
Transformation matrix which describes parent space at its tail. |
basis_roll_angle |
Angular parameter which influences initial roll of generated y bone basis. |
Methods
void StretchLength(const float& length_change)
Changes length of bone by multiplying current length.
void SetLength(const float& new_length)
Resets bone length to the new value.
const float& GetLength() const
Returns bone length.
const glm::mat4& GetHeadMat4() const
Returns local transformation matrix, with origin according to the bone head position.
const glm::mat4& GetTailMat4() const
Returns local transformation matrix, with origin according to the bone tail position.
void InterpolateTo(const BoneTransform& target_transform, const float target_weight, BoneTransform* out_transform) const
Interpolates current transform with another, in a specific mix ratio.
Parameters:
target |
The Transform which to interpolate to. |
target_weight |
Defines how much of target should be taken. Value 0 results in 100% of this transform, value 1 results in 100% of target. |
out_transform |
A pointer to an object where the computed transformation will be stored. |
virtual void SaveToStream(std::ostream& ostr) const
Writes relevant information to stream.
virtual void LoadFromStream(std::istream& istr)
Reads relevant information from stream.
virtual void OnInvariantChange()
Function called each time a change on position, rotation or scaling is performed.