Last active
December 30, 2015 05:49
-
-
Save adrienkaiser/7785600 to your computer and use it in GitHub Desktop.
Function to color vertices from an interpolation of its bones
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void mesh::fill_color_from_weight(int nbBones) | |
{ | |
srand(42); | |
std::vector<vec3> boneColor; | |
for(unsigned int b=0; b<nbBones; b++) | |
{ | |
// float iBone = (float)b/(float)nbBones; | |
boneColor.push_back(vec3(float(rand())/RAND_MAX,float(rand())/RAND_MAX,float(rand())/RAND_MAX)); | |
} | |
v_color.resize(v_vertices.size()); | |
for(unsigned int k=0,N=v_vertices.size();k<N;++k) | |
{ | |
vec3 color = vec3(0.0,0.0,0.0); | |
for (unsigned s = 0; s < 6; s+=1) // Pour tous les poids de skinning | |
{ | |
int bone = v_skinning[k].bones[s]; // numero de l'os = ... | |
float weight = v_skinning[k].weights[s];// /sumweight; // poids de skinning = ... | |
color += weight * boneColor[bone]; | |
} | |
v_color[k] = color; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment