TDME2  1.9.200
Skinning.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <unordered_map>
5 #include <vector>
6 
7 #include <tdme/tdme.h>
12 
13 using std::string;
14 using std::unordered_map;
15 using std::vector;
16 
19 
20 /**
21  * Skinning definition for nodes
22  * @author andreas.drewke
23  */
25 {
26 private:
27  vector<float> weights;
28  vector<Joint> joints;
29  vector<vector<JointWeight>> verticesJointsWeights;
30  unordered_map<string, Joint*> jointsByNodeIds;
31 
32 public:
33  // forbid class copy
35 
36  /**
37  * Public constructor
38  */
39  Skinning();
40 
41  /**
42  * @return weights
43  */
44  inline const vector<float>& getWeights() {
45  return weights;
46  }
47 
48  /**
49  * Set up weights
50  * @param weights weights
51  */
52  void setWeights(const vector<float>& weights);
53 
54  /**
55  * @return all joints
56  */
57  inline const vector<Joint>& getJoints() {
58  return joints;
59  }
60 
61  /**
62  * Set up joints
63  * @param joints joints
64  */
65  void setJoints(const vector<Joint>& joints);
66 
67  /**
68  * @return all vertex joints
69  */
70  inline const vector<vector<JointWeight>>& getVerticesJointsWeights() {
71  return verticesJointsWeights;
72  }
73 
74  /**
75  * Sets up vertices joints weights
76  * @param verticesJointsWeights verticesJointsWeights
77  */
78  void setVerticesJointsWeights(const vector<vector<JointWeight>>& verticesJointsWeights);
79 
80  /**
81  * Get joint by node id
82  * @param nodeId node id
83  * @return joint or nullptr if not found
84  */
85  inline Joint* getJointByNodeId(const string& nodeId) {
86  auto jointIt = jointsByNodeIds.find(nodeId);
87  if (jointIt != jointsByNodeIds.end()) return jointIt->second;
88  return nullptr;
89  }
90 
91 private:
92 
93  /**
94  * Set up joints by node ids hash map
95  */
96  void setupJointsByNodeIds();
97 };
Joint / Bone.
Definition: Joint.h:19
Skinning definition for nodes.
Definition: Skinning.h:25
const vector< float > & getWeights()
Definition: Skinning.h:44
const vector< vector< JointWeight > > & getVerticesJointsWeights()
Definition: Skinning.h:70
Joint * getJointByNodeId(const string &nodeId)
Get joint by node id.
Definition: Skinning.h:85
void setVerticesJointsWeights(const vector< vector< JointWeight >> &verticesJointsWeights)
Sets up vertices joints weights.
Definition: Skinning.cpp:42
void setupJointsByNodeIds()
Set up joints by node ids hash map.
Definition: Skinning.cpp:53
vector< vector< JointWeight > > verticesJointsWeights
Definition: Skinning.h:29
vector< Joint > joints
Definition: Skinning.h:28
vector< float > weights
Definition: Skinning.h:27
unordered_map< string, Joint * > jointsByNodeIds
Definition: Skinning.h:30
void setWeights(const vector< float > &weights)
Set up weights.
Definition: Skinning.cpp:23
Skinning()
Public constructor.
Definition: Skinning.cpp:19
const vector< Joint > & getJoints()
Definition: Skinning.h:57
void setJoints(const vector< Joint > &joints)
Set up joints.
Definition: Skinning.cpp:32
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6