Collada Writer

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
asparagusx
Posts: 81
Joined: Thu Oct 16, 2008 6:50 am

Collada Writer

Post by asparagusx »

Hello

Been trying to create collada (.DAE) files using irrlicht 1.7.2 and I am having some major issues. I tried to create a simple file with a single face in it and then trying to load that in Sketch-up. The face simply has 2 triangles and a material. Sketch-up does not load the file. I then ran the file via a collada validator (http://opencollada.org/news.html) and it generated a number of errors :-

Schema validation error: Error: ERROR_UNKNOWN_ATTRIBUTE Element: param, Attribute: flow, Line: 73, Column: 29, Additional: OUT
Schema validation error: Error: ERROR_UNKNOWN_ATTRIBUTE Element: param, Attribute: flow, Line: 74, Column: 29, Additional: OUT
Schema validation error: Error: ERROR_UNKNOWN_ATTRIBUTE Element: param, Attribute: flow, Line: 87, Column: 29, Additional: OUT
Schema validation error: Error: ERROR_UNKNOWN_ATTRIBUTE Element: param, Attribute: flow, Line: 88, Column: 29, Additional: OUT
Schema validation error: Error: ERROR_UNKNOWN_ATTRIBUTE Element: param, Attribute: flow, Line: 89, Column: 29, Additional: OUT
Schema validation error: Error: ERROR_UNKNOWN_ATTRIBUTE Element: input, Attribute: idx, Line: 97, Column: 32, Additional: 0
Schema validation error: Error: ERROR_REQUIRED_ATTRIBUTE_MISSING Element: input, Attribute: offset, Line: 97, Column: 32, Additional:
Schema validation error: Error: ERROR_UNKNOWN_ATTRIBUTE Element: input, Attribute: idx, Line: 98, Column: 32, Additional: 1
Schema validation error: Error: ERROR_REQUIRED_ATTRIBUTE_MISSING Element: input, Attribute: offset, Line: 98, Column: 32, Additional:
Schema validation error: Error: ERROR_UNKNOWN_ATTRIBUTE Element: input, Attribute: idx, Line: 99, Column: 32, Additional: 2
Schema validation error: Error: ERROR_REQUIRED_ATTRIBUTE_MISSING Element: input, Attribute: offset, Line: 99, Column: 32, Additional:

Suffice to say, doing the same thing from Sketch-up produced an error free .DAE file.

Any ideas as to what the problem(s) might be?

Thanks

Anton
CuteAlien
Admin
Posts: 9670
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Collada Writer

Post by CuteAlien »

Hm, there have been a lot of changes in collada-export since 1.7.2. It would help if you could also put that collada file online - or maybe even better - the sources which you used to produce it.
There might still be problems - for example currently our exported collada's crash Blender on import. I haven't found time yet to dig deeper into what's going on there.
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
asparagusx
Posts: 81
Joined: Thu Oct 16, 2008 6:50 am

Re: Collada Writer

Post by asparagusx »

Some progress :-

I recompiled the system, using the latest SVN trunk and now the Collada validator test and validates the file correctly. The bad news is however that neither Sketch-up nor Blender loads the file. Neither system generates any useful information as to what the issue(s) might be. For reference, here is a copy of the test file

http://www.cad-essence.com/genes1s/Drawing_1.DAE

If I load this file back into my system, using the irrlicht mesh loader, it imports correctly.

Thanks

Anton
asparagusx
Posts: 81
Joined: Thu Oct 16, 2008 6:50 am

Re: Collada Writer

Post by asparagusx »

For reference, here is the code I use to generate the export files :-

Code: Select all

                IWriteFile *out = Device->ifs->createAndWriteFile(Filename);
                if (out)
                        {
                        IMeshWriter *writer = 0;
         DCELMESHPTR Mesh;
         PATIT ipos,end = End();
         SMesh mesh;
         ISceneManager *Manager = Device->AddSceneManager(0);
         
         // traverse our drawing and add facelists to a mesh
         for (ipos = Begin(); ipos != end; ++ipos)
            {
            pat = (*ipos).second;
                 if (pat->IsVisible() && pat->DCELList.size())
                         {
                         for (i = 0; i != pat->DCELList.size(); ++i)
                                 {
                                 Mesh = pat->DCELList[i];
                                 if (!Mesh->IsSystemMesh())
                                         for (j = 0; j != Mesh->MFaces.size(); ++j)
                                                 mesh.addMeshBuffer(Mesh->MFaces[j]->Mesh);
                                 }
                         }
                 }
         IMeshSceneNode *Export = Manager->addMeshSceneNode(&mesh);
         IAnimatedMesh *AExport = (IAnimatedMesh *) Export->getMesh();
         
         // create the correct mesh writer, based on the file extension
         Export->setName(EName);
         Manager->getMeshCache()->addMesh(EName,AExport);
                        if (!stricmp(Ext,".DAE"))
                                writer = Manager->createMeshWriter(EMWT_COLLADA);
                        else if (!stricmp(Ext,".OBJ"))
                                writer = Manager->createMeshWriter(EMWT_OBJ);                                           
                        else if (!stricmp(Ext,".STL"))                  
                                writer = Manager->createMeshWriter(EMWT_STL);                                           
                        else if (!stricmp(Ext,".PLY"))                  
                                writer = Manager->createMeshWriter(EMWT_PLY);                           
         // write the mesh                                              
                        if (writer)
                                {                       
                                writer->writeMesh(out,Export->getMesh());//&mesh);      
                                writer->drop();
                                Result = TRUE;
                                }
         Manager->getMeshCache()->removeMesh(AExport);
         Device->RemoveManager(Manager);
                        out->drop();
 
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Collada Writer

Post by hybrid »

The scene instance is missing. I guess that only parts present in the scene will be shown by the tools. And IMHO this should also be exported by Irrlicht by default.
CuteAlien
Admin
Posts: 9670
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Collada Writer

Post by CuteAlien »

It's possible to enable that now. You can cast the writer to IColladaMeshWriter* when creating it with EMWT_COLLADA. And then you can set writer->setWriteDefaultScene(true); Maybe also take a look at the new IColladaMeshWriter.h as there might be more useful stuff in there for working with collada (different tools interpret values different, so you can overload the way properties are written on export, for example some (maybe even most) tools only support certain lighting techniques).

Setting setWriteDefaultScene to to true by default could be done - I've got to change something else anyway in the collada-writer in the next time (in creating mesh-names as the current solution I wrote there is bad and not really working correct on 64-bit). I just have to test if Irrlicht still loads it without trouble then (without having to set it to scene-loading first).
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
asparagusx
Posts: 81
Joined: Thu Oct 16, 2008 6:50 am

Re: Collada Writer

Post by asparagusx »

Well, well, well...

Some success! Enabling the default scene to be exported, certainly made a huge difference. I was not aware of this feature - the model is now loading in Sketch-up. I am still not seeing any textures - i am using :-

Code: Select all

                        ((IColladaMeshWriter*) writer)->setWriteDefaultScene(true);
                        ((IColladaMeshWriter*) writer)->setWriteTextures(true);
                        ((IColladaMeshWriter*) writer)->setAmbientLight(DwgSmgr->getAmbientLight());
 
Looking at the file, the texture images are exported but Sketch-up did not display them.

Thanks

Asp
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Collada Writer

Post by hybrid »

Does WriteTextures create the binary code in the XML, or does it just link to the image files? Your original example did not include any textures.
asparagusx
Posts: 81
Joined: Thu Oct 16, 2008 6:50 am

Re: Collada Writer

Post by asparagusx »

It appears to write the location of the image used as the texture. I have updated the file above, with a new version, with a mesh containing a texture image in it. Maybe this will give you some clues. It appears as if the path might be relative, rather than absolute.

Thanks

Asp
Post Reply