TDME2  1.9.200
Skinning.cpp
Go to the documentation of this file.
2 
3 #include <map>
4 #include <string>
5 #include <vector>
6 
7 #include <tdme/tdme.h>
10 
11 using std::map;
12 using std::string;
13 using std::vector;
14 
18 
19 Skinning::Skinning()
20 {
21 }
22 
23 void Skinning::setWeights(const vector<float>& weights)
24 {
25  this->weights.resize(weights.size());
26  auto i = 0;
27  for (float weight: weights) {
28  this->weights[i++] = weight;
29  }
30 }
31 
32 void Skinning::setJoints(const vector<Joint>& joints)
33 {
34  this->joints.resize(joints.size());
35  auto i = 0;
36  for (const auto& joint: joints) {
37  this->joints[i++] = joint;
38  }
40 }
41 
42 void Skinning::setVerticesJointsWeights(const vector<vector<JointWeight>>& verticesJointsWeights)
43 {
44  this->verticesJointsWeights.resize(verticesJointsWeights.size());
45  for (auto i = 0; i < verticesJointsWeights.size(); i++) {
46  this->verticesJointsWeights[i].resize(verticesJointsWeights[i].size());
47  for (auto j = 0; j < verticesJointsWeights[i].size(); j++) {
48  this->verticesJointsWeights[i][j] = verticesJointsWeights[i][j];
49  }
50  }
51 }
52 
54 {
55  jointsByNodeIds.clear();
56  for (auto& joint: joints) {
57  jointsByNodeIds[joint.getNodeId()] = &joint;
58  }
59 }
Joint / Bone.
Definition: Joint.h:19
Skinning definition for nodes.
Definition: Skinning.h:25
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
void setJoints(const vector< Joint > &joints)
Set up joints.
Definition: Skinning.cpp:32