Hello I'm a new user to Irrlicht. I'm trying out simple movements for a character.
I've loaded a model:
scene::IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/faerie.md2"));
I did all the rest of the necessary stuff, including an Event Receiver. The updating of the model's position is done in the while loop for smooth movement. Now I want to update the model's animation when the Move Forward key is being held down.
switch(event.KeyInput.Key){
case KEY_KEY_W:
{
node->setMD2Animation(scene::EMAT_RUN);
}
So I added the above code in my event receiver. Thing is, when I compiled, I get an error saying setMD2Animation is not a member of irr::scene::ISceneNode.
I thought I've already declared 'node' as an IAnimatedMeshSceneNode. What is the problem here?
Set MD2 Animation
I'm using a java binding for Irrlicht and when i want to set the MD2 animation i need to use EMD2_ANIMATION_TYPE.EMAT_RUN as the param, although that may just be because it's a java binding that it's different, as it doesn't sound as if that would solve your problem...
And the strange thing is that i've just decided that today i'm going to have a bash at animating my MD2s when they move, so i may have to ask you for some help if i get a bit stuck!
And the strange thing is that i've just decided that today i'm going to have a bash at animating my MD2s when they move, so i may have to ask you for some help if i get a bit stuck!
The 'node' in the switch statement probably isn't the same as the one youv'e defined in the code above, maybe called the same thing, but different variables.
Double check your code, and change the name to make sure your'e referencing the correct variable.
________
Maryjane
Double check your code, and change the name to make sure your'e referencing the correct variable.
________
Maryjane
Last edited by area51 on Tue Feb 22, 2011 1:15 pm, edited 1 time in total.
-
- Posts: 29
- Joined: Wed Oct 12, 2005 9:09 am
are51: You're right. There was a pointer stored to a node that I missed. It was an ISceneNode. I've made the necessary changes. There is no problem with that now.
The problem is that my logic for implementing moving forward smoothly whilst executing the run animation is flawed. It doesn't work, even though the thing compiles fine. Heh so I'm sorry JP, at this stage I'm still figuring it out.
The problem is that my logic for implementing moving forward smoothly whilst executing the run animation is flawed. It doesn't work, even though the thing compiles fine. Heh so I'm sorry JP, at this stage I'm still figuring it out.
-
- Posts: 29
- Joined: Wed Oct 12, 2005 9:09 am
JP, I figured it out. The model updates fine now.
Go to this Wiki link : http://irrforge.org/index.php/Simple_wa ... ard_Events
Copy the class and paste it in your main.cpp. Make sure you include the necessary header files or DWORD won't be recognized. Also, set the functions in the class to public.
After that call it in the main loop as such:
Oh, don't forget to declare a boolean run. That's it, the animation should play fine. I hope this helps you.
Go to this Wiki link : http://irrforge.org/index.php/Simple_wa ... ard_Events
Copy the class and paste it in your main.cpp. Make sure you include the necessary header files or DWORD won't be recognized. Also, set the functions in the class to public.
After that call it in the main loop as such:
Code: Select all
while(device->run()) {
TTinyEvent* Inp = new TTinyEvent;
if (Inp->KeyDown(irr::Key_UP) && run == false) {
//movement code here blahblahblah
playernode->setMD2Animation(scene::EMAT_RUN);
run = true;
}
if (Inp->KeyUp(irr::Key_UP) && run == true) {
playernode->setMD2Animation(scene::EMAT_STAND);
run=false;
}