Just started with JME3. My experience and a few Questions

Hi,



I started yesterday with JME3. I had experiences with JOGL and was always using your math libs in my projects. But otherwise JME was completly new to me.



I think that you have done a very nice job and it is a pleasure to work with JME3. I coded one night and have already an application where an animated model is rendered and when i click onto it with the mouse the animation is changed. There is also a nice sky map with sphere mapping. I searched a lot on the forum and in the wiki to get this done and it was mostly easy and quickly done.



But I have a few inputs and questions. I don't know if my inputs they help you, as I am realy new to JME and have not understood it completly by now.



  • Sometimes there is lots of documentation missing. For example the class CollisionResults (I think this is why JME3 is in the alpha state, but if there were some examples in the JavaDoc I would have done the application in maybe half of the time).

  • I would like to see a feature like an onKeyPress event for keyboard inputs. The key binding event is fired again and again and again while the key is hold down.

  • I could not figure if there is a better way to get the absolute mouse coordinates in a window. This is what I am currently doing:
    (The constructor is added for the next question.)


public class Input implements RawInputListener {
    private Main main;
    private InputManager inputManager;
    private Camera camera;


    Input(Main main, InputManager inputManager, Camera camera) {
         this.main = main;
         this.inputManager = ......

         inputManager.addRawInputListener(this);
    }

    ....

    public void onMouseButtonEvent(MouseButtonEvent evt) {
        //left mouse button pressed?
        if(evt.isPressed() && evt.getButtonIndex() == 0) {
            Vector2f screenPos = new Vector2f(Mouse.getX(), Mouse.getY());
            ....
        }


The problem is, that Mouse depends on import org.lwjgl.input.Mouse;. I don't think this is the right way to do this.

[/list]

  • I am still thinking of a good software architecture for my application. I want to code an application where some models are rendered and when I click on them I can give them orders where they should move (like in an RTS Game). I have currently one main class, which holds references to an input class, a model class and a sky class. To use my input class I have to parameterize it with an reference to the main class so that I am able to react to inputs and an instance of the inputManager (look at the constructor above).

    I don't think that I am currently doing this in the best way there is. If anyone can drop me a hint I would be glad. Nice would be some kind of service oriented approach (may be a bit overhead), or just an static variable Main.inputManager, that could be acccessed from everywhere. Some example architectures for different applications or just some design patterns that have proven helpful while working with JME would be useful.

  • As I already said I am currently rendering a model. This is currently done this way:


    Model(Node rootNode, AssetManager assetManager) {
        Spatial model = (Spatial) assetManager.loadModel("Models/Oto/Oto.meshxml");
        model.setName("PlayerChar");
        model.center();

        AnimControl control = model.getControl(AnimControl.class);
        control.addListener(this);
        channel = control.createChannel();

        channel.setAnim("stand");

        rootNode.attachChild(model);
    }


What is bothering me, is that I want this model standing an plane (later terrain) that is drawn along the x- and z-axis. How can I figure out how much I need to translocate the model so that its feet are on the plane.
[/li]
  • Is there a better way to do collision detection? This is how I am currently doing it:
  • [/list]


        void checkMouseClickCollision(Ray ray) {
            CollisionResults collisionResults = new CollisionResults();
            rootNode.collideWith(ray, collisionResults);
           
            if(collisionResults.getClosestCollision() != null &&
                collisionResults.getClosestCollision().getGeometry() != null &&
                collisionResults.getClosestCollision().getGeometry().getParent() != null &&
                collisionResults.getClosestCollision().getGeometry().getParent().getName() == "PlayerChar") {
                model.nextAnimation();
            }
        }


      [/li]


    Thanks for all your work on this awesome engine. I'd like to learn JME, as I every time I started an 3D project I had to do the same boring stuff again and again (for example shadow volumes or just a little helper class that loads shaders).


    Greetings,

        iuiz

    (PS: Your forum has problems with code tags within li tags....)
    iuiz said:
    Sometimes there is lots of documentation missing. For example the class CollisionResults (I think this is why JME3 is in the alpha state, but if there were some examples in the JavaDoc I would have done the application in maybe half of the time).

    I've also noticed that; as you said, I'm guessing that the documentation will be improved as jME3 approaches a stable state.  :)

    iuiz said:

    I would like to see a feature like an onKeyPress event for keyboard inputs. The key binding event is fired again and again and again while the key is hold down.

    This has been mentioned before, and according to the developers, the Input system is going to be revamped.

    iuiz said:

    I could not figure if there is a better way to get the absolute mouse coordinates in a window. This is what I am currently doing:
    (The constructor is added for the next question.)
    *snip*
    The problem is, that Mouse depends on import org.lwjgl.input.Mouse;. I don't think this is the right way to do this.

    You should implement BindingListener instead of RawInputListener (according to the tutorials, which I've been following). Have a look at this tutorial.

    iuiz said:
    I am still thinking of a good software architecture for my application. I want to code an application where some models are rendered and when I click on them I can give them orders where they should move (like in an RTS Game). I have currently one main class, which holds references to an input class, a model class and a sky class. To use my input class I have to parameterize it with an reference to the main class so that I am able to react to inputs and an instance of the inputManager (look at the constructor above).

    I don't think that I am currently doing this in the best way there is. If anyone can drop me a hint I would be glad. Nice would be some kind of service oriented approach (may be a bit overhead), or just an static variable Main.inputManager, that could be acccessed from everywhere. Some example architectures for different applications or just some design patterns that have proven helpful while working with JME would be useful.

    I was also wondering this; as soon as you're doing something bigger than a couple of boxes, it seems a bit messy having it all in one class.

    I can't help with any of the other stuff as I've also only just started with jME.

    iuiz said:

    (PS: Your forum has problems with code tags within li tags....)

    It does seem to. I imagine thats a bug with SMF, which the forum is powered by.

    Tanks for the answer.

    Quote:
    iuiz said:

    I could not figure if there is a better way to get the absolute mouse coordinates in a window. This is what I am currently doing:
    (The constructor is added for the next question.)
    *snip*
    The problem is, that Mouse depends on import org.lwjgl.input.Mouse;. I don't think this is the right way to do this.

    You should implement BindingListener instead of RawInputListener (according to the tutorials, which I've been following). Have a look at this tutorial.
    The problem was, that I was not able to get absolute mouse coordinates with the BindingListener interface. The onMouseButtonEvent method was only provided by the RawInputListener interface.


    Greetings,

        iuiz

    The question about how to organize the code best is dependent on what you want to achieve. For one you should be aware of the general object-oriented concepts, so a "player" in a game should probably be a separate class and have methods to update and manipulate that player. Then for the rest of it, thats basically up to you and to your game type… There are many ways to go about and the programmers at rockstar deserve the money they get for it :wink:



    However we intend to create some basic frameworks for different game types later, like game "entity" classes with basic move commands and things that connect code and game concepts better. Then probably some of the code layout can even be done in a more visual way in jMonkeyPlatform but jME is intended to be a complete game engine to write high-performance games with, so programming experience will always be essential.



    Cheers,

    Normen

    For GUI applications, its fine to implement the RawInputListener.