Language
Google Search
 
 
COLLADA on JOGL

COLLADA is especially designed to facilitate 3D information interchange with other DCCs and to integrate easily within tool chains for game development. It is an open format, whose official web site is http://www.collada.org/. (Words from feelingsoftware)

The majority of COLLADA implementations are by C++ language. For example, FCollada from feelingsoftware, COLLADA RT, and COLLADA FX Loader from collada.org.

 

100town.com had been devoted in the development COLLADA parse and viewer based on Java Platform for the interests of our own 3D production. Now the beta version has been released for test.

 

Several references should be mentioned here since they had provided important information to us in building our COLLADA on JOGL (We still don’t have a formal name for it yet).

 

1.    JAXB compilation of COLLADA DOM


JAXB has been shipped with JDK and JRE. JAXB seems to be ideal for COLLADA implementation since COLLADA documentations are based on Document Object Model (DOM). But in practice we found there are many difficulties from different aspects. For example: 


(1). Versions compatibility –compilation using JAXB1 leads to many unsolved errors;


(2.) Performance – create a new instance of JAXBContext and an Unmarshaller takes about 8 seconds on a Dual core  (1.8G Hz CPU) PC. But finally we found a solution and use the following lines of JAXB2 command compiling COLLADA Schema successfully.

          xjc -extension simpleMode.xsd collada_schema_1_4.xsd

where simpleMode.xsd is from
http://weblogs.java.net/blog/kohsuke/archive/2006/03/simple_and_bett.html

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="no-such-thing"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"
    xmlns:xjc= "http://java.sun.com/xml/ns/jaxb/xjc" jaxb:extensionBindingPrefixes="xjc">
  <xs:annotation><xs:appinfo>
    <jaxb:globalBindings>
        <xjc:simple />
    </jaxb:globalBindings>
  </xs:appinfo></xs:annotation>
</xs:schema>

 

There are other suggestions trying to solve the problem of performance. For example, DukeBeanEm  uses XmlBean from Apache instead. It makes the burdens of programming heavier and additional jar files will also influence users’ experiences when the downloading applications is big. We finally decided bet on Sun’s side and choosing JAXB2 since these are one time works and can be done at the initial time of the application. Hopefully the future version of JAXB can load COLLADA in less than one second. That will be a real success of JAXB technology.

2.    The FCollada from feelingsoftware might be the best solution on C++ platform. On Java Platform there are several approaches but most of them are not finished yet. For example, we still do not find any one supporting animations on JOGL except us.


There is one experimental of COLLADA loader in one sub project of JDesktop which gives a good way of task dispatching mechanism as the following code shows

 

      for(Geometry g : geoms) {
            System.out.println("Processing Geometry "+g.getName());
            if (g.getConvexMesh()!=null)
                children.add(ProcessorFactory.createProcessor(g.getConvexMesh(), this));
            if (g.getMesh()!=null)
                children.add(ProcessorFactory.createProcessor(g.getMesh(), this));
            if (g.getSpline()!=null)
                children.add(ProcessorFactory.createProcessor(g.getSpline(), this));
        }

In processiong a DAE file the cross-reference between nodes may lead to dead locks of processors.
We improve it by using multi-threads and letting each thread waiting for other processors to finish:

           Processor target = processor.getFactory().cache().getVertices(vsource);
                if(target==null){
                                    processor.getFactory().cache().addElementLoadedListener(vsource, processor);
                    synchronized(processor.getLock()){
                        processor.startWait();
                    }
                    target = processor.getFactory().cache().getVertices(vsource);
                    if(target==null){ //still not load
                        processor.setCfxloaded(cfxloaded_Abort);
                        continue;
                    }
                }

 

The COLLADA implementation is a difficult task which needs many programmers working for many months. Indeed the collada.org should take over this work themselves but currently they only working on an C++ implementation (COLLADA RT, and COLLADA FX Loader) and there are still some parts is not finished. COLLADA is important and many developers may had been working on it already. To avoid not to re-invent the wheels, we decided only to follow the codes of one of C++ versions. Because COLLADA RT, and COLLADA FX seems to be more formal, so in building our COLLADA on JOGL we reference many part of their codes.

 

What we will do next

We need to improve the performance of the COLLADA on JOGL to make it can compare with the speed of C++ codes (That is also the original desire of JOGL). We need to test with more complex COLLADA models too.


JAVA 3D, JOGL and other 3D implantation are different branches and now we only support JOGL.  The COLLADA on JOGL had considered to separate the parser and render so in the future we may also release the version based on JAVA 3D. If you have any questions and suggestions please write to us.