I would like it to run when I move the "model" but when it does nothing, i would like to have the "stand up" animation How can i do that ?
Sam
Moving model
-
hearsedriver
- Posts: 81
- Joined: Fri Aug 22, 2003 12:06 pm
- Location: Germany
- Contact:
Simply use the setMD2Animation method for your MD2 scenenode with the EMAT_STAND enum as parameter for the standing animation, or EMAT_RUN for the running animation.
Cheers.
Cheers.
matthias gall, lead programmer at sechsta sinn - email matthias@sechsta-sinn.de
-
Guest
I added this piece of code :
scene::ISceneNode* noeud_perso = 0;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (noeud_perso != 0 && event.EventType == irr::EET_KEY_INPUT_EVENT&&
!event.KeyInput.PressedDown)
{
switch(event.KeyInput.Key)
{
case KEY_KEY_W:
case KEY_KEY_S:
{
core::vector3df v = noeud_perso->getRotation();
v.Y += event.KeyInput.Key == KEY_KEY_W ? 20.0f : -20.0f;
noeud_perso->setRotation(v);
}
return true;
}
}
if (camera)
return camera->OnEvent(event);
return false;
}
};
But this don't affect the rotation of my model in this code :
scene::IAnimatedMeshSceneNode* noeud_perso = 0;
material.Texture1 = driver->getTexture("../../media/sydney.bmp");
material.Lighting = true;
scene::IAnimatedMesh* personnage2 = smgr->getMesh("../../media/sydney.md2");
if (personnage2)
{
noeud_perso = smgr->addAnimatedMeshSceneNode(personnage2);
noeud_perso->setPosition(core::vector3df(-40,-10,0));
noeud_perso->setAnimationSpeed(1);
noeud_perso->setMD2Animation(scene::EMAT_STAND);
noeud_perso->getMaterial(0) = material;
}
Have you got an solution ?
Sam.
scene::ISceneNode* noeud_perso = 0;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (noeud_perso != 0 && event.EventType == irr::EET_KEY_INPUT_EVENT&&
!event.KeyInput.PressedDown)
{
switch(event.KeyInput.Key)
{
case KEY_KEY_W:
case KEY_KEY_S:
{
core::vector3df v = noeud_perso->getRotation();
v.Y += event.KeyInput.Key == KEY_KEY_W ? 20.0f : -20.0f;
noeud_perso->setRotation(v);
}
return true;
}
}
if (camera)
return camera->OnEvent(event);
return false;
}
};
But this don't affect the rotation of my model in this code :
scene::IAnimatedMeshSceneNode* noeud_perso = 0;
material.Texture1 = driver->getTexture("../../media/sydney.bmp");
material.Lighting = true;
scene::IAnimatedMesh* personnage2 = smgr->getMesh("../../media/sydney.md2");
if (personnage2)
{
noeud_perso = smgr->addAnimatedMeshSceneNode(personnage2);
noeud_perso->setPosition(core::vector3df(-40,-10,0));
noeud_perso->setAnimationSpeed(1);
noeud_perso->setMD2Animation(scene::EMAT_STAND);
noeud_perso->getMaterial(0) = material;
}
Have you got an solution ?
Sam.
-
hearsedriver
- Posts: 81
- Joined: Fri Aug 22, 2003 12:06 pm
- Location: Germany
- Contact:
It worked for me perfectly. Note that due to the !event.KeyInput.PressedDown condition in the code, the rotation code is only executed when you RELEASE the W/S keys. Maybe that's the "problem"?
Cheers.
Cheers.
matthias gall, lead programmer at sechsta sinn - email matthias@sechsta-sinn.de
-
cyberbobjr
- Posts: 64
- Joined: Mon Sep 08, 2003 8:21 am
- Location: Paris, France
In the case you want to keep keyboard down during moving, use this condition instead :
Code: Select all
if (node != 0 && event.EventType == EET_KEY_INPUT_EVENT)-
Guest
-
hearsedriver
- Posts: 81
- Joined: Fri Aug 22, 2003 12:06 pm
- Location: Germany
- Contact:
Err ... I guess this was some kind of misunderstanding. The code you showed in your first post obviously does, what I told you (?) about object rotation in another thread - it rotates the model around the Y axis. Rotation is not translation. To translate your object, simply add a vector to the node position, where direction and length of the vector define the change of the position.
Cheers.
Cheers.
matthias gall, lead programmer at sechsta sinn - email matthias@sechsta-sinn.de
-
Guest
-
Guest
This is my solution :
scene::IAnimatedMeshSceneNode* model2 = 0;
public:
virtual bool OnEvent(SEvent event)
{
if (model2 != 0 && event.EventType == irr::EET_KEY_INPUT_EVENT )
{
switch(event.KeyInput.Key)
{
case KEY_KEY_W:
case KEY_KEY_S:
{
core::vector3df v = model2->getRotation();
v.Y += event.KeyInput.Key == KEY_KEY_W ? 20.0f : -20.0f;
model2->setRotation(v);
}
return true;
}
}
if (camera)
return camera->OnEvent(event);
return false;
}
};
/////////////////////////
scene::IAnimatedMesh* mesh = 0;
mesh = smgr->getMesh("../../media/sydney.md2");
if (mesh)
{
model2 = smgr->addAnimatedMeshSceneNode(mesh);
if (model2)
{
model2->setPosition(core::vector3df(-70,-15,-60));
model2->setScale(core::vector3df(2,2,2));
model2->setMD2Animation(scene::EMAT_STAND);
model2->setAnimationSpeed(20);
model2->setMaterialTexture(0, device->getVideoDriver()->getTexture("../../media/sydney.bmp"));
model2->setMaterialFlag(video::EMF_LIGHTING, true);
model2->addShadowVolumeSceneNode();
}
}
/////////////////////////////
scene::IAnimatedMeshSceneNode* model2 = 0;
public:
virtual bool OnEvent(SEvent event)
{
if (model2 != 0 && event.EventType == irr::EET_KEY_INPUT_EVENT )
{
switch(event.KeyInput.Key)
{
case KEY_KEY_W:
case KEY_KEY_S:
{
core::vector3df v = model2->getRotation();
v.Y += event.KeyInput.Key == KEY_KEY_W ? 20.0f : -20.0f;
model2->setRotation(v);
}
return true;
}
}
if (camera)
return camera->OnEvent(event);
return false;
}
};
/////////////////////////
scene::IAnimatedMesh* mesh = 0;
mesh = smgr->getMesh("../../media/sydney.md2");
if (mesh)
{
model2 = smgr->addAnimatedMeshSceneNode(mesh);
if (model2)
{
model2->setPosition(core::vector3df(-70,-15,-60));
model2->setScale(core::vector3df(2,2,2));
model2->setMD2Animation(scene::EMAT_STAND);
model2->setAnimationSpeed(20);
model2->setMaterialTexture(0, device->getVideoDriver()->getTexture("../../media/sydney.bmp"));
model2->setMaterialFlag(video::EMF_LIGHTING, true);
model2->addShadowVolumeSceneNode();
}
}
/////////////////////////////