이 코드는 엄청난 엉망진창처럼 보입니다. 그래서 내가 할 수있는 말을하기 위해 최선을 다했습니다 ... 누군가 정기적으로 골격 애니메이션을 사용한다면, 여기에.부스트를 사용하여 보간 : 타이머와 slerp, quaternions
내가 가진 문제는 float interp = (next-current)/(next-start);
이 예상했던 것, 예를 들어 1보다 큰 값과 마이너스 값 ... 이것은 애니메이션이 표시되지 않는 또 다른 기본적인 실수가 아닌 이유입니다. 분명히 튀어 나와있는 것이 있으면 알려주세요.
m_animations
은 조인트에 대한 모든 키 프레임 정보를 저장합니다. 난 내 프로그램을 실행할 때 또한
void Animation::getRotation(Joint& J) {
int i=0,j=0; //i for bone to animation j for which keyframe in animation
float start, next, current = m_time.elapsed(); //storing time elapsed to keep it the same thoughout method to avoid errors
for (i=0; i<m_animations.size(); i++) {
if(m_animations[i].m_bname == J.name) //finds which bone is being animated
break;
} //retrieve the correct 'anim' for Joint
if (current > m_animations[i].rx_time[m_animations[i].rx_time.size()-1]) { //checks to see if end of animation
m_time.restart();
current = m_time.elapsed(); //resets the animation at its end
}
for (j=0; j<m_animations[i].rx_time.size()-1; j++) {
if(m_animations[i].rx_time[j] >= next && next < m_animations[i].rx_time[j+1]) { //finds the keyframe
start = m_animations[i].rx_time[j]; //start time of current frame
next = m_animations[i].rx_time[j+1]; //end time of current frame
break;
}
}
cout << start <<" "<< current <<" "<< m_time.elapsed() <<" "<< next << endl;
//Get start and end quaternions for slerp
Rotation3 Rj(m_animations[i].rx_angle[j], m_animations[i].ry_angle[j], m_animations[i].rz_angle[j], J.translation);
J.quat = Rj.GetQuat(); //rotating to
Rotation3 R = Rotation3(m_animations[i].rx_angle[j+1], m_animations[i].ry_angle[j+1], m_animations[i].rz_angle[j+1], J.translation);
Quat4 q = R.GetQuat(); //rotating from
float interp = (next-current)/(next-start); //find interpolation point
Quat4 slerp = Slerp(J.quat, q, interp); //sphereical linear interpolation
R = Rotation3(slerp,J.translation);
J.rotation.PasteRotation(R.GetRotationMatrix());
}
는 heres는 getRotation를 호출하는 업데이트 골격 기능을하는 데 도움이 경우는
void Animation::update_skeleton(Joint& J) {
getRotation(J);
J.world.PasteTranslation(J.translation); //world becomes translation matrix
J.world *= J.rotation;
if(J.pName != "") {
J.world = Mat4(J.parent->world) *= J.world; //as not to overwrite the parents world matrix
}
J.translation = J.world.ExtractTranslation();
for(int i=0; i<J.children.size(); i++) {
update_skeleton(*J.children[i]);
}
}
또한, 하나 개의 공동이있는 것처럼 수 ... 그래서 추측 메신저 보인다 getRotation 동안 J.translation
값이 잘못되었을 수도 있지만 내 보간 문제를 해결하면이 문제를 해결할 수 있기를 바랍니다.
도움이 될 것입니다.
방금 rx_time의 값이 변경되고 있다는 것을 알았습니다 ... 4.04로 시작해야합니다. 그 다음에 2.48, 1로 내려 가서 그 프로세스를 반복합니다 ... 그리고 나는 볼 수 없습니다. 그 데이터를 변경하는 곳이면 어디든지 – CurtisJC