Help for Initialization or ChaseCamera

Hello, 

 

I am changing two functions basing on "jmetest.flagrushtut.lesson9", because I need the

separate movements in individual functions, for do-las later starting from a reasoner. 

The problem is that with the change the visualization is strange distrust that it is something

with the function ChaseCamera or initSpatial, because I don't get to move the character and nor to move the

vision. In the part of declaration of the variables, I changed the object node for an object

player. And when using the change of the simpleUpdate(), the model executes more with the

prejudiced visualization, I put the changes below in the functions to demonstrate what had been

doing:





    private Node m_character;   



    private void setupCharacter() {

        Box b = new Box("box", new Vector3f(), 5,5,5);

        b.setModelBound(new BoundingBox());

        b.updateModelBound();

        m_character = new Node("char node");

        rootNode.attachChild(m_character);

        m_character.attachChild(b);

        m_character.updateWorldBound();

        TextureState ts = display.getRenderer().createTextureState();

        ts.setEnabled(true);

        ts.setTexture(

            TextureManager.loadTexture(

            Environment.class.getClassLoader().getResource(

            "jmetest/data/images/Monkey.jpg"),

            Texture.MinificationFilter.BilinearNearestMipMap,

            Texture.MagnificationFilter.Bilinear));

        m_character.setRenderState(ts);

    }





    private void setupChaseCamera() {

        Vector3f targetOffset = new Vector3f();

        targetOffset.y = ((BoundingBox) player.getWorldBound()).yExtent * 1.5f;

        chaser = new ChaseCamera(cam, player);

        chaser.setTargetOffset(targetOffset);

    }



    protected void simpleUpdate() {

        .

        .

        .



        float characterMinHeight = page.getHeight(player

                .getLocalTranslation())+((BoundingBox)player.getWorldBound()).yExtent;

        if (!Float.isInfinite(characterMinHeight) && !Float.isNaN(characterMinHeight)) {

            player.getLocalTranslation().y = characterMinHeight;

        }



        .

        .

        .

    }







Changed respectively for:







  private Character player;



  private void buildPlayer() throws IOException {

        Spatial model = null;

        try {

            URL bikeFile = Environment.class.getClassLoader().getResource("jmetest/data/model/bike.jme");

            BinaryImporter importer = new BinaryImporter();

            model = (Spatial)importer.load(bikeFile.openStream());

            model.setModelBound(new BoundingBox());

            model.updateModelBound();

            //scale it to be MUCH smaller than it is originally

            model.setLocalScale(.0025f);

        } catch (IOException e) {

            logger

                    .throwing(this.getClass().toString(), "buildPlayer()",

                            e);

        }

       

        player = new Character("Player Node", model);

        player.setAcceleration(15);

        player.setBraking(15);

        player.setTurnSpeed(2.5f);

        player.setWeight(25);

        player.setMaxSpeed(25);

        player.setMinSpeed(15);

       

        player.setLocalTranslation(new Vector3f(100,0, 100));

        //scene.attachChild(player);

        //scene.updateGeometricState(0, true);

        //agl = ((BoundingBox)player.getWorldBound()).yExtent;

        player.setRenderQueueMode(Renderer.QUEUE_OPAQUE);

    }





    private void buildChaseCamera() {

        HashMap<String, Object> props = new HashMap<String, Object>();

        props.put(ThirdPersonMouseLook.PROP_MAXROLLOUT, "6");

        props.put(ThirdPersonMouseLook.PROP_MINROLLOUT, "3");

        props.put(ThirdPersonMouseLook.PROP_MAXASCENT, ""+45 * FastMath.DEG_TO_RAD);

        props.put(ChaseCamera.PROP_INITIALSPHERECOORDS, new Vector3f(5, 0, 30 * FastMath.DEG_TO_RAD));

        props.put(ChaseCamera.PROP_DAMPINGK, "4");

        props.put(ChaseCamera.PROP_SPRINGK, "9");

        chaser = new ChaseCamera(cam, player, props);

        chaser.setMaxDistance(8);

        chaser.setMinDistance(2);

    }



    protected void simpleUpdate() {

        .

        .

        .



        float characterMinHeight = page.getHeight(player

                .getLocalTranslation())+agl;

        if (!Float.isInfinite(characterMinHeight) && !Float.isNaN(characterMinHeight)) {

            player.getLocalTranslation().y = characterMinHeight;

        }



        .

        .

        .

    }





If somebody can help me, if it is necessary, I send the whole code.