Bender with Irrlicht/best 3D modeling/animation tool

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
cclau
Posts: 3
Joined: Mon May 05, 2014 4:27 am

Bender with Irrlicht/best 3D modeling/animation tool

Post by cclau »

First, thanks in advance for reading this post and I apologize if this is covered elsewhere, but I was having a difficult time finding up-to-date info on this topic.

My questions are:
1. Is there a reliable way to import 3D animations from Blender to Irrlicht? If so, how?
2. If not, what would the community recommend as the best tool for creating animated 3D models for import into Irrlicht? The reason I like Blender is that it is free, well documented, and runs on Linux, so the more of these that apply to a tool the more interested I am.

Just to give some background on what I am trying to do, I downloaded the example files sydney.md2 and sydney.bmp, and tried them using the code below which I copied from a tutorial, and it worked. Next, I tried creating a moving cube in blender, exporting it in various formats, and using the file in place of sydney.md2. The cube appeared, but was static and didn't move.

Again, thanks so much for any help/advice!

Code: Select all

 
 
/*
 * irrlichttest.cpp
 */
 
#include <irrlicht.h>
 
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
 
int main()
{
    IrrlichtDevice *device =
        createDevice( video::EDT_SOFTWARE, dimension2d<u32>(640, 480), 16,
            false, false, false, 0);
 
    if (!device)
        return 1;
 
    device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
 
    IVideoDriver* driver = device->getVideoDriver();
    ISceneManager* smgr = device->getSceneManager();
    IGUIEnvironment* guienv = device->getGUIEnvironment();
 
    guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
        rect<s32>(10,10,260,22), true);
 
    IAnimatedMesh* mesh = smgr->getMesh("sydney.md2");
 
    if (!mesh)
    {
        device->drop();
        return 1;
    }
    IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
 
    if (node)
    {
        node->setMaterialFlag(EMF_LIGHTING, false);
        node->setMD2Animation(scene::EMAT_STAND);
 
        node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
    }
 
    smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
 
    while(device->run())
    {
        driver->beginScene(true, true, SColor(255,100,101,140));
 
        smgr->drawAll();
        guienv->drawAll();
 
        driver->endScene();
    }
 
    device->drop();
 
    return 0;
 
}
 
 
Christi258
Posts: 62
Joined: Wed Feb 06, 2013 12:11 pm

Re: Bender with Irrlicht/best 3D modeling/animation tool

Post by Christi258 »

There is no problem to use blender for creating your animated 3D models. I have the opinion that the DirectX format (.x) worked best.
Perhaps you try that.
cclau
Posts: 3
Joined: Mon May 05, 2014 4:27 am

Re: Bender with Irrlicht/best 3D modeling/animation tool

Post by cclau »

Thank you so much for your reply!

It's good to know that x format works. Currently I am having trouble making the test code work with this, though.

The procudure I am using is to create an animated cube using methods similar to this tutorial:
http://cgcookie.com/blender/lessons/4-animation/
Then export as directX to file "cube.x". Finally, use the "sydney.md2" example, except replace the filename "sydney.md2" with "cube.x". The code is here:

Code: Select all

 
/*
 * irrlichttest.cpp
 */
 
#include <irrlicht.h>
 
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
 
int main()
{
    IrrlichtDevice *device =
        createDevice( video::EDT_SOFTWARE, dimension2d<u32>(640, 480), 16,
            false, false, false, 0);
 
    if (!device)
        return 1;
 
    device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
 
    IVideoDriver* driver = device->getVideoDriver();
    ISceneManager* smgr = device->getSceneManager();
    IGUIEnvironment* guienv = device->getGUIEnvironment();
 
    guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
        rect<s32>(10,10,260,22), true);
 
    ///IAnimatedMesh* mesh = smgr->getMesh("sydney.md2");
    IAnimatedMesh* mesh = smgr->getMesh("cube.x");
 
    if (!mesh)
    {
        device->drop();
        return 1;
    }
    IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
 
    if (node)
    {
        node->setMaterialFlag(EMF_LIGHTING, false);
        node->setMD2Animation(scene::EMAT_STAND);
 
        node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
    }
 
    smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
 
    while(device->run())
    {
        driver->beginScene(true, true, SColor(255,100,101,140));
 
        smgr->drawAll();
        guienv->drawAll();
 
        driver->endScene();
    }
 
    device->drop();
 
    return 0;
 
}
 
The result is that the cube appears, but it does not move, i.e., is not animated.

I have not yet read the documentation in detail, so maybe the code above must be modified in other ways to use x instead of md2? For example, there is a method call "setMD2Animation" that seems MD2 specific.

Is there any example code similar to this that would illustrate how to make an x animation file display correctly? If no reply is posted, I will try spending more time with the documentation to try to figure it out, or at least ask more specific questions.

Thanks again so much :)
tothex
Posts: 5
Joined: Tue Sep 24, 2013 5:38 pm

Re: Bender with Irrlicht/best 3D modeling/animation tool

Post by tothex »

it should work if you use these settings:
http://irrlicht.sourceforge.net/forum/v ... =1&t=49222

You can also try the .b3d blender plugin (only for export):
http://irrlicht.sourceforge.net/forum/v ... =4&t=49777
cclau
Posts: 3
Joined: Mon May 05, 2014 4:27 am

Re: Bender with Irrlicht/best 3D modeling/animation tool

Post by cclau »

Thanks for the reply.

Yes, this was it, it looks like I did not have the settings right when exporting X from blender.

Thanks again so much :)
Post Reply