SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLJoint Class Reference

Specialized SLNode that represents a single joint (or bone) in a skeleton. More...

#include <SLJoint.h>

Inheritance diagram for SLJoint:
[legend]

Public Member Functions

 SLJoint (SLuint handle, SLAnimSkeleton *creator)
 
 SLJoint (const SLstring &name, SLuint handle, SLAnimSkeleton *creator)
 
SLJointcreateChild (SLuint id)
 
SLJointcreateChild (const SLstring &name, SLuint id)
 
void calcMaxRadius (const SLVec3f &vec)
 
SLMat4f calcFinalMat ()
 
void needUpdate ()
 
void offsetMat (const SLMat4f &mat)
 
SLuint id () const
 
const SLMat4foffsetMat () const
 
SLfloat radius () const
 
- Public Member Functions inherited from SLNode
 SLNode (const SLstring &name="Node")
 Construct a new SLNode::SLNode object. More...
 
 SLNode (SLMesh *mesh, const SLstring &name="Node")
 
 SLNode (SLMesh *mesh, const SLVec3f &translation, const SLstring &name)
 
 ~SLNode () override
 
virtual void cull3DRec (SLSceneView *sv)
 
virtual void cullChildren3D (SLSceneView *sv)
 Initializer function to call SLNode::cull3DRec recursively. More...
 
virtual void cull2DRec (SLSceneView *sv)
 
virtual bool hitRec (SLRay *ray)
 
virtual void statsRec (SLNodeStats &stats)
 
virtual SLNodecopyRec ()
 
virtual SLAABBoxupdateAABBRec (SLbool updateAlsoAABBinOS)
 
virtual void dumpRec ()
 
void setDrawBitsRec (SLuint bit, SLbool state)
 
void setPrimitiveTypeRec (SLGLPrimitiveType primitiveType)
 
virtual void addMesh (SLMesh *mesh)
 
virtual void drawMesh (SLSceneView *sv)
 Draws the single mesh. More...
 
bool removeMesh ()
 Returns true if a mesh was assigned and set it to nullptr. More...
 
bool removeMesh (SLMesh *mesh)
 Returns true if the passed mesh was assigned and sets it to nullptr. More...
 
SLint numChildren ()
 
void addChild (SLNode *child)
 
bool insertChild (SLNode *insertC, SLNode *afterC)
 
void deleteChildren ()
 
bool deleteChild ()
 
bool deleteChild (SLNode *child)
 
bool deleteChild (const SLstring &name)
 
bool removeChild (SLNode *child)
 remove child from vector of children. Removes false if not found, else true. More...
 
template<typename T >
T * find (const SLstring &name="", SLbool findRecursive=true)
 
template<typename T >
T * findChild (const SLstring &name="", SLbool findRecursive=true)
 
template<typename T >
deque< T * > findChildren (const SLstring &name="", SLbool findRecursive=true, SLbool canContain=false)
 
deque< SLNode * > findChildren (const SLMesh *mesh, SLbool findRecursive=true)
 
deque< SLNode * > findChildren (SLuint drawbit, SLbool findRecursive=true)
 
SLVec3f translationOS () const
 
SLVec3f forwardOS () const
 
SLVec3f rightOS () const
 
SLVec3f upOS () const
 
SLVec3f axisXOS () const
 
SLVec3f axisYOS () const
 
SLVec3f axisZOS () const
 
SLVec3f translationWS () const
 
SLVec3f forwardWS () const
 
SLVec3f rightWS () const
 
SLVec3f upWS () const
 
SLVec3f axisXWS () const
 
SLVec3f axisYWS () const
 
SLVec3f axisZWS () const
 
void translation (const SLVec3f &pos, SLTransformSpace relativeTo=TS_parent)
 
void translation (SLfloat x, SLfloat y, SLfloat z, SLTransformSpace relativeTo=TS_parent)
 
void rotation (const SLQuat4f &rot, SLTransformSpace relativeTo=TS_parent)
 
void rotation (SLfloat angleDeg, const SLVec3f &axis, SLTransformSpace relativeTo=TS_parent)
 
void scaling (SLfloat s)
 
void scaling (SLfloat x, SLfloat y, SLfloat z)
 
void scaling (const SLVec3f &scaling)
 
void lookAt (SLfloat targetX, SLfloat targetY, SLfloat targetZ, SLfloat upX=0, SLfloat upY=1, SLfloat upZ=0, SLTransformSpace relativeTo=TS_world)
 
void lookAt (const SLVec3f &target, const SLVec3f &up=SLVec3f::AXISY, SLTransformSpace relativeTo=TS_world)
 
void translate (const SLVec3f &vec, SLTransformSpace relativeTo=TS_object)
 
void translate (SLfloat x, SLfloat y, SLfloat z, SLTransformSpace relativeTo=TS_object)
 
void rotate (const SLQuat4f &rot, SLTransformSpace relativeTo=TS_object)
 
void rotate (SLfloat angleDeg, const SLVec3f &axis, SLTransformSpace relativeTo=TS_object)
 
void rotate (SLfloat angleDeg, SLfloat x, SLfloat y, SLfloat z, SLTransformSpace relativeTo=TS_object)
 
void rotateAround (const SLVec3f &point, SLVec3f &axis, SLfloat angleDeg, SLTransformSpace relativeTo=TS_world)
 
void scale (SLfloat s)
 
void scale (SLfloat x, SLfloat y, SLfloat z)
 
void scale (const SLVec3f &scale)
 
void scaleToCenter (SLfloat maxDim)
 
void setInitialState ()
 
void resetToInitialState ()
 
void parent (SLNode *p)
 
void entityID (SLint entityID)
 
void om (const SLMat4f &mat)
 
void animation (SLAnimation *a)
 
void castsShadows (SLbool castsShadows)
 
void needWMUpdate ()
 
void needAABBUpdate ()
 
void isSelected (bool isSelected)
 
void minLodCoverage (SLfloat minLodCoverage)
 
void levelForSM (SLubyte lfsm)
 
void onUpdateCB (function< void()> callbackFunc)
 
SLNodeparent ()
 
SLint depth () const
 
SLint entityID () const
 
const SLMat4fom ()
 
const SLMat4finitialOM ()
 
const SLMat4fupdateAndGetWM () const
 
const SLMat4fupdateAndGetWMI () const
 
SLDrawBitsdrawBits ()
 
SLbool drawBit (SLuint bit)
 
SLAABBoxaabb ()
 
SLAnimationanimation ()
 
SLbool castsShadows ()
 
SLMeshmesh ()
 
SLVNodechildren ()
 
const SLAnimSkeletonskeleton ()
 Returns the first skeleton found in the meshes. More...
 
void updateRec ()
 
virtual void doUpdate ()
 
bool updateMeshSkins (bool forceCPUSkinning, const std::function< void(SLMesh *)> &cbInformNodes)
 Update all skinned meshes recursively. More...
 
void updateMeshAccelStructs ()
 
void updateMeshMat (std::function< void(SLMaterial *m)> setMat, bool recursive)
 Updates the mesh material recursively with a material lambda. More...
 
void setMeshMat (SLMaterial *mat, bool recursive)
 Set the mesh material recursively. More...
 
bool isSelected ()
 
SLfloat minLodCoverage ()
 
SLubyte levelForSM ()
 
- Public Member Functions inherited from SLObject
 SLObject (const SLstring &Name="", const SLstring &url="")
 
virtual ~SLObject ()
 
void name (const SLstring &Name)
 
void url (const SLstring &url)
 
const SLstringname () const
 
const SLstringurl () const
 
- Public Member Functions inherited from SLEventHandler
 SLEventHandler ()
 
virtual ~SLEventHandler ()
 
virtual SLbool onMouseDown (const SLMouseButton button, const SLint x, const SLint y, const SLKey mod)
 
virtual SLbool onMouseUp (const SLMouseButton button, const SLint x, const SLint y, const SLKey mod)
 
virtual SLbool onMouseMove (const SLMouseButton button, const SLint x, const SLint y, const SLKey mod)
 
virtual SLbool onDoubleClick (const SLMouseButton button, const SLint x, const SLint y, const SLKey mod)
 
virtual SLbool onMouseWheel (const SLint delta, const SLKey mod)
 
virtual SLbool onTouch2Down (const SLint x1, const SLint y1, const SLint x2, const SLint y2)
 
virtual SLbool onTouch2Move (const SLint x1, const SLint y1, const SLint x2, const SLint y2)
 
virtual SLbool onTouch2Up (const SLint x1, const SLint y1, const SLint x2, const SLint y2)
 
virtual SLbool onTouch3Down (const SLint x1, const SLint y1)
 
virtual SLbool onTouch3Move (const SLint x1, const SLint y1)
 
virtual SLbool onTouch3Up (const SLint x1, const SLint y1)
 
virtual SLbool onKeyPress (const SLKey key, const SLKey mod)
 
virtual SLbool onKeyRelease (const SLKey key, const SLKey mod)
 
virtual SLbool onRotationPYR (const SLfloat pitchRAD, const SLfloat yawRAD, const SLfloat rollRAD)
 
void mouseRotationFactor (SLfloat rf)
 
SLfloat mouseRotationFactor ()
 

Protected Attributes

SLuint _id
 unique id inside its parent skeleton More...
 
SLAnimSkeleton_skeleton
 the skeleton this joint belongs to More...
 
SLMat4f _offsetMat
 matrix transforming this joint from bind pose to world pose More...
 
SLfloat _radius
 info for the mesh this skeleton is bound to (should be moved to a skeleton instance class later, or removed entierely) More...
 
- Protected Attributes inherited from SLNode
SLNode_parent
 pointer to the parent node More...
 
SLVNode _children
 vector of children nodes More...
 
SLMesh_mesh
 pointer to a single mesh More...
 
SLint _depth
 depth of the node in a scene tree More...
 
SLint _entityID
 ID in the SLVEntity graph for Data Oriented Design. More...
 
SLMat4f _om
 object matrix for local transforms More...
 
SLMat4f _initialOM
 the initial om state More...
 
SLMat4f _wm
 world matrix for world transform More...
 
SLMat4f _wmI
 inverse world matrix More...
 
SLbool _isWMUpToDate
 is the WM of this node still valid More...
 
SLbool _isWMIUpToDate
 is the inverse WM of this node still valid More...
 
SLbool _isAABBUpToDate
 is the saved aabb still valid More...
 
bool _castsShadows
 flag if meshes of node should cast shadows More...
 
bool _isSelected
 flag if node and one or more of its meshes are selected More...
 
SLDrawBits _drawBits
 node level drawing flags More...
 
SLAABBox _aabb
 axis aligned bounding box More...
 
SLAnimation_animation
 animation of the node More...
 
SLfloat _minLodCoverage
 Min. LOD coverage for visibility (0.0 < _minLodCoverage < 1.0) More...
 
SLubyte _levelForSM
 Level of LOD to use for shadow mapping (0 = the visible one will be drawn) More...
 
function< void()> _onUpdateCB
 Optional lambda callback once per update. More...
 
- Protected Attributes inherited from SLObject
SLstring _name
 name of an object More...
 
SLstring _url
 uniform resource locator More...
 
- Protected Attributes inherited from SLEventHandler
SLfloat _mouseRotationFactor
 Mouse rotation sensibility. More...
 
SLfloat _keyboardDeltaPos
 Delta dist. for keyboard translation. More...
 

Additional Inherited Members

- Static Public Attributes inherited from SLNode
static SLuint numWMUpdates = 0
 NO. of calls to updateWMRec per frame. More...
 
static unsigned int instanceIndex = 0
 ??? More...
 

Detailed Description

Specialized SLNode that represents a single joint (or bone) in a skeleton.

The main addition of SLJoint to the base SLNode is the offset matrix. The offset matrix is the inverse transformation of the joint's binding pose in mesh space. It is used to transform the vertices of a rigged mesh to the origin of the joint to be able to manipulate them in the join's space. The ID of the joint must be unique among all joints in the parent skeleton.

Definition at line 26 of file SLJoint.h.

Constructor & Destructor Documentation

◆ SLJoint() [1/2]

SLJoint::SLJoint ( SLuint  id,
SLAnimSkeleton creator 
)

Constructor

Definition at line 16 of file SLJoint.cpp.

17  : SLNode("Unnamed Joint"),
18  _id(id),
19  _skeleton(creator),
20  _radius(0)
21 {
22 }
SLAnimSkeleton * _skeleton
the skeleton this joint belongs to
Definition: SLJoint.h:53
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(const SLstring &name="Node")
Construct a new SLNode::SLNode object.
Definition: SLNode.cpp:40

◆ SLJoint() [2/2]

SLJoint::SLJoint ( const SLstring name,
SLuint  id,
SLAnimSkeleton creator 
)

Constructor

Definition at line 26 of file SLJoint.cpp.

27  : SLNode(name), _id(id), _skeleton(creator), _radius(0)
28 {
29 }
const SLstring & name() const
Definition: SLObject.h:38

Member Function Documentation

◆ calcFinalMat()

SLMat4f SLJoint::calcFinalMat ( )

Getter that calculates the final joint transform matrix.

Definition at line 59 of file SLJoint.cpp.

60 {
61  return updateAndGetWM() * _offsetMat;
62 }
SLMat4f _offsetMat
matrix transforming this joint from bind pose to world pose
Definition: SLJoint.h:54
const SLMat4f & updateAndGetWM() const
Definition: SLNode.cpp:703

◆ calcMaxRadius()

void SLJoint::calcMaxRadius ( const SLVec3f vec)

Updates the current max radius with the input vertex position in joint space.

Definition at line 51 of file SLJoint.cpp.

52 {
53  SLVec3f boneSpaceVec = _offsetMat * vec;
54  _radius = std::max(_radius, boneSpaceVec.length());
55 }
T length() const
Definition: SLVec3.h:122

◆ createChild() [1/2]

SLJoint * SLJoint::createChild ( const SLstring name,
SLuint  id 
)

Creation function to create a new child joint for this joint.

Definition at line 42 of file SLJoint.cpp.

43 {
44  SLJoint* joint = _skeleton->createJoint(name, id);
45  addChild(joint);
46  return joint;
47 }
SLJoint * createJoint(SLuint id)
Specialized SLNode that represents a single joint (or bone) in a skeleton.
Definition: SLJoint.h:27
void addChild(SLNode *child)
Definition: SLNode.cpp:207

◆ createChild() [2/2]

SLJoint * SLJoint::createChild ( SLuint  id)

Creation function to create a new child joint for this joint.

Definition at line 33 of file SLJoint.cpp.

34 {
35  SLJoint* joint = _skeleton->createJoint(id);
36  addChild(joint);
37  return joint;
38 }

◆ id()

SLuint SLJoint::id ( ) const
inline

Definition at line 47 of file SLJoint.h.

47 { return _id; }

◆ needUpdate()

void SLJoint::needUpdate ( )
virtual

Getter that calculates the final joint transform matrix.

Reimplemented from SLNode.

Definition at line 66 of file SLJoint.cpp.

67 {
69 
70  // a joint must always know it's creator
71  assert(_skeleton && "Joint didn't have a valid creator");
72  _skeleton->changed(true);
73 }
SLbool changed() const
virtual void needUpdate()
Definition: SLNode.cpp:616

◆ offsetMat() [1/2]

const SLMat4f& SLJoint::offsetMat ( ) const
inline

Definition at line 48 of file SLJoint.h.

48 { return _offsetMat; }

◆ offsetMat() [2/2]

void SLJoint::offsetMat ( const SLMat4f mat)
inline

Definition at line 44 of file SLJoint.h.

44 { _offsetMat = mat; }

◆ radius()

SLfloat SLJoint::radius ( ) const
inline

Definition at line 49 of file SLJoint.h.

49 { return _radius; }

Member Data Documentation

◆ _id

SLuint SLJoint::_id
protected

unique id inside its parent skeleton

Definition at line 52 of file SLJoint.h.

◆ _offsetMat

SLMat4f SLJoint::_offsetMat
protected

matrix transforming this joint from bind pose to world pose

Definition at line 54 of file SLJoint.h.

◆ _radius

SLfloat SLJoint::_radius
protected

info for the mesh this skeleton is bound to (should be moved to a skeleton instance class later, or removed entierely)

Definition at line 55 of file SLJoint.h.

◆ _skeleton

SLAnimSkeleton* SLJoint::_skeleton
protected

the skeleton this joint belongs to

Definition at line 53 of file SLJoint.h.


The documentation for this class was generated from the following files: