[dead] JME3 COLLADA loader

Collada animations works on the collada geometry which is unique even when part of it are bound to different materials. It works exactly in the same way as the jme animation does, there's a vertex buffer and bones modify the values in that buffer via indices/weights. The problem is that if i map the collada geometry to multiple jme geometries i have also to map the skeleton to the jme meshes. Will it work if i share the same vertex buffer among different meshes and i apply the skin to one of them? Or it will be better to duplicate the skin for each mesh? Maybe the answer will be easy but you have to consider that i'm still trying to apply a skin to a cube with two bones (and not animated yet).

Hello,



I have recently got back into my 3D hobbies, and I would like to see Collada support make its way into jME3/Platform also. I'll be working on a basic animated model in my spare time, that I would donate and share with the jME community to help in this effort if it is needed. I use Lightwave, and the Collada format is one of a few formats that I can export to.

Hello.



The good news are that importing static data is a piece of cake and jme3 API's behaves very well.



The bad one is that i have no experience with 3d animation stuff so skin/bone/animation stuff will take a bit longer that expected.



Currently i'm re-writing the geometry transformer to better serve the skinning process. I'll release a jar-plugin soon for testing static scenes.

:smiley:



It's ok, it'll take me a week or so to work up something animated. I'm still in the process of modeling a new test character. Plus I need to brush up a bit on some of the newer rigging tutorials.

lwnurb said:

Hello,

I have recently got back into my 3D hobbies, and I would like to see Collada support make its way into jME3/Platform also. I'll be working on a basic animated model in my spare time, that I would donate and share with the jME community to help in this effort if it is needed. I use Lightwave, and the Collada format is one of a few formats that I can export to.

There's an Ogre exporter for Lightwave you might want to check out.

Will it work if i share the same vertex buffer among different meshes and i apply the skin to one of them?

Yes it will, just make sure that the index buffers for every mesh use the indices relative to the entire vertex buffer.
Momoko_Fan said:



There's an Ogre exporter for Lightwave you might want to check out.



I would like a working link to an Ogre exporter for Lightwave if possible. My attempts at finding it have lead to dead ends so far. :(

Its there as attachments to the post… http://www.ogre3d.org/tikiwiki/LightWave+to+OGRE#attachments

Thanks for pointing out the obvious, sbook  :slight_smile:



Momoko_Fan Thanks for the link.

lwnurb said:

Thanks for pointing out the obvious, sbook  :)

Momoko_Fan Thanks for the link.



I'm usually the one who puts on his shirt inside out :)

Front page updated. Javadoc, a jar file if anyone wants to test it, i've re-re-built the geometry parser (the second implementation was terrible, the third one is alwasy the better). Still have shadeless materials and no transparency  but it's all a matter of implementing the glsl shaders.



Skins and animations next.

I have a little doubt with (my interpretation of) jme3 skinning. In JME3 the influences for a vertex I are specified by the entries (BoneIndexBuffer[K], BoneWeightBuffer[K]), where K = I * 4. Those entries have four components and are paired so that the influences are:



BoneIndex[K + 0], BoneWeight[K + 0] -> the first bone influence for vertex I

BoneIndex[K + 1], BoneWeight[K + 1] -> the second influence for vertex I

BoneIndex[K + 2], BoneWeight[K + 2] -> the third bone influence for vertex I

BoneIndex[K + 3], BoneWeight[K + 3] -> the third bone influence for vertex I



The value in the bone index buffer is the index of the bone in the bone array used to create the skeleton to which the mesh is bound.



Given the constant size of this assignment buffers, if I have a vertex with less than 4 influences  which value should I use in the buffers? For example if the vertex 10 is bound to the bone 1 with a weight of 3.75 the buffers will have the values:



BoneIndex[40] = 1, BoneWeigt[40] = 3.75;

BoneIndex[41] = ?, BoneWeight[41] = ?;

BoneIndex[42] = ?, BoneWeight[42] = ?;

BoneIndex[43] = ?, BoneWeight[43] = ?;



Thanks.

A little experiment with a “fx-enhancer” process.



Blender (1 texture, uv mapping):







JME3 plugin built scene (autogenerated binormal/tangent, autogenerated normal map from the collada diffuse texture):







It is enabled tuning the ColladaDocumentFactory like this:



ColladaDocumentFactory.setFXEnhance(FXEnhancerInfo.create(true));



and voil

That's cool ^^



So because this is collada it should also work with blender 2.5, right?

Yap, it is supposed to work with any collada 1.4 file (the front page reports current limits in geometric elements parsing).



In theory.



In practice I have tested it only with models exported from blender 2.49a and with some of the test files provided by the collada test repository.

Given the constant size of this assignment buffers, if I have a vertex with less than 4 influences  which value should I use in the buffers? For example if the vertex 10 is bound to the bone 1 with a weight of 3.75 the buffers will have the values:

BoneIndex[40] = 1, BoneWeigt[40] = 3.75;
BoneIndex[41] = ?, BoneWeight[41] = ?;
BoneIndex[42] = ?, BoneWeight[42] = ?;
BoneIndex[43] = ?, BoneWeight[43] = ?;

Well, actually, weight 3.75 is illegal. All weights must add to 1.
Since this happens often with exported models, I recommend you normalize the weights automatically.
This is how its done in the mesh.xml importer:
http://code.google.com/p/jmonkeyengine/source/browse/branches/jme3/src/ogre/com/jme3/scene/plugins/ogre/MeshLoader.java#237

To answer your question, you can just put "0" for the bone indices and "0" for the bone weights.

Could you upload or post a simple code example?

An example of the collada loader?

I was interested in the dice example screenshot a few pages earlier in this thread. Maybe I misread but I thought you used the COLLADA loader for that.

morrowsend said:

I was interested in the dice example screenshot a few pages earlier in this thread. Maybe I misread but I thought you used the COLLADA loader for that.

He is developing a collada loader for jme3. How could you use any example code from him :?
morrowsend said:

I was interested in the dice example screenshot a few pages earlier in this thread. Maybe I misread but I thought you used the COLLADA loader for that.



Yes, the model is loaded in JME3 using the collada loader. There is a jar file linked in the first page of this thread that contains the jme3 plugin (in development).

To use it (well, to test it giving it's current state) you have to add that jar file to the classpath of your jme3 project. Once the jar is in the classpath, you can use the loader as a jme3 asset loader.

You have to register the loader before to use it, like this:

assetManager.registerLoader(ColladaLoader.class.getName(), "dae");



Then you can try it, for example:

Spatial myScene = assetManager.loadModel("path of the model.dae");



A complete example could look like this:

import ... a lot of things

public class Main extends SimpleApplication {
    public static void main(String[] args) { new Main().start(); }

    public void simpleInitApp() {
        //this is optional
   ColladaDocumentFactory.setFXEnhance(FXEnhancerInfo.create(
      FXEnhancerInfo.NormalMapGenerator.OFF,
      FXEnhancerInfo.TwoSidedMaterial.OFF,
      FXEnhancerInfo.IgnoreMeasuringUnit.ON));

        String modelDirectory = "file://home/pgi/3d models/");
        String modelFile = modelDirectory + "/gamelevel.dae";
        assetManager.registerLocator(modelDirectory, UrlLocator.class.getName());
        assetManager.registerLoader(ColladaLoader.class.getName(), "dae");
        Spatial gameLevel = assetManager.loadModel(modelFile);
        rootNode.attachChild(gameLevel);
    }
}



I'm not sure about the usage of UrlLocator, i do that to load models from absolute locations.

The loader doesn't support animated models yet (and it is not going to support it in the foreseeable future).