mesh->setFrameLoop() access violation

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
pippy
Posts: 49
Joined: Sun Jul 08, 2007 11:31 pm

mesh->setFrameLoop() access violation

Post 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?
trivtn
Posts: 132
Joined: Tue Jan 17, 2006 12:30 pm
Location: Viet Nam
Contact:

Post 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.
There's something is fantastic, there's nothing is absolute.
pippy
Posts: 49
Joined: Sun Jul 08, 2007 11:31 pm

Post 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
pippy
Posts: 49
Joined: Sun Jul 08, 2007 11:31 pm

Post 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;
				}
			}
}
Post Reply