md2 animation
i tried posting in this topic
http://www.gamedev.net/community/forums/topic.asp?topic_id=161374
but the access was denied
so, i have the same problem
can anybody post the solution to this problem?
thanks in advance
[Edited by - ComradeBG on November 7, 2006 8:17:34 AM]
If your animation is "jumpy", then I would have to guess that you're not linearly interpolating between frames. Can you show some code?
as far I understand from the topic in my first post the problem is in this function
it works for a one md2 model, but when i import more than one the 1st model is ok with the animation but the others are animating in choppy way
the problem is that elapsedTime and lastTime are giving the times for one model and i have to have these 2 variables separate for every separate model
i tried to put them in the model structure info but it didn't work =/
hope you understood me
[Edited by - ComradeBG on November 7, 2006 7:58:53 AM]
float CLoadMD2::ReturnCurrentTime(t3DModel *pModel, int nextFrame){ static float elapsedTime = 0.0f; static float lastTime = 0.0f; float time = (float)GetTickCount(); elapsedTime = time - lastTime; float t = elapsedTime / (1000.0f / kAnimationSpeed); if (elapsedTime >= (1000.0f / kAnimationSpeed) ) { pModel->currentFrame = nextFrame; lastTime = time; } return t;}
it works for a one md2 model, but when i import more than one the 1st model is ok with the animation but the others are animating in choppy way
the problem is that elapsedTime and lastTime are giving the times for one model and i have to have these 2 variables separate for every separate model
i tried to put them in the model structure info but it didn't work =/
hope you understood me
[Edited by - ComradeBG on November 7, 2006 7:58:53 AM]
look at this video
">
now i think you will understand what's the problem ;)
[Edited by - ComradeBG on November 7, 2006 8:38:53 AM]
">
now i think you will understand what's the problem ;)
[Edited by - ComradeBG on November 7, 2006 8:38:53 AM]
it will work up to 15 minutes i've just uploaded it
or try this http://rapidshare.com/files/2324061/md2anim.avi.html
[Edited by - ComradeBG on November 7, 2006 8:25:02 AM]
or try this http://rapidshare.com/files/2324061/md2anim.avi.html
[Edited by - ComradeBG on November 7, 2006 8:25:02 AM]
GetTickCount - is this a windows call - from what I can recall it's not very accurate - +- 50ms I heard. You'll need a high res timer. This may explain choppiness
Going by your code above, you're not interpolating between animation frames, you're just skipping from one frame to the next. What you should be doing is lerping the vertex positions between the two positions, so at the start of frame 0, the vertices are at the positions defined by frame 0, halfway through they're halfway between frame 0 and 1, etc.
I am interpolating but in another function
the previous one just returns the time between frames
[Edited by - ComradeBG on November 7, 2006 7:29:50 AM]
void CLoadMD2::AnimateMD2Model(t3DModel *pModel){ if(pModel->pObject.size() <= 0) return; tAnimationInfo *pAnim = &(pModel->pAnimations[pModel->currentAnim]); int nextFrame = (pModel->currentFrame + 1) % pAnim->endFrame; if(nextFrame == 0) nextFrame = pAnim->startFrame; t3DObject *pFrame = &pModel->pObject[pModel->currentFrame]; t3DObject *pNextFrame = &pModel->pObject[nextFrame]; t3DObject *pFirstFrame = &pModel->pObject[0]; float t = ReturnCurrentTime(pModel, nextFrame); glBegin(GL_TRIANGLES); for(int j = 0; j < pFrame->numOfFaces; j++) { for(int whichVertex = 0; whichVertex < 3; whichVertex++) { int vertIndex = pFirstFrame->pFaces[j].vertIndex[whichVertex]; int texIndex = pFirstFrame->pFaces[j].coordIndex[whichVertex]; if(pFirstFrame->pTexVerts) { glTexCoord2f(pFirstFrame->pTexVerts[ texIndex ].x, pFirstFrame->pTexVerts[ texIndex ].y); } CVector3 vPoint1 = pFrame->pVerts[ vertIndex ]; CVector3 vPoint2 = pNextFrame->pVerts[ vertIndex ]; glVertex3f(vPoint1.x + t * (vPoint2.x - vPoint1.x), vPoint1.y + t * (vPoint2.y - vPoint1.y), vPoint1.z + t * (vPoint2.z - vPoint1.z)); } } glEnd(); }
the previous one just returns the time between frames
[Edited by - ComradeBG on November 7, 2006 7:29:50 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement