Creating/Loading COLLADA Files

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
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Creating/Loading COLLADA Files

Post by kklouzal »

I'm attempting to load a COLLADA file I created and exported from blender, the console is not showing any errors and this is what irrlicht gives me:
Image
I'm able to display the model in other 3D model viewers just fine and it should look like a simple textured building:
Image
Irrlicht seems to be either turning it into a solid object and displaying textures in the wrong places
or
It's only rendering the floor and extruding it up to the height of the entire model.

Viewing the model from the same position within Irrlicht:
Image

To download the file.
https://drive.google.com/open?id=1_kIF4 ... 35ZALEFBU1

I'm using very basic code to render the object:

Code: Select all

#include <irrlicht.h>
#include <iostream>
 
using namespace irr;
 
int main()
{
    IrrlichtDevice *device = createDevice(video::EDT_OPENGL, core::dimension2d<u32>(640, 480));
 
    if (device == 0)
        return 1;
 
    video::IVideoDriver* driver = device->getVideoDriver();
    scene::ISceneManager* smgr = device->getSceneManager();
 
    scene::IAnimatedMesh* mesh = smgr->getMesh("BasicBuilding.dae");
    scene::ISceneNode* node = 0;
 
    if (mesh)
        node = smgr->addMeshSceneNode(mesh->getMesh(0));
 
    node->setMaterialFlag(video::E_MATERIAL_FLAG::EMF_LIGHTING, false);
    node->setScale(core::vector3df(10, 10, 10));
 
    smgr->addCameraSceneNodeFPS();
 
    device->getCursorControl()->setVisible(false);
 
    int lastFPS = -1;
 
    while (device->run())
    {
        if (device->isWindowActive())
        {
            driver->beginScene(true, true, video::SColor(255, 200, 200, 200));
            smgr->drawAll();
            driver->endScene();
 
            int fps = driver->getFPS();
 
            if (lastFPS != fps)
            {
                core::stringw str = L"Irrlicht Engine [";
                str += driver->getName();
                str += "] FPS:";
                str += fps;
 
                device->setWindowCaption(str.c_str());
                lastFPS = fps;
            }
        }
        else
            device->yield();
    }
 
    device->drop();
    return 0;
}
Any ideas whats going on here?
Dream Big Or Go Home.
Help Me Help You.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Creating/Loading COLLADA Files

Post by CuteAlien »

Add:

Code: Select all

 
smgr->getParameters()->setAttribute(scene::COLLADA_CREATE_SCENE_INSTANCES, true);
 
Collada is somewhat a hack. Because it's a scene-format and used here in a meshloader. So by default it only loads the first mesh. This way it creates the whole scene... but the node returned will only be a dummy-node. It really creates a lot of nodes (one for each mesh) and puts them into the active scene.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Re: Creating/Loading COLLADA Files

Post by kklouzal »

That's unfortunate.. I'll go ahead and use a different object type then.
As a side note the application crashes after adding your suggested line.
Dream Big Or Go Home.
Help Me Help You.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Creating/Loading COLLADA Files

Post by CuteAlien »

Where does it crash? I'm always kinda interested in crashes... could you send me your .dae file?
And it's not really bad the way it works, just slightly confusing. Collada _is_ a scene-format, so it makes sense to get it as scene. Only bad that it doesn't use an explicit scene-loader for this.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Re: Creating/Loading COLLADA Files

Post by kklouzal »

There is a link in the original post to google drive where the file is stored. I didn't run the application inside the IDE so I don't have any information other than it crashed :P
Moved over to using .3DS format but blender truncates texture filenames to 12 characters after export. it's like I can't win lol!
Dream Big Or Go Home.
Help Me Help You.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Creating/Loading COLLADA Files

Post by CuteAlien »

Ah thanks, I missed the link.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
kklouzal
Posts: 343
Joined: Sun Mar 28, 2010 8:14 pm
Location: USA - Arizona

Re: Creating/Loading COLLADA Files

Post by kklouzal »

If only FBX file format was supported :(
And you're welcome CuteAlien, always a pleasure :P
Dream Big Or Go Home.
Help Me Help You.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Creating/Loading COLLADA Files

Post by CuteAlien »

Crash is because the node returned is only a dummy-node. When you try to do setMaterialFlag on it then it crashes because the dummy-node has no materials. Remove that line. And maybe slow down camera like: smgr->addCameraSceneNodeFPS(0, 100.f, 0.005f);
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply