Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void AnimateBone(Mesh& mesh, char* boneName, float phiX, float phiY, float phiZ){
- matrix33 mx = { { 1,0,0 },{ 1,cosf(phiX),-sinf(phiX) },{ 1,sinf(phiX),cosf(phiX) } };
- matrix33 my = { { cosf(phiY),0,sinf(phiY) },{ 0,1,0 },{ -sinf(phiY),0,cosf(phiY) } };
- matrix33 mz = { { cosf(phiZ),-sinf(phiZ),0 },{ cosf(phiZ), sinf(phiX),0 },{ 0,0,1 } };
- int id = mesh.animation.GetBoneIndexOf(boneName);
- matrix44 m4 = mesh.animation.bones[id].matrix;
- mx = mx * my*mz;
- mesh.animation.bones[id].matrix.x_component().x = mx.x_component().x;
- mesh.animation.bones[id].matrix.y_component().y = mx.y_component().y;
- mesh.animation.bones[id].matrix.z_component().z = mx.z_component().z;
- //updateChilds(mesh, 1);
- updateChilds(mesh, 5);
- updateChilds(mesh, 2);
- }
- float step = 0.001;
- void AnimateArms(Mesh& mesh){
- float t = cos(angle);
- if (angle > 3)
- {
- angle = 3;
- step = -0.001;
- }
- if (angle < 0)
- {
- angle = 0;
- step = 0.001;
- }
- angle += step;
- AnimateBone(mesh, "joint2", 0, 20.0, -angle);
- AnimateBone(mesh, "joint5", 0, 20.0, -angle);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement