TDME2 1.9.121
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
11using std::map;
12using std::string;
13using std::vector;
14
18
19Skinning::Skinning()
20{
21}
22
23void 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
32void Skinning::setJoints(const vector<Joint>& joints)
33{
34 this->joints.resize(joints.size());
35 auto i = 0;
36 for (auto& joint: joints) {
37 this->joints[i++] = joint;
38 }
40}
41
42void Skinning::setVerticesJointsWeights(const vector<vector<JointWeight>>& verticesJointsWeights)
43{
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++) {
49 }
50 }
51}
52
54{
55 for (auto i = 0; i < joints.size(); i++) {
56 auto& joint = joints[i];
57 jointsByName[joint.getNodeId()] = &joint;
58 }
59}
60
61Joint* Skinning::getJointByName(const string& name)
62{
63 auto jointIt = jointsByName.find(name);
64 if (jointIt != jointsByName.end()) {
65 return jointIt->second;
66 }
67 return nullptr;
68}
Joint / Bone.
Definition: Joint.h:19
Skinning definition for nodes.
Definition: Skinning.h:27
map< string, Joint * > jointsByName
Definition: Skinning.h:32
vector< vector< JointWeight > > verticesJointsWeights
Definition: Skinning.h:31
Joint * getJointByName(const string &name)
Get joint by name.
Definition: Skinning.cpp:61
void setVerticesJointsWeights(const vector< vector< JointWeight > > &verticesJointsWeights)
Sets up vertices joints weights.
Definition: Skinning.cpp:42
vector< Joint > joints
Definition: Skinning.h:30
vector< float > weights
Definition: Skinning.h:29
void setWeights(const vector< float > &weights)
Set up weights.
Definition: Skinning.cpp:23
void setupJointsByName()
Set up joints by name.
Definition: Skinning.cpp:53
void setJoints(const vector< Joint > &joints)
Set up joints.
Definition: Skinning.cpp:32