OpenCollada .dae file to use in jme

Hi all.

I am able to export a Maya file using OpenCollada exporter and have a .dae file.

I am trying to understand how to use that file and get it into jme.

I have read this post: http://www.jmonkeyengine.com/forum/index.php?topic=12272.0

I just don't fully understand what to do.



Any help would be great.



Thanks,

Scott

It doesn't get much simpler than that post describes.  Were there any steps that you found confusing?



BTW, there are some weird problems with OpenCOLLADA, see this thread: http://www.jmonkeyengine.com/forum/index.php?topic=12339.0

Thanks sbook.

I re-read the link and read the one about texturing.

What I'm trying to figure out is editing the .json file to locate the model and then putting the model file where it belongs. I know the location of the files just making jme read it.



Scott

Archania said:

Thanks sbook.
I re-read the link and read the one about texturing.
What I'm trying to figure out is editing the .json file to locate the model and then putting the model file where it belongs. I know the location of the files just making jme read it.

Scott


Ah ok, got ya!

There are kind of two main options here:  Either the .dae file is going to be on the classpath or off of it.  Having it off there would mean using a URL to load the model, as such:


try {
         ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_MODEL,
               new SimpleResourceLocator(modelURL));
         ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE,
               new SimpleResourceLocator(textureURL));
         // load model
         ColladaImporter.load(modelURL.openStream(), design.getName());
         
         importedModel = ColladaImporter.getModel();
         importedModel.setModelBound(new BoundingBox());
         importedModel.updateRenderState();
         importedModel.updateModelBound();
      } catch (URISyntaxException e) {
         e.printStackTrace();
      } catch (IOException e) {
         e.printStackTrace();
      }



putting it on the classpath would mean using something like the example in the jmetest package:


try {
            ResourceLocatorTool.addResourceLocator(
                    ResourceLocatorTool.TYPE_TEXTURE,
                    new SimpleResourceLocator(TestColladaLoading.class
                            .getClassLoader().getResource(
                                    "jmetest/data/model/collada/")));
        } catch (URISyntaxException e1) {
            logger.warning("Unable to add texture directory to RLT: "
                    + e1.toString());
        }
// ........ some setup code here

 InputStream mobboss = TestColladaLoading.class.getClassLoader()
                .getResourceAsStream("jmetest/data/model/collada/man.dae");

ColladaImporter.load(mobboss, "model");

// now you can get the node
Node modelNode = ColladaImporter.getModel();



Be sure to look at the jmetest.renderer.loader.TestColladaLoading demo though, as I've eliminated little bits of code here and there.

sbook,

I am able to export the model from Maya without any issues.

I was able to open them up with a viewer and they look correct. Looking into the importing of them into the game engine.

I have applied simple color to it and from your post, your correct in that transparency doesn't come out.

I made some windows and they are all white. Gotta look more into that.



Thanks though for all your help.

Archania said:

I have applied simple color to it and from your post, your correct in that transparency doesn't come out.
I made some windows and they are all white. Gotta look more into that.


My recommendation for using transparency is to checkout the wonderland branch of jME2 and build their COLLADA importer..  They specifically addressed transparency issues in COLLADA, though it hasn't been merged to the jME trunk yet..

http://code.google.com/p/jmonkeyengine/source/browse/#svn/branches/2.0.x-wonderland/src/com/jmex/model/collada