I did a search for IAnimatedMeshX and .x file
I did a search for IAnimatedMeshX and .x file
I did a search for IAnimatedMeshX and .x file and I found somewhere that someone else was trying to animate an .x file. I tried to use the function setMD2Animation and it works fine. But now I have two questions.
1. How can I get the animation to loop? If I could tell when the animation was over then I could set it to the first frame if I knew how to get that. A nice little code block would be nice.
2. It does seem strange not to use the IAnimatedMeshX member functions. Does anyone have any code on how to use the IAnimatedMeshX class?
Also once again I am going to sleep. Its past 2am and I have a Calc 2 Exam in the morning. Wish me luck.
Thanks again
1. How can I get the animation to loop? If I could tell when the animation was over then I could set it to the first frame if I knew how to get that. A nice little code block would be nice.
2. It does seem strange not to use the IAnimatedMeshX member functions. Does anyone have any code on how to use the IAnimatedMeshX class?
Also once again I am going to sleep. Its past 2am and I have a Calc 2 Exam in the morning. Wish me luck.
Thanks again
setMD2Animation is exclusively for .md2 files (hence the MD2 in the name).
Do u want looping behavior or non-looping behavior? If all you want is looped animation then IAnimatedMeshSceneNode::setFrameLoop(in the API docs). If you don't want things to loop it's a little more difficult. I made a mod that allowed you to set the animation as non-looping. See the FAQ forum, though you'll prob need search as the thread is a bit old. madinitaly also made a modification that's a bit less powerful in some respects than mine, but is more straight-forward to use and allows easily chained animations. See his .md3 loader thread in FAQ.
Using IAnimatedMeshX member functions affects all nodes with that mesh (though scene manager functions could be modified so each new node gets a new mesh) and also requires that you have a pointer to the mesh, not just the node.
Do u want looping behavior or non-looping behavior? If all you want is looped animation then IAnimatedMeshSceneNode::setFrameLoop(in the API docs). If you don't want things to loop it's a little more difficult. I made a mod that allowed you to set the animation as non-looping. See the FAQ forum, though you'll prob need search as the thread is a bit old. madinitaly also made a modification that's a bit less powerful in some respects than mine, but is more straight-forward to use and allows easily chained animations. See his .md3 loader thread in FAQ.
Using IAnimatedMeshX member functions affects all nodes with that mesh (though scene manager functions could be modified so each new node gets a new mesh) and also requires that you have a pointer to the mesh, not just the node.
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
Crucible of Stars
Crucible of Stars
thanks but
The reason I used the MD2 function was because of a prior post where someone showed a work around using it. But thanks I should have stated that more clearly.
Do you or anyone else have a sample code bit to show me how to load a .x file and get the pointer to the IAnimatedMeshX?
Thanks
Do you or anyone else have a sample code bit to show me how to load a .x file and get the pointer to the IAnimatedMeshX?
Thanks
Code: Select all
IAnimatedMesh *mesh=smgr->getMesh("filename.x");
IAnimatedMeshX *xmesh=dynamic_cast<IAnimatedMeshX*>(mesh);
if(!xmesh)
{
cout<<"this is not a .x mesh\n";
}
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
Crucible of Stars
Crucible of Stars
I was the one originally (I think) interested in that question
The code to load an .X file is quite simple:
So you only have to keep both pointers to pMesh and pNode. You can use the same pMesh to create several identic actors (characters, objects, etc...) in your scene. When you enable an animation using the pMesh, all the actors related to that mesh show the same animation. Then you can use the pNode of each actor to displace them or some other actions.
The problem I had was that I only kept the pointer to the SceneNodes, and I asked for a way to obtain the pointer to the Mesh
Anyway, you can animate your X models without the IAnimatedMesh, using the setFrameLoop and setAnimationSpeed methods of the IAnimatedMeshSceneNode class.
The code to load an .X file is quite simple:
Code: Select all
//Load the X file
IAnimatedMesh *pMesh = pSceneMng->getMesh("my_model.x");
if (pMesh == NULL)
{
//error
}
// Add the model to the scene
IAnimatedMeshSceneNode *pNode = pSceneMng->addAnimatedMeshSceneNode(pMesh,parent,id);
if (pNode == NULL)
{
//error
}
The problem I had was that I only kept the pointer to the SceneNodes, and I asked for a way to obtain the pointer to the Mesh
Anyway, you can animate your X models without the IAnimatedMesh, using the setFrameLoop and setAnimationSpeed methods of the IAnimatedMeshSceneNode class.
"There's always a way, if desire meets courage"
Conan of Cimmeria
Conan of Cimmeria
Now an error
Code: Select all
scene::IAnimatedMesh* iZombieMesh = smgr->getMesh("Zombie.x");
scene::IAnimatedMeshX *xmesh=dynamic_cast<scene::IAnimatedMeshX*>(iZombieMesh);
if(!xmesh)
{
cout<<"this is not a .x mesh\n";
}
Also Ryoga2k could you send me a more complete sample of what you did to get your .x file loaded and animated? Thanks
I think a correct way to do it could be:
Code: Select all
scene::IAnimatedMesh* iZombieMesh = smgr->getMesh("Zombie.x");
scene::IAnimatedMeshX *xmesh;
if (xmesh = dynamic_cast<scene::IAnimatedMeshX*>(iZombieMesh))
{
// ...
}
else
{
cout<<"this is not a .x mesh\n";
}
"There's always a way, if desire meets courage"
Conan of Cimmeria
Conan of Cimmeria
Still get error
I still get an error that gives me "abnormal program termination"
I tried DX and OpenGL but both have this issue. Does anyone have a code bit that shows how to load the .x file and then set the animation by calling the animation name and not the the key frames?
Thanks
I tried DX and OpenGL but both have this issue. Does anyone have a code bit that shows how to load the .x file and then set the animation by calling the animation name and not the the key frames?
Thanks
OK Fixed one problem and now another :)
OK I took the code above and had the crash issue. So I did a static cast and that worked.
Now my problem is how to I get xmesh into the scene manager?
This is the code I was using when I was using the IAnimatedMesh
What call do I need to make to the scene manager? I tried to change the call to addMeshSceneNode and passing the mesh from xmesh but then all I get is a static mesh when I call xmesh->setCurrentAnimation() function.
Any Help
Thanks as always
Code: Select all
scene::IAnimatedMesh* iZombieMesh = smgr->getMesh("Zombie.x");
IAnimatedMeshX *xmesh = static_cast<IAnimatedMeshX*>(iZombieMesh);
This is the code I was using when I was using the IAnimatedMesh
Code: Select all
scene::IAnimatedMeshSceneNode* iZombieNode = smgr->addAnimatedMeshSceneNode(iZombieMesh, 0, -1, core::vector3df(0, 0, 0), core::vector3df(0, 0, 0), core::vector3df(200, 200, 200));
iZombieNode->setMD2Animation("Idle");
iZombieNode->setAnimationSpeed(1000);
iZombieNode->setMaterialFlag(EMF_LIGHTING, false);
Any Help
Thanks as always
static_cast? That's odd. A static cast shouldn't work for upcasting as a static_cast is supposed to work only with safe casts. Upcasting from a base class is not a safe cast. I'm not sure why your compiler allows that. Maybe I'm missing something?
You can set the frame loop with IAnimatedMeshSceneNode::SetFrameLoop
Which animation (of however many seperate animation there are in the .x file) is determined by xmesh->setAnimation (or maybe it's setCurrentAnimation, but it's something like that)
above you say that, and you still seem to be using the md2 function. I cannot help you with that part, because as far as I know the md2 function works only with md2 files.The reason I used the MD2 function was because of a prior post where someone showed a work around using it.
smgr->addAnimatedMeshSceneNode(iZombieMesh,etc) should work. Your code there appears correct.Now my problem is how to I get xmesh into the scene manager?
You can set the frame loop with IAnimatedMeshSceneNode::SetFrameLoop
Which animation (of however many seperate animation there are in the .x file) is determined by xmesh->setAnimation (or maybe it's setCurrentAnimation, but it's something like that)
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
Crucible of Stars
Crucible of Stars