Page 1 of 1
mesh->setFrameLoop() access violation
Posted: Sun Oct 07, 2007 3:39 am
by pippy
I have a scene::IAnimatedMeshSceneNode*. I want to change its animation according to what state it's in
i can call mesh->setFrameLoop() just after it has loaded, but if I call it at render time it gets an "access violation" and crashes
any ideas why?
Posted: Sun Oct 07, 2007 5:56 am
by trivtn
I think you can use the bool variable to toggle the setFrame loop such as :
if (!active)
{
mesh->setFrameLoop();
active = true;
}
Maybe this way can help.
Posted: Mon Oct 08, 2007 4:44 am
by pippy
Thanks for your reply trivtn.
Using a boolean to set the frame loop would mean i could only set it once, and i want to change it twice
Posted: Mon Oct 08, 2007 9:48 pm
by pippy
I found the problem, it was that mesh was undefined in some cases.
so
Code: Select all
if(NULL != mesh){
//what state you are in
if(state != tmpstate){
switch (state){
case 0://idle
mesh->setFrameLoop(myType->idle_start, myType->idle_end);
tmpstate = 0;
break;
case 1://walking
mesh->setFrameLoop(myType->walk_start, myType->walk_end);
tmpstate = 1;
break;
case 2://attacking
mesh->setFrameLoop(myType->attack_start, myType->attack_end);
tmpstate = 2;
break;
case 3://attacking
mesh->setFrameLoop(myType->attack_start, myType->attack_end);
tmpstate = 3;
break;
default:
mesh->setFrameLoop(myType->idle_start, myType->idle_end);
break;
}
}
}