Advertisement
masx1996

Untitled

May 20th, 2018
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. void AnimateBone(Mesh& mesh, char* boneName, float phiX, float phiY, float phiZ){
  2.     matrix33 mx = { { 1,0,0 },{ 1,cosf(phiX),-sinf(phiX) },{ 1,sinf(phiX),cosf(phiX) } };
  3.     matrix33 my = { { cosf(phiY),0,sinf(phiY) },{ 0,1,0 },{ -sinf(phiY),0,cosf(phiY) } };
  4.     matrix33 mz = { { cosf(phiZ),-sinf(phiZ),0 },{ cosf(phiZ), sinf(phiX),0 },{ 0,0,1 } };
  5.     int id = mesh.animation.GetBoneIndexOf(boneName);
  6.     matrix44 m4 = mesh.animation.bones[id].matrix;
  7.     mx = mx * my*mz;
  8.     mesh.animation.bones[id].matrix.x_component().x = mx.x_component().x;
  9.     mesh.animation.bones[id].matrix.y_component().y = mx.y_component().y;
  10.     mesh.animation.bones[id].matrix.z_component().z = mx.z_component().z;
  11.     //updateChilds(mesh, 1);
  12.     updateChilds(mesh, 5);
  13.     updateChilds(mesh, 2);
  14. }
  15.  
  16. float step = 0.001;
  17. void AnimateArms(Mesh& mesh){
  18.     float t = cos(angle);
  19.     if (angle > 3)
  20.     {
  21.         angle = 3;
  22.         step = -0.001;
  23.     }
  24.     if (angle < 0)
  25.     {
  26.         angle = 0;
  27.         step = 0.001;
  28.     }
  29.     angle += step;
  30.     AnimateBone(mesh, "joint2", 0, 20.0, -angle);
  31.     AnimateBone(mesh, "joint5", 0, 20.0, -angle);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement