[ad_1]
I am making an attempt to make a skeleton animation utilizing Rust, OpenGL (particularly the gl library), loading gltf information. I loaded the interpretation and rotation data into two variables inside the vertex shader that are ANIMACAO2 and ANIMACAO3…
uniform vec3 ANIMACAO2[65]; // translate
uniform vec4 ANIMACAO3[65]; // rotate
I researched and noticed on the web that it rotates with quaternion like this:
vec3 Girar(vec3 u, vec4 q){
return 2*dot(q.xyz, u) * q.xyz + (q.w*q.w - dot(q.xyz,q.xyz)) * u + 2 * q.w * cross(q.xyz,u);
}
After which I attempted to use the transformations to the mannequin like this:
float ant = 0;
for(int i = 0; i < 4; i++){
if(ossosid[i] > ant){
ant = ossosid[i];
}else{
break;
}
pos-=ANIMACAO2[int(ossosid[i])];
vec4 angulo = ANIMACAO3[int(ossosid[i])];
angulo = vec4(angulo.x,angulo.y,angulo.z,angulo.w);
pos = Girar(pos, angulo*pesos[i]);
pos+=ANIMACAO2[int(ossosid[i])];
}
I am making an attempt to calculate the animation primarily based on what I perceive, however I’ve already tried 12 to 14 variations of the code and I nonetheless have not discovered one which works, though each time it looks like I am very near getting it proper. The place is the error within the calculation?
I am testing on fashions:
[ad_2]