Is there a way to import Collada files into Java?

1.8k views Asked by At

We have a graph datastructure for our little 3D program which just contains info about vertices and edges, no fill etc. We just want to get the information about the point locations and how they are connected together. (From what I understand, this is called Mesh data, is that correct terminology?)

Is there a library that would do something like this, or go anywhere near what I want to achieve? Is there, for example, a library which will allow me to just use a function which takes in that file and instantiate a new object that will have all this mesh info?

If not, what would be the steps to get this done?

2

There are 2 answers

0
Erik Brendel On

If you can, switch to wavefront .obj - Files. These can be parsed in a few lines and are likely the thing you want (just import your collada to blender for example and export as obj again)

If you cant, you could give lwjgl a try. This library gives you access to assimp, which can load any 3d-object-format for you

2
Endery On

I understand you need to parse the 3D-information in COLLADA and convert it to your internal data structure. You can create POJOs for COLLADA elements using JAXB and COLLADA schema file. But it is not really easy because there are some name collision problems in the schema. You need to do some hacks to get rid of this. Here is a link which explains how to do that: http://shinoblogbyshiva.blogspot.de/2009/01/compiling-collada-15-schema-by-jaxb.html.

According to this link, you need to have 3 things: 1) Collada XML-Schema 2) A schemalet for help (http://interreality.org/bzroot/vos/supervos/colladajaxb/src/simpleMode.xsd) 3) And the latest version of JAXB. Then use xjc from JAXB like this:

"xjc collada_schema_1_5.xsd -extension simpleMode.xml"

Be sure the paths of the files are correct.

After you have your POJOs, you can parse the COLLADA file. But for the conversion process, you are alone. You should understand the definition of elements in COLLADA and compare them with your own structure. It is a little bit complicated, I can recommend you to read the book "Collada: Sailing the Gulf of 3d Digital Content Creation" from Remi Arnaud.