Problem with flagrush tut and my proggie

righto, flagrushtut…


 private void buildPlayer() {
        Node model = null;
       try {
            MaxToJme C1 = new MaxToJme();
            ByteArrayOutputStream BO = new ByteArrayOutputStream();
            URL maxFile = Lesson7.class.getClassLoader().getResource("jmetest/data/model/bike.3ds");
            C1.convert(new BufferedInputStream(maxFile.openStream()),BO);
            JmeBinaryReader jbr = new JmeBinaryReader();
            jbr.setProperty("bound", "box");
            model = jbr.loadBinaryFormat(new ByteArrayInputStream(BO.toByteArray()));
            //scale it to be MUCH smaller than it is originally
            model.setLocalScale(.0025f);
        } catch (IOException e) {
            e.printStackTrace();
        }

        //set the vehicles attributes (these numbers can be thought
        //of as Unit/Second).
        player = new Vehicle("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);
        player.setRenderQueueMode(Renderer.QUEUE_OPAQUE);
    }




my proggie...

   private void setupChar() {

        try {
         ObjToJme converter = new ObjToJme();
         ByteArrayOutputStream BO = new ByteArrayOutputStream();
         URL objFile=Game.class.getClassLoader().getResource("cars/model/f.obj");
         converter.convert(new BufferedInputStream(objFile.openStream()),BO);
         JmeBinaryReader jbr = new JmeBinaryReader();
         jbr.setProperty("bound", "box");
         m_character = jbr.loadBinaryFormat(new ByteArrayInputStream(BO.toByteArray()));

         m_character.setLocalScale(4.5f);
               
         TextureState ts = display.getRenderer().createTextureState();
         ts.setEnabled(true);
         ts.setTexture(TextureManager.loadTexture(Gamecore.class.getClassLoader().getResource(
               "jmetest/data/images/fin.jpg"),
               Texture.MM_LINEAR,
               Texture.FM_LINEAR));
         m_character.setRenderState(ts);

        }
      catch (IOException e) {
            e.printStackTrace();
        }

      
        player = new Vehicle("Player Node", m_character);
        player.setAcceleration(15);
        player.setBraking(15);
        player.setTurnSpeed(2.5f);
        player.setWeight(25);
        player.setMaxSpeed(15);
        player.setMinSpeed(5);
   player.setLocalTranslation(new Vector3f(100,0, 100));
       
   m_character.updateWorldBound();   
   rootNode.attachChild(m_character);
   rootNode.attachChild(player);
   player.updateWorldBound();
   rootNode.updateGeometricState(0, true);
   player.setRenderQueueMode(Renderer.QUEUE_OPAQUE);
    }




Flagrush is Lesson7.java extends BaseGame. Mine extends SimpleGame.

the rest of the class is not the same, but for some reason, flagrush's code sample will take a model and put it into a vehicle object, and then load it into a InputHandler class, but mine will just load the object and put it into a vehicle object, but it will not load properly into the input handler. We both pass the following as input to the handler...

private void buildInput() {
        input = new GameInputHandler(player, properties.getRenderer());
   }




please can someone explain why they do not work the same? ive been at it since 11am this morning (its now 4pm) trying to work it out, and it still makes no sense.

thank you, i really am desperate!
mtm

maybe i ought to explain a bit more



when i use my code and i run the program, my model doesnt relate to the terriain ive got. As in, it will pass through the hills, and hover in the air. it will go forwards and backwards, but it wont move relative to the terrain.



however, in the flag rush tutorial, the model will move on top of the terrain, and move over its bumps and hills.



at the moment, i have two options. I can either have the car move around on top of the terrain properly, but to do this, i simply pass the node m_char into buildInput, not the vehicle object, so this is very primitive.



OR I can pass the vehicle object into buildInput, whereby the object will be static on top of the terrain, and I have only once managed to edit something to get it to move around, but in that case it was not relative to the terrain (as in, it passed through everything)



hope this makes more sense - does it?



thanks

mtm

gilles said:

when i use my code and i run the program, my model doesnt relate to the terriain ive got. As in, it will pass through the hills, and hover in the air. it will go forwards and backwards, but it wont move relative to the terrain.

well, I don't know the flag rush tuts but this does not sound like an input issue. You input handler seems to be registered fine, just the code inside your handler does not do what you want. I guess in flagrush you just set the translation of the bike? If yes you simply get the wrong y coordinate - which should relate to the terrain but does not... so how do you get the terrain height and apply it?

i managed to fix this late last night, after spending about 10 hours on it.



the solution? change the charMinHeight and the terrainNormal code so that instead of getting the NODE's values, it now gets the VEHICLES values, thus making the vehicle sit on the terrain.



its a joke, ten hours to change two words. i hate programming sometimes