Animated DirectX model - animation problems

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
asteron
Posts: 4
Joined: Thu Jun 22, 2006 10:47 am

Animated DirectX model - animation problems

Post by asteron »

I have a problem with importing animated DirectX moedels into Irrlicht.

In 3D Studio Max 8 I created a plane with 50x50 polygons and applied animated noise to it. Then I exported the animation using the Quest3D exporter for .X files .

I loaded it into Irrlicht like this:

________________________________________________
#include <irrlicht.h>

using namespace irr;

#pragma comment(lib,"irrlicht.lib")

int main()
{
IrrlichtDevice *irrdev=createDevice(video::EDT_DIRECT3D9,core::dimension2d<s32>(800,600));
video::IVideoDriver* irrvideodriver=irrdev->getVideoDriver();
scene::ISceneManager* irrsmgr=irrdev->getSceneManager();
irrdev->setWindowCaption(L"Luminance Level Editor");
scene::IAnimatedMesh* mesh= irrsmgr->getMesh("x.x");
scene::IAnimatedMeshSceneNode* node= irrsmgr-> addAnimatedMeshSceneNode(mesh);

if(node)
{
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setFrameLoop(0, 100);
node->setMaterialTexture( 0, irrvideodriver->getTexture("texture.bmp") );

}
irrsmgr->addCameraSceneNode(0, core::vector3df(0,30,-40),core::vector3df(0,5,0));

while(irrdev->run())
{
irrvideodriver->beginScene(true,true,video::SColor(255,0,0,255));
irrsmgr->drawAll();
irrvideodriver->endScene();
}
irrdev->drop();
return 0;


}
_________________________________________________

I hope that you can understand the code easily...

Now... my problem is :

The mesh loads. But it doesn't animate :(

I think I haven't used the correct method... I've looked through the documentation and I stumbled upon a function IAnimatedMeshX

Unfortunately I haven't got the faintest idea on how to implement it.
The Irrlicht documentation supplies data based on the header... and, shamefully I am not able yet to understand that data.

If someone could point me to the correct solution to this problem... i would be extremely grateful :D

I mean... the syntax of the function IAnimatedMeshX or something ;)
God is real unless declared integer
Gatekeeper
Posts: 31
Joined: Fri Apr 21, 2006 12:00 am
Location: Australia

Post by Gatekeeper »

I wouldn't bother trying to get it to animate...

I've spent a lot of time on this myself. My conclusion is that you won't be able to get animation to work in the .X format.

I've made some animations (and I mean really simple ones, like a box spinning around), and saved them in .X (with both the Quest3D and Panda exporter). In the DirectX mesh viewer, they play exactly as I planned. In Irrlicht, all I get is the model with no animation.

So instead I've been using the Cal3d format. Do a search on the forum, somebody made a scene node class for Cal3d, and you can get plugins for 3d studio max that will export them in the Cal3d format. It's a bit of mucking around, but I had absolutely no problems with animation - it worked first time for me, no crashes, no weird bugs.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

But the dwarf is animating, and I've seen several other .x files animating, too. Try to load it with the meshviewer from irrlicht and report the console output if it is not working there. Most problems are related to file parsing errors, so it could be a problem with wrong reading of the animation part. There's also a limit of bones and weights which you might find some more information about with a forum search.
hardgeus
Posts: 28
Joined: Tue May 23, 2006 12:55 am
Contact:

Post by hardgeus »

hybrid wrote:But the dwarf is animating, and I've seen several other .x files animating, too.
I have seen pretty much every format work at *some* point or other. Having a pre-made "perfect" model working in Irrlicht is one thing. Going from your preferred modeler, out to a .X file, and then into Irrlicht is another story.

So far I have been completely incapable of getting *any* animation data out of Blender and into Irrlicht regardless of format (I know you're talking about MAX, but from what I'm reading here, it seems to have similar problems).

So far, the only way I have been able to get animated data into Irrlicht is using Milkshape. Even then, I found the .X behavior to be somewhat bad with visible "breaks" in the mesh when doing bones. My best luck to date has been exporting a .md2 from Milkshape.

Unfortunately, I hate Milkshape's interface, not to mention it irks my Linux zealotry to use Windows, but that's my .02. The best and quickest way I have found to get animations into Irrlicht is to export a .md2 file from Milkshape.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Maybe try the latest Irrlicht SVN version. I've added some more .x file reader fixes which might also fix loss of animation data (which had been simply not read due to reader bugs). If this still does not work please mail me your meshes to experiment with.
luckymutt
Posts: 453
Joined: Sun Mar 06, 2005 11:56 pm
Location: C-Ville

Post by luckymutt »

How were you animating it in Max?
An animation needs to be created in a certain way in order for it to be played as an X file in Irrlicht.
If you are sure you set up the animation corrcelty in Max (or blender or whatever) and it works in the DX mesh viewer but not in Irrlicht, then open it in the DX mesh viewer and save it from there. That will sometimes straighten it out.

good luck
Join us in the Irrlicht chatroom:
[url]irc://irc.freenode.net/irrlicht[/url]

I love deadlines. I like the whooshing sound they make as they fly by. -D.Adams
hardgeus
Posts: 28
Joined: Tue May 23, 2006 12:55 am
Contact:

Post by hardgeus »

luckymutt wrote: An animation needs to be created in a certain way in order for it to be played as an X file in Irrlicht.
Is there a tutorial anywhere that shows the "dos" and "don'ts" of animated models importing into Irrlicht?
Gatekeeper
Posts: 31
Joined: Fri Apr 21, 2006 12:00 am
Location: Australia

Post by Gatekeeper »

I've tried loading my .X models in DirectX meshview and then saving them, and they still never animate correctly. Also, when I go to view them in Irrlicht's mesh viewer, the console output is always "Loaded mesh: blah blah blah"

And yet still no animation. Also, sometimes the models look a little funny too (vertices are in the wrong places etc).
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

If you get wrong node placement it is often due to missing frame names. Irrlicht requires names for all frames. Search for a forum post where I had discovered this bug. I have not yet fixed this problem as generation of temporary names is no good choice, so instead frame sorting and access has to be changed.
If you provide me with the mesh I can check it for you.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Irrlicht supports only bone animations !!!
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Gatekeeper
Posts: 31
Joined: Fri Apr 21, 2006 12:00 am
Location: Australia

Post by Gatekeeper »

Well, I didn't know Irrlicht only supported bone animations...

But that still doesn't mean I can get animations to work. When I export from 3ds DirectX meshview never seems to be able to play the animations. And the animations don't display in Irrlicht either.
hellbound
Posts: 51
Joined: Sat Jun 24, 2006 7:39 am

Post by hellbound »

that's exactly what i get...
it's kind of weird though.. so how can you actually do animations in irrlicht?
Gatekeeper
Posts: 31
Joined: Fri Apr 21, 2006 12:00 am
Location: Australia

Post by Gatekeeper »

Use the Cal3d scene node class my friend... Save the headaches, save the mucking around, save the wasting your time. Just move onto something that works and keep going with your project.
luckymutt
Posts: 453
Joined: Sun Mar 06, 2005 11:56 pm
Location: C-Ville

Post by luckymutt »

Here is a tutorial that was written with the intent of using a different file format and the UnrealEngine, but the creation method is the same.
Just skip the part about ActorX and PSK file stuff and go right on to the animating with keyframes part - then use the PandaX exporter (search the Irrlicht forums for proper settings on export)
It was written a while ago for Max r5, but the same tools are present.
http://fordy.planetunreal.gamespy.com/g ... ls/16.html
There are other ways with other tools, but this should get you going.

If you still have a problem, post your file and I'll take a look.

One of these days I am going to write a tutorial specifically for x files and Irrlicht.
Join us in the Irrlicht chatroom:
[url]irc://irc.freenode.net/irrlicht[/url]

I love deadlines. I like the whooshing sound they make as they fly by. -D.Adams
Terrachild
Posts: 21
Joined: Sun Sep 03, 2006 5:58 am

.X finally working

Post by Terrachild »

Acki wrote: Irrlicht supports only bone animations !!!

Not true. I made a simple cube that tilts on its axis. I followed the suggestions and got both the Panda and the Quest exporters for 3DS Max. I'm using Max version 8.

After wasting an entire night trying to get the cube to animate in Irrlicht I tried opening it up in MS MeshViewer and both exporters worked fine. I also tried resaving it with MeshViewer in another name to see if that would straighten things out.

Finaly, I noticed that in Irrlicht it was moving, but incredibly slowly. So I checked the framecount: MsgBox(mesh.FrameCount) 'Returns 4960.

That sounds like a multiple of the 31 frames I created in 3DS Max. Let's see 4960 divided by 31 = 160. Ahh that gives me an idea!

Gee, I wonder what will happen if I multiply the speed I want 30, by 160, and set the animation speed to that product. (.AnimationSpeed = 4800);
Then set the frame loop to 4960 frames, (.SetFrameLoop(0, 4959)

Sure enough, the animation plays in its entirety, at the correct speed. Life is good.

Would someone like to explain this please?

Any ideas?
Post Reply