首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

关键帧跟动画

2013-10-31 
关键帧和动画关键帧和动画Keyframes and Animation关键帧就是预先记录各个级别的动画数据。前面的机械手和

关键帧和动画

关键帧和动画

Keyframes and Animation

关键帧就是预先记录各个级别的动画数据。前面的机械手和太阳系系统都是在运行的时候计算出动画的。

struct Keyframe{ float time; D3DXQUATERNION R; D3DXVECTOR3 S; D3DXVECTOR3 T;}; //用L返回计算所得的变换矩阵。void interpolateBone(Keyframe& K0, Keyframe& K1, D3DXMATRIX& L){ // Transform to [0, 1] float t0 = K0.time; float t1 = K1.time; float lerpTime = (t - t0) / (t1 - t0); // Compute interpolated RST values. D3DXVECTOR3 lerpedT; D3DXVECTOR3 lerpedS; D3DXQUATERNION lerpedR; D3DXVec3Lerp(&lerpedT, &K0.T, &K1.T, lerpTime);//Direct3D函数,线性插值算法 D3DXVec3Lerp(&lerpedS, &K0.S, &K1.S, lerpTime); D3DXQuaternionSlerp(&lerpedR, &K0.R, &K1.R, lerpTime);//圆形插值算法 // Build and return the interpolated to-parent // matrix for this bone. D3DXMATRIX T, S, R; D3DXMatrixTranslation(&T, lerpedT.x, lerpedT.y, lerpedT.z); D3DXMatrixScaling(&S, lerpedS.x, lerpedS.y, lerpedS.z); D3DXMatrixRotationQuaternion(&R, &lerpedQ); L = R * S * T;//用L返回计算所得的变换矩阵。}

 

.X文件可以存储相关矩阵信息。D3DX中有API IDSDXAnimationController接口可以自动计算其中间位置。

 

 

热点排行