Hello,
there seems to be an error with the way attachment nodes are handled with the models in the JME3 test data assets. The location/rotation of the attachement nodes do not match the displayed model/bone location/rotation. It looks like the position of the attachment node is mirrored at the Z axis. A simple test case to show this (the test-data jar has to be added to the libraries):
[java]package mygame;
import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.animation.LoopMode;
import com.jme3.animation.SkeletonControl;
import com.jme3.app.SimpleApplication;
import com.jme3.light.AmbientLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;
/**
-
test
-
@author murk
*/
public class Main extends SimpleApplication {public static void main(String[] args) {
Main app = new Main();
app.start();
}@Override
public void simpleInitApp() {
Box b = new Box(.25f, .25f, .25f);
Geometry geom = new Geometry(“Box”, b);Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setColor("Color", ColorRGBA.Blue); geom.setMaterial(mat); flyCam.setEnabled(false); AmbientLight al = new AmbientLight(); al.setColor(ColorRGBA.White); rootNode.addLight(al); Spatial jaime = assetManager.loadModel("Models/Jaime/Jaime.j3o"); rootNode.attachChild(jaime); SkeletonControl skel = jaime.getControl(SkeletonControl.class); Node an = skel.getAttachmentsNode("hand.L"); an.attachChild(geom); AnimControl anim = jaime.getControl(AnimControl.class); AnimChannel channel = anim.createChannel(); channel.setAnim("Wave"); channel.setLoopMode(LoopMode.Loop);
}
@Override
public void simpleUpdate(float tpf) {
//TODO: add update code
}@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
}[/java]
This also happens with the Ninja model. I noticed that the geometry of the model used in this case is rotated around the Y-Axis by 180 degrees. If this rotation is removed from the geometry, then the attachment node matches the rendering of the model, but then the model itself is not orientated the way it is expected, of course, e.g. it does not look at the -Z direction. I assume this rotation of the model is introduced during import from the blend file to make up for the different axis layout used in Blender, so I also think that this might affect other models created in Blender. Unforunately, I cannot provide a solution (yet), but since there seems to be no related issue on the Github repo, I wanted to report it at least.
Also, with the move to GitHub, are you okay with creating issue for such reports on GitHub directly or do you prefer forum threads?