MD2 Animation Not Playing Correctly
-
- Posts: 29
- Joined: Wed Oct 12, 2005 9:09 am
MD2 Animation Not Playing Correctly
This is so much of a programming question rather than a modelling one. I've created a custom MD2 model and exported it. When I load it into my program. It seems to just playthrough all the animations available, and not just the STAND animation like it's supposed to. When I hit the run button, it jumps to the first frame of the run animation and pauses there.
I've looked at the model using MD2Viewer and the animations are FINE. I've only animated 12 frames even though the qc file states up to 200 frames. I'm not sure what is causing the animation errors on my model. Is there something extra that needs to be done?
This is my qc:
// Sample MD2 config, copy into export directory
$modelname faerie.md2
$origin 0.0 0.0 0.0
// sequences
$sequence stand 0 9
$sequence run 10 12
$sequence attack 16 25
$sequence paint1 26 32
$sequence jump 33 40
$sequence flip 41 50
$sequence salute 51 57
$sequence taunt 58 65
$sequence wave 66 70
$sequence point 90 130
$sequence crstnd 131 140
$sequence crwalk 141 150
$sequence crattak 151 160
$sequence crpain 161 165
$sequence crdeath 166 170
$sequence death1 171 180
$sequence death2 181 190
$sequence death3 191 200
I exported the model with the same name as in the qc. The thing that bugs me is that it shows up fine in MD2Viewer. The Stand and Run animations are there. But in-game the model just plays all the animations.
I've looked at the model using MD2Viewer and the animations are FINE. I've only animated 12 frames even though the qc file states up to 200 frames. I'm not sure what is causing the animation errors on my model. Is there something extra that needs to be done?
This is my qc:
// Sample MD2 config, copy into export directory
$modelname faerie.md2
$origin 0.0 0.0 0.0
// sequences
$sequence stand 0 9
$sequence run 10 12
$sequence attack 16 25
$sequence paint1 26 32
$sequence jump 33 40
$sequence flip 41 50
$sequence salute 51 57
$sequence taunt 58 65
$sequence wave 66 70
$sequence point 90 130
$sequence crstnd 131 140
$sequence crwalk 141 150
$sequence crattak 151 160
$sequence crpain 161 165
$sequence crdeath 166 170
$sequence death1 171 180
$sequence death2 181 190
$sequence death3 191 200
I exported the model with the same name as in the qc. The thing that bugs me is that it shows up fine in MD2Viewer. The Stand and Run animations are there. But in-game the model just plays all the animations.
-
- Posts: 395
- Joined: Fri Apr 08, 2005 8:46 pm
Irrlicht animation play back has to be told when to start and stop, otherwise default behavior is what you see. Its like a tape recorder, you have to wind it to the animation you want.
heres a code snippet I use to play an .X animation
look at the help file for setFrameLoop, and the MD2 object
for:
virtual bool irr::scene::IAnimatedMeshMD2::getFrameLoop ( const c8 * name,
s32 & outBegin,
s32 & outEnd,
s32 & outFps
) const [pure virtual]
hth
heres a code snippet I use to play an .X animation
Code: Select all
personNode->setAnimationSpeed(25);
personNode->setLoopMode(true);
personNode->setFrameLoop(startAnimidx,stopAnimidx);
for:
virtual bool irr::scene::IAnimatedMeshMD2::getFrameLoop ( const c8 * name,
s32 & outBegin,
s32 & outEnd,
s32 & outFps
) const [pure virtual]
hth
-
- Posts: 29
- Joined: Wed Oct 12, 2005 9:09 am
I know what you mean. The thing is, it works when I put like faerie.md2 or sydney.md2 in. It's this model. I'm not sure what exactly I have to do for the model to work in Irrlicht. As far as I know now, the MD2 model has it's animation names correct, but it just doesn't play correctly when loaded in Irrlicht.
EDIT: Also, I am using setMD2Animation.
EDIT2: I've uploaded the model to my website if anyone wants to try to see what's wrong.
http://www.samuelheng.com/faerie.md2
It's called faerie because I'm lazy to rename my source.
EDIT: Also, I am using setMD2Animation.
EDIT2: I've uploaded the model to my website if anyone wants to try to see what's wrong.
http://www.samuelheng.com/faerie.md2
It's called faerie because I'm lazy to rename my source.
-
- Posts: 29
- Joined: Wed Oct 12, 2005 9:09 am
-
- Posts: 370
- Joined: Mon Aug 29, 2005 10:54 pm
- Location: http://web.utk.edu/~pfox1
-
- Posts: 29
- Joined: Wed Oct 12, 2005 9:09 am
scene::IAnimatedMeshSceneNode* anmh = smgr->addAnimatedMeshSceneNode(
smgr->getMesh("Media\\horse.md2"));
scene::ISceneNodeAnimator* anim2 = smgr->createFollowSplineAnimator(device->getTimer()->getTime(),
points);
anmh->addAnimator(anim2);
anim2->drop();
anmh->setMaterialFlag(video::EMF_LIGHTING, false);
anmh->setFrameLoop(8, 96);
anmh->setAnimationSpeed(60);
anmh->setRotation(core::vector3df(0.0f,90.0f,0.0f));
anmh->setScale(core::vector3df(0.1750f,0.175f,0.1750f));
anmh->setMaterialTexture(0, driver->getTexture("Media\\horse.pcx"));
This code plays the first 12 frames of the horse animation
smgr->getMesh("Media\\horse.md2"));
scene::ISceneNodeAnimator* anim2 = smgr->createFollowSplineAnimator(device->getTimer()->getTime(),
points);
anmh->addAnimator(anim2);
anim2->drop();
anmh->setMaterialFlag(video::EMF_LIGHTING, false);
anmh->setFrameLoop(8, 96);
anmh->setAnimationSpeed(60);
anmh->setRotation(core::vector3df(0.0f,90.0f,0.0f));
anmh->setScale(core::vector3df(0.1750f,0.175f,0.1750f));
anmh->setMaterialTexture(0, driver->getTexture("Media\\horse.pcx"));
This code plays the first 12 frames of the horse animation
-
- Posts: 29
- Joined: Wed Oct 12, 2005 9:09 am
#include <stdio.h>
#include <wchar.h>
#include <irrlicht.h>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
bool IsStanding ;
scene::ISceneNode* node = 0;
IrrlichtDevice* device = 0;
int main()
{
device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640, 480),32, false, false, false );
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
IsStanding = true; // change this value to change the animation frames!
scene::IAnimatedMeshSceneNode* anms = smgr->addAnimatedMeshSceneNode(smgr->getMesh("faerie.md2"));
anms->setMaterialFlag(video::EMF_LIGHTING, false);
if(IsStanding)
anms->setFrameLoop(0, 72);
else
anms->setFrameLoop(80, 96);
anms->setAnimationSpeed(30);
anms->setRotation(core::vector3df(0,180.0f,0));
smgr->addCameraSceneNodeFPS(0, 100.0f, 100.0f);
device->getCursorControl()->setVisible(false);
while(device->run())
{
driver->beginScene(true, true, video::SColor(255,113,113,133));
smgr->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
#include <wchar.h>
#include <irrlicht.h>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
bool IsStanding ;
scene::ISceneNode* node = 0;
IrrlichtDevice* device = 0;
int main()
{
device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640, 480),32, false, false, false );
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
IsStanding = true; // change this value to change the animation frames!
scene::IAnimatedMeshSceneNode* anms = smgr->addAnimatedMeshSceneNode(smgr->getMesh("faerie.md2"));
anms->setMaterialFlag(video::EMF_LIGHTING, false);
if(IsStanding)
anms->setFrameLoop(0, 72);
else
anms->setFrameLoop(80, 96);
anms->setAnimationSpeed(30);
anms->setRotation(core::vector3df(0,180.0f,0));
smgr->addCameraSceneNodeFPS(0, 100.0f, 100.0f);
device->getCursorControl()->setVisible(false);
while(device->run())
{
driver->beginScene(true, true, video::SColor(255,113,113,133));
smgr->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
-
- Posts: 29
- Joined: Wed Oct 12, 2005 9:09 am
-
- Posts: 29
- Joined: Wed Oct 12, 2005 9:09 am
Sorry dude, it was my bad.
I was using setMD2Animation(scene::EMAT_STAND); and RUN and whatsoever to call my animations. Turns out it only works with the default models in Irrlicht. When I used setMD2Animation("stand"); it works perfect. Also, I've found out through some searching on the forums that if I want to use setFrameLoop(begin, end), I have to multiply the frame numbers by 8.
Can anyone tell me if I need to do the same for getFrameNr()? As in if I want to detect if a node's animation is at frame 10 do I need to write:
if (node->getFrameNr() == 80) {
//blah
}
?
I was using setMD2Animation(scene::EMAT_STAND); and RUN and whatsoever to call my animations. Turns out it only works with the default models in Irrlicht. When I used setMD2Animation("stand"); it works perfect. Also, I've found out through some searching on the forums that if I want to use setFrameLoop(begin, end), I have to multiply the frame numbers by 8.
Can anyone tell me if I need to do the same for getFrameNr()? As in if I want to detect if a node's animation is at frame 10 do I need to write:
if (node->getFrameNr() == 80) {
//blah
}
?
-
- Posts: 230
- Joined: Mon Oct 10, 2005 2:24 am
AshmenGlue wrote:Nono, my code WORKS. When I use the default faerie.md2 the CODE WORKS.
It's when I use my new model that the animation doesn't play.
Hello, my situation is just the same as yours!
by the way, what export program do you use?
And do you have any link about how to make md2 models?
Thanks!