SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLJoint.h
Go to the documentation of this file.
1 /**
2  * \file SLJoint.h
3  * \date Autumn 2014
4  * \authors Marc Wacker, Marcus Hudritsch
5  * \copyright http://opensource.org/licenses/GPL-3.0
6  * \remarks Please use clangformat to format the code. See more code style on
7  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
8 */
9 
10 #ifndef SLBONE_H
11 #define SLBONE_H
12 
13 #include <SLNode.h>
14 
15 //-----------------------------------------------------------------------------
16 class SLAnimSkeleton;
17 //-----------------------------------------------------------------------------
18 //! Specialized SLNode that represents a single joint (or bone) in a skeleton
19 /*!
20 The main addition of SLJoint to the base SLNode is the offset matrix.
21 The offset matrix is the inverse transformation of the joint's binding pose in
22 mesh space. It is used to transform the vertices of a rigged mesh to the origin
23 of the joint to be able to manipulate them in the join's space.
24 The ID of the joint must be unique among all joints in the parent skeleton.
25 */
26 class SLJoint : public SLNode
27 {
28 public:
29  SLJoint(SLuint handle,
30  SLAnimSkeleton* creator);
31  SLJoint(const SLstring& name,
32  SLuint handle,
33  SLAnimSkeleton* creator);
34 
36  SLJoint* createChild(const SLstring& name, SLuint id);
37 
38  void calcMaxRadius(const SLVec3f& vec);
40 
41  void needUpdate();
42 
43  // Setters
44  void offsetMat(const SLMat4f& mat) { _offsetMat = mat; }
45 
46  // Getters
47  SLuint id() const { return _id; }
48  const SLMat4f& offsetMat() const { return _offsetMat; }
49  SLfloat radius() const { return _radius; }
50 
51 protected:
52  SLuint _id; //!< unique id inside its parent skeleton
53  SLAnimSkeleton* _skeleton; //!< the skeleton this joint belongs to
54  SLMat4f _offsetMat; //!< matrix transforming this joint from bind pose to world pose
55  SLfloat _radius; //!< info for the mesh this skeleton is bound to (should be moved to a skeleton instance class later, or removed entierely)
56 };
57 //-----------------------------------------------------------------------------
58 typedef vector<SLJoint*> SLVJoint;
59 //-----------------------------------------------------------------------------
60 #endif
float SLfloat
Definition: SL.h:173
unsigned int SLuint
Definition: SL.h:171
string SLstring
Definition: SL.h:158
vector< SLJoint * > SLVJoint
Definition: SLJoint.h:58
SLAnimSkeleton keeps track of a skeletons joints and animations.
Specialized SLNode that represents a single joint (or bone) in a skeleton.
Definition: SLJoint.h:27
SLMat4f calcFinalMat()
Definition: SLJoint.cpp:59
SLuint id() const
Definition: SLJoint.h:47
void offsetMat(const SLMat4f &mat)
Definition: SLJoint.h:44
SLJoint(SLuint handle, SLAnimSkeleton *creator)
Definition: SLJoint.cpp:16
SLMat4f _offsetMat
matrix transforming this joint from bind pose to world pose
Definition: SLJoint.h:54
SLAnimSkeleton * _skeleton
the skeleton this joint belongs to
Definition: SLJoint.h:53
void calcMaxRadius(const SLVec3f &vec)
Definition: SLJoint.cpp:51
SLJoint * createChild(SLuint id)
Definition: SLJoint.cpp:33
SLfloat radius() const
Definition: SLJoint.h:49
const SLMat4f & offsetMat() const
Definition: SLJoint.h:48
void needUpdate()
Definition: SLJoint.cpp:66
SLuint _id
unique id inside its parent skeleton
Definition: SLJoint.h:52
SLfloat _radius
info for the mesh this skeleton is bound to (should be moved to a skeleton instance class later,...
Definition: SLJoint.h:55
SLNode represents a node in a hierarchical scene graph.
Definition: SLNode.h:147
const SLstring & name() const
Definition: SLObject.h:38