Layered COLLADA Loader for OpenGL3.1+ Context

Garet Claborn picture Garet Claborn · Feb 6, 2011 · Viewed 9.3k times · Source

What layers would aid in implementing this efficiently? Preferably such that I am able to get these three components listed below up with the early layers and code the rest as I go.

I am writing a COLLADA loading library to use with my graphics engine. So of course as soon as I began I notice this seems to be a rather large task. I now intend to write the library to use different layers.

I do not yet understand COLLADA. I'm assuming there may be:

  • Geometry layer
  • Shader layer
  • Texure Layer

Even these I'm unsure of, may need to be part of a different sort of layering scheme.

Side note, I will most likely be using irrXML or this interesting XML library I just read about here to read the files unless advised otherwise.

Answer

Alexander Gessler picture Alexander Gessler · Feb 18, 2011

Are you aware of Open Asset Import Library (http://assimp.sourceforge.net/)? It has quite decent support for Collada loading and targets use in graphics engines. Writing a collada loader on your own is not only hard, it also takes ages to get it stable enough for productive use, mostly because the format is terribly complex (or, as the primary author of Assimp's Collada loader jokingly put is: almost turing-complete) and every exporter has its own strange habits.

If you need additional features, you can base your work on Assimp's Collada loader and add just what you need (BSD license, you may take it as long as you attribute the source).

Note: I am affliated with the project and thus not unbiased. But after the horrible experiences we made with writing our own Collada loader, I just feel like having to warn you …

Side note, I will most likely be using irrXML

We use it too. Should you really start from scratch, don't. Use a DOM parser, such as TinyXML. Collada is complex but very well-defined, a SAX parser just hardens the work since you have to build the document tree on your own (and you *will** need a data structure to resemble the full document - Collada elements are highly interconnected. To read something meaningful out of them, various cross references need to be resolved).