Help with getting tutorial to work


I want create an example for my problem with TrianglePickResults but I can't even manage to get a simple application up and running.

I copied the mouse input tutorial to get the framework and planned to add the relevant code once that runs.

The application starts, however the mouse input does not work (neither does key input when I copied the key input example).

I even can't close the window by clicking on X so I'm not sure if the problem really originates from JME.

I'm starting the app from IntelliJ Idea btw.

Please see the following code and tell me if it should run (or does on your systems):

public class TestTrianglePicking extends SimpleGame {
    // This will be my mouse
    // This will be my mouse
    AbsoluteMouse am;

    // This will be he box in the middle
    Box b;

    PickResults pr;

    public static void main(String[] args) {
        TestTrianglePicking app = new TestTrianglePicking();

    protected void simpleInitGame() {


// Create a new mouse. Restrict its movements to the display screen.
        am = new AbsoluteMouse("The Mouse", display.getWidth(), display

        // Get a picture for my mouse.
        TextureState ts = display.getRenderer().createTextureState();
        URL cursorLoc = TestTrianglePicking.class.getClassLoader().getResource(
        "textures/arrow_up_blue.png" ); //this texture is from my system, so provide an own here
        Texture t = TextureManager.loadTexture(cursorLoc, Texture.MinificationFilter.NearestNeighborNoMipMaps,

        // Make the mouse's background blend with what's already there
        BlendState as = display.getRenderer().createBlendState();

        // Get the mouse input device and assign it to the AbsoluteMouse
        // Move the mouse to the middle of the screen to start with
        am.setLocalTranslation(new Vector3f(display.getWidth() / 2, display
                .getHeight() / 2, 0));
        // Assign the mouse to an input handler
        am.registerWithInputHandler( input );

// Create the box in the middle. Give it a bounds
        b = new Box("My Box", new Vector3f(-1, -1, -1), new Vector3f(1, 1, 1));
        b.setModelBound(new BoundingBox() );
        // Attach Children
        // Remove all the lightstates so we can see the per-vertex colors
        b.setLightCombineMode( Spatial.LightCombineMode.Off );
        pr = new BoundingPickResults();
        ((FirstPersonHandler) input ).getMouseLookHandler().setEnabled( false );


    // This is called every frame. Do changing of values here.
    protected void simpleUpdate() {
        // Get the mouse input device from the jME mouse
        // Is button 0 down? Button 0 is left click
        if (MouseInput.get().isButtonDown(0)) {
            Vector2f screenPos = new Vector2f();
            // Get the position that the mouse is pointing to
            screenPos.set(am.getHotSpotPosition().x, am.getHotSpotPosition().y);
            // Get the world location of that X,Y value
            Vector3f worldCoords = display.getWorldCoordinates(screenPos, 0);
            Vector3f worldCoords2 = display.getWorldCoordinates(screenPos, 1);
            System.out.println( worldCoords.toString() );
            // Create a ray starting from the camera, and going in the direction
            // of the mouse's location
            Ray mouseRay = new Ray(worldCoords, worldCoords2
            // Does the mouse's ray intersect the box's world bounds?
            rootNode.findPick(mouseRay, pr);

            for (int i = 0; i < pr.getNumber(); i++) {


I have tried your test app on my setup (EclipseGalileo / Vista32 / Nforce / Nvidia / JDK1.6.0_7) , and it works just fine.

Thanks for trying it.

Did the mouse control and picking work, too?

If so, I guess it's my IDE that has recently gone mad.

Yes, the picking worked.

I have IntelliJ and when I can find some time I will try it again in that - I had trouble getting JME working in IntelliJ tho, so put evaluating it on hold and went back to galileo so I could get some work done.

So much to do… so little time :frowning:

I use intelliJ and I got it to work ok.  You need to specify where the runtime libraries are.  In my case I have:

In the Run dialog for VM parameters i put: -Djava.library.path=D:\java\libs\lwjgl-2.1.0\native\windows

Otherwise you get a runtime error.

Well, I don't get a runtime error. The rendering works fine but the controls (key and mouse input) don't.

There are a number of webstart examples dotted around the forum. Do any of them work if you run them?

e.g.  (first one I found…)

Well, the webstart examples don't run right now because of proxy issues.

The examples that come with the binary download work, though.

However, I'm using an svn version for development that I downloaded some weeks ago, so there might be changes since the build of the binary packages that break something.