Category Image Tips for Importing Characters (Animated, Skinned Meshes) into Irrlicht.


1)  Use the XExporter (ver2) MEL script linked several blog entries below.  

2)  Read the "readme" file that comes with the script.  Note that only Lambert and Blinn materials are supported!!!

3)  Use Maya, Window->General Editors->Script Editor and the File menu to "Source Script".  Find the script on disk.  When it "sources", it's running and will pop up a window.  Check all the boxes, leave Quaternions, and give it a meaningful filename with a ".x" extension.

4)  Before doing 3, though, you should have your polyMesh selected.

5)  Keyframed animations that are keyed on the joints or IK handles should work.  (I'm not completely sure about animations that are keyed through controllers).

6)  After the script exports, find the .x file that it generated.  The easiest thing is to copy that file into the Irrlicht/media folder.  (This way, all those "../../media/sydney.md2" references or whichever may be easily replaced with your file without a painful path to your file).

7)  Compile and run the Collision example with the "faerie" model replaced with your .x file.  (Or run the MeshViewer -- note this often has to be stopped, re-compiled, and re-run to re-fresh properly).  See line of code here for example:

IAnimatedMesh* mesh = smgr->getMesh("../../media/GumbyArmMesh.x");

8)  Before running any examples, though, you may wish to edit the .x text file that was generated.  Use WordPad or VI or whatever...  Search on .jpg or .bmp or whatever texture file you have (or just search on Material).  This will bring you to the Material section in the file.  You will likely want to change the first row of numbers which is likely 0;0;0;0;; or something like that -- change it to 0.2;0.2;0.2;1;;  This should give your character a bit of ambient light so that it will show up in all the examples, even ones with default lighting in Irrlicht turned off).

9)  Also, while you're editing the .x file -- make sure that the TextureFileName {} section has your texture filename in it, such as "MyTexture.jpg" -- this should be copied into the same Irrlicht/media directory.  If it is, .x files will actually find the texture file without having to have another material reference in Irrlicht.  For example, the following lines in HelloWorld could be commented out:

//if (node)

//{

// node->setMaterialFlag(EMF_LIGHTING, false);

// node->setMD2Animation ( scene::EMAT_STAND );

// node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") );

//}


10)  Your animated mesh should work, and you should be able to see it in the Irrlicht window.

11)  You may wish to add the second line of this code to fix your size/scale

node = smgr->addAnimatedMeshSceneNode(faerie);

node->setScale(core::vector3df(-0.7, 0.7, 0.7));


12)  You may also wish to choose your animation cycle:

node->setFrameLoop(3, 15);     // or whatever for walk, attack, etc.

node->setAnimationSpeed(30);   // might not even be necessary

13)  If you're having trouble getting this working, go back to just a mesh with a lambert or blinn shader and start from there.  Work up to your skinned and animated character.

14)  This does work, though, so don't lose heart!  

15)  Once you have your character loaded, the collision example is a great example for your 3D game code.  (Turn off the triangle/picking and light highlight features, of course, though).




Posted: Thursday - April 17, 2008 at 05:13 PM