Page 1 of 1

Creating/Loading COLLADA Files

Posted: Tue Dec 12, 2017 1:00 pm
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?

Re: Creating/Loading COLLADA Files

Posted: Tue Dec 12, 2017 1:27 pm
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.

Re: Creating/Loading COLLADA Files

Posted: Tue Dec 12, 2017 2:18 pm
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.

Re: Creating/Loading COLLADA Files

Posted: Tue Dec 12, 2017 2:53 pm
by devsh
Use ASSIMP

Re: Creating/Loading COLLADA Files

Posted: Tue Dec 12, 2017 3:12 pm
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.

Re: Creating/Loading COLLADA Files

Posted: Tue Dec 12, 2017 3:26 pm
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!

Re: Creating/Loading COLLADA Files

Posted: Tue Dec 12, 2017 3:31 pm
by CuteAlien
Ah thanks, I missed the link.

Re: Creating/Loading COLLADA Files

Posted: Tue Dec 12, 2017 3:32 pm
by kklouzal
If only FBX file format was supported :(
And you're welcome CuteAlien, always a pleasure :P

Re: Creating/Loading COLLADA Files

Posted: Tue Dec 12, 2017 7:42 pm
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);