Unwanted rotation with ThirdPersonHandler

I'm just really curious here if this is a bug, or if I'm doing something wrong. I'm loading an OBJ file through the same means as the test example. Then, I'm rotating the model to orient it forwards, and then I add it to a node. I set up a chase camera behind the node, and a ThirdPersonHandler (very standard) to the node as well. When I first load the screen up, everything is oriented correctly, but as soon as I push the "forward" key, the model's orientation shifts to the left 90 degrees around the Y axis. I can compensate for this by adding a different rotation, but it looks funny to have the camera always start by looking in the wrong direction. Is this a bug?

For reference, here's the code (just a modified version of the test by the same name):



package spaceops;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;

import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingBox;
import com.jme.input.ChaseCamera;
import com.jme.input.ThirdPersonHandler;
import com.jme.math.FastMath;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.scene.Node;
import com.jme.scene.shape.Box;
import com.jme.util.LoggingSystem;
import com.jme.util.export.binary.BinaryImporter;
import com.jmex.model.XMLparser.Converters.ObjToJme;

public class TestThirdPersonController extends SimpleGame {

    private Node m_character;

    private ChaseCamera chaser;

    /**
     * Entry point for the test,
     *
     * @param args
     */
    public static void main(String[] args) {
        LoggingSystem.getLogger().setLevel(java.util.logging.Level.OFF);
        TestThirdPersonController app = new TestThirdPersonController();
        app.setDialogBehaviour(ALWAYS_SHOW_PROPS_DIALOG);
        app.start();
    }

    /**
     * builds the scene.
     *
     * @see com.jme.app.SimpleGame#initGame()
     */
    protected void simpleInitGame() {
        display.setTitle("jME - 3rd person controller test");
       
        setupCharacter();
        setupChaseCamera();
        setupInput();
    }
   
    protected void simpleUpdate() {
        chaser.update(tpf);
    }

    private void setupCharacter() {
        ObjToJme converter=new ObjToJme();
        m_character = new Node("char node");
        rootNode.attachChild(m_character);
        Node model = new Node("model");
        try {
            URL objFile=TestThirdPersonController.class.getClassLoader().getResource("spaceops/models/roboticbattleship.obj");
            converter.setProperty("mtllib",objFile);
            converter.setProperty("texdir",objFile);
            ByteArrayOutputStream BO=new ByteArrayOutputStream();
            System.out.println("Starting to convert .obj to .jme");
            converter.convert(objFile.openStream(),BO);
           
            System.out.println("Done converting, now watch how fast it loads!");
            long time=System.currentTimeMillis();
            model=(Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
            System.out.println("Finished loading time is "+(System.currentTimeMillis()-time));
            model.setLocalScale(5f);
            Quaternion q = new Quaternion();
            q.fromAngleAxis(-FastMath.DEG_TO_RAD*90f, new Vector3f(1,0,0));
            model.setLocalRotation(q);
            model.setModelBound(new BoundingBox());
            model.updateModelBound();
            model.updateWorldBound();

            m_character.attachChild(model);
            m_character.updateWorldBound();
        } catch (IOException e) {
            e.printStackTrace();
        }

       
        Box tempbox = new Box("box", new Vector3f(),5,5,5);
        tempbox.setLocalTranslation(new Vector3f(0,0,0));
        rootNode.attachChild(tempbox);
       
    }
   
    private void setupChaseCamera() {
        Vector3f targetOffset = new Vector3f();
        targetOffset.y = ((BoundingBox) m_character.getWorldBound()).yExtent * 1.5f;
        chaser = new ChaseCamera(cam, m_character);
        chaser.setStayBehindTarget(true);
        chaser.setTargetOffset(targetOffset);
    }

    private void setupInput() {
        HashMap<String, Object> handlerProps = new HashMap<String, Object>();
        handlerProps.put(ThirdPersonHandler.PROP_DOGRADUAL, "false");
        handlerProps.put(ThirdPersonHandler.PROP_TURNSPEED, ""+(1.0f * FastMath.PI));
        handlerProps.put(ThirdPersonHandler.PROP_LOCKBACKWARDS, "false");
        handlerProps.put(ThirdPersonHandler.PROP_ROTATEONLY, "true");
        handlerProps.put(ThirdPersonHandler.PROP_CAMERAALIGNEDMOVE, "true");
        input = new ThirdPersonHandler(m_character, cam, handlerProps);
        input.setActionSpeed(100f);
    }
}

did you got success on this problem ? I'm having the same

Well, yes and no.



Yes, because I went back to using my own engine.  :stuck_out_tongue:



No, because I still want to use jME for a future project. I do think it primarily has something to do with my lack of understanding on how it works though. For those of us who want total control, we'll probably need to write our own handler.