[SOLVED]collada import problem with blender


I want to use a model collada or another
But whenever I Export even a cube
Jme begins instructed then crash
I made a lot of tries and I always the same thingI also imported Skin Man in the blender and also in
ColladaLoader first is not open and 2 nd crash
However the code works very well with man.dae
There is the parameter or structure to comply on file collada that we charge with jme?

is just a copy of TestColladaLoading Without skelet


package jmetest.renderer.loader;

import java.io.InputStream;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.logging.Logger;

import com.jme.animation.AnimationController;
import com.jme.animation.Bone;
import com.jme.animation.BoneAnimation;
import com.jme.animation.SkinNode;
import com.jme.app.AbstractGame;
import com.jme.app.SimpleGame;
import com.jme.input.FirstPersonHandler;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.light.PointLight;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Controller;
import com.jme.util.BoneDebugger;
import com.jme.util.resource.ResourceLocatorTool;
import com.jme.util.resource.SimpleResourceLocator;
import com.jmex.model.collada.ColladaImporter;

/**
 * Shows how to load a COLLADA file and apply an animation to it.
 * @author Mark Powell
 *
 */
public class TestColladaLoading extends SimpleGame {
    private static final Logger logger = Logger
            .getLogger(TestColladaLoading.class.getName());
   
    AnimationController ac;
    boolean boneOn = false;
    public static void main(String[] args) {
        TestColladaLoading app = new TestColladaLoading();
        app.setDialogBehaviour(AbstractGame.ALWAYS_SHOW_PROPS_DIALOG);
        app.start();
    }
   
    protected void simpleUpdate() {
        if( KeyBindingManager.getKeyBindingManager().isValidCommand( "bones", false ) ) {
            boneOn = !boneOn;
        }
    }

    protected void simpleRender() {
        //If we want to display the skeleton use the BoneDebugger.
        if(boneOn) {
            BoneDebugger.drawBones(rootNode, display.getRenderer(), true);
        }
    }

    protected void simpleInitGame() {
        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());
        }

        KeyBindingManager.getKeyBindingManager().set( "bones", KeyInput.KEY_SPACE );
       
        //Our model is Z up so orient the camera properly.
        cam.setAxes(new Vector3f(-1,0,0), new Vector3f(0,0,1), new Vector3f(0,1,0));
        cam.setLocation(new Vector3f(0,-100,20));
        input = new FirstPersonHandler( cam, 80,
                1 );
       
        //this stream points to the model itself.
        InputStream mobboss = TestColladaLoading.class.getClassLoader()
               .getResourceAsStream("jmetest/data/model/collada/man.dae");
       
   
        if (mobboss == null) {
            logger.info("Unable to find file, did you include jme-test.jar in classpath?");
            System.exit(0);
        }
        //tell the importer to load the mob boss
        ColladaImporter.load(mobboss, "kl");
    
        SkinNode sn = ColladaImporter.getSkinNode(ColladaImporter.getSkinNodeNames().get(0));
     

        //clean up the importer as we are about to use it again.
        ColladaImporter.cleanUp();
       
    
        rootNode.attachChild(sn);
   
       
        rootNode.updateGeometricState(0, true);
        //all done clean up.
        ColladaImporter.cleanUp();
       
        lightState.detachAll();
       
        PointLight pl = new PointLight();
        pl.setAmbient(new ColorRGBA(0.5f,0.5f,0.5f,1));
        pl.setDiffuse(new ColorRGBA(1,1,1,1));
        pl.setLocation(new Vector3f(10,-50,20));
        pl.setEnabled(true);
        lightState.attach(pl);
    }
}



at this line  :SkinNode sn = ColladaImporter.getSkinNode(ColladaImporter.getSkinNodeNames().get(0));

console :

java.lang.NullPointerException
at jmetest.renderer.loader.TestColladaLoading.simpleInitGame(TestColladaLoading.java:93)
at com.jme.app.BaseSimpleGame.initGame(BaseSimpleGame.java:503)
at com.jme.app.BaseGame.start(BaseGame.java:69)
at jmetest.renderer.loader.TestColladaLoading.main(TestColladaLoading.java:40)

The example code assumes you are loading up a collada file with a skinned mesh in it.  You can change that line to something like this if you are just loading a static mesh:



Geometry sn = ColladaImporter.getGeometry(ColladaImporter.getGeometryNames().get(0));

not crash  not visible  but not crash  I love you 

i see my cube  I SEE MY CUBE  thx

What did you do?  :’( I have the same problem with a blender exported Cube.

Anyone can help me?



The super boned example of the man_walk.dae works fine and my simple cube maded in blender with 2 bones does not work. It is visible but don't move hehe. There's no error or warning message in console.



Thanks.

Blender collada export doesn't support the kind of bone animation jME epects.

That's pretty much all there is to say, as far as I know. Somebody has claimed to have created patches for both blender and jME to make it work, it's somewhere here on the forum, but I haven't been able to get any results with it :confused:

Yeah, I've already did all the steps that I found… With every kind of types



But nothing. Collada is a open standard, because of that i choose it. :frowning: I'm working in a open source game…



So, what model format do you choose? Blender can export it?



Thankyou for the answer, I would try until my death :expressionless:

Try md5 or md3 models.

md3? I haven't heard of that importer yet :confused:

The md5 importer (external project) seems to work quite good, and there is an abandoned but well made and feature rich cal3d loader as well. Look for Ender's version of the md5 importer, or kman's cal3d code , but that is rather old and will require some work to integrate with current jME.



Other than that, I have recently been working on a blender->jME skelanim path using a custom xml format, and have made some progress, but ultimately ran into problems nobody seems to be able to look into at this time. I'll try again some time soon, but cannot promise I'll have any success right now.

The Kman’s loader should be available here. I made a modified version of the blender2cal3d exporter script for Blender here. The thread about the exporter Blender and jME is here.

Somewhere I should have the sources already modified to work with jME 0.10 or 0.11. If you need them please contact me and I will try to find them and to send them to you.



The old Chaosdeathfish’s MD5 Reader (it worked with jME 0.8) have been continued by me here: MD5 Reader 2. The page has also links to all the jME forum discussions about it (I have to thank also kman and mcbeth jME forum users for some code modifications to make it work with jME 0.10).

Every feedback is wellcome. For patches, bugs and requests please use the traker at SourceForge page (contact me if you have any problem).



Both blender2cal3d and md5exporter (der_ton’s exporter, in a famous Doom3 forum) python scripts for Blender are based on the same code, so they suffers of the same problems.

There are 2 new versions (refactored) of the blender2cal3d exporter. One in the Blender official source tree (I don’t know if it have been included in the latest Blender release), and one in the Cal3D source tree.

Only to make it clean, I'll not animate the bones by hand. I want to export already made animations.



I'm still made use to work with COLLADA format. Maybe somebody could post a cube with a simple bone animation made by Maya, 3dMax or Milkshape or anyone else that is correctly imported on JME??? So I can compare the XML file with mine. And maybe I could detect the problems with the .py blender collada importer.



Until now, all I can say is that the fungi .py scripts is until necessary also in the 0.3.159 version. But the fungi's ColladaImporter don't work with JME 1.0, there so many differences in the packages.



The curious thing: my player with a lot of bones, when I press spacebar, JME show me every one practically. But my cube has only one of two.



In parallel, I'm trying to use the Cal3d and md5. See you soon.



Yeah, I know, my english is the best!  :stuck_out_tongue: I hope to have been understood.