0

Ok, here is my code:

package test;


import java.util.ArrayList;
import java.util.Vector;

import com.jme3.app.SimpleApplication;
import com.jme3.system.AppSettings;


import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.Node;


public class test extends SimpleApplication {


    public static void main(String[] args){

        AppSettings settings = new AppSettings(false);
        settings.setResolution(640,480);
        test app = new test();

        app.setSettings(settings);
        app.start();

    }


    @Override
    public void simpleInitApp() {

        ArrayList<Geometry> geos = new ArrayList<Geometry>();

        for ( int count = 0; count <= 5; count++ ) {

            double x = 10;
            double y = 10;
            double z = 10;

            Box      box = new Box( new Vector3f(count*10,count*10,count*10), (int)x, (int)y, (int)z );
            Geometry geo = new Geometry( "Box", box );
            Material mat = new Material( assetManager, "Common/MatDefs/Misc/Unshaded.j3md");

            mat.setColor( "Color", ColorRGBA.Blue );
            geo.setMaterial(mat);

            geos.add( geo );

        }

        /** Create a pivot node at (0,0,0) and attach it to the root node */
        Node pivot = new Node("pivot");
        rootNode.attachChild(pivot); // put this node in the scene

        /** Attach the two boxes to the *pivot* node. */
        for( Geometry g : geos ) {
            pivot.attachChild( g );
        }

        /** Rotate the pivot node: Note that both boxes have rotated! */
        pivot.rotate(.4f,.4f,0f);

    }




}

It errors on the app.start() command stating that it is a NULL pointer exception. How can app be a null pointer when the line before it does not error? I am lost as to what is wrong.

HISTORY: I need to be able to create a 3D render for my job of simple boxes. I need to load the model elements from another procedure and then cycle through them and draw them. I am using jMonkey because they originally wanted Xj3D but I couldn't find how to get it running. At least this I can get the tutorial working but when I modified it to loop and create several boxes now I get the null pointer issues.

Thanks in Advance! JH

EDIT:

Here is the console output:

Exception in thread "main" java.lang.NullPointerException
    at com.jme3.system.JmeDesktopSystem.showSettingsDialog(JmeDesktopSystem.java:73)
    at com.jme3.system.JmeSystem.showSettingsDialog(JmeSystem.java:108)
    at com.jme3.app.SimpleApplication.start(SimpleApplication.java:127)
    at test.test.main(test.java:34)
Patrick Aquilone
  • 584
  • 2
  • 11
  • 28
  • What is your stack trace? It may be that something has been set to null and is only being called when you start your app which is why you would see it on that line rather than app itself being null. – n00begon Jun 06 '12 at 02:04
  • Is that what you meant by stack trace? If not, how do I get it? – Patrick Aquilone Jun 06 '12 at 02:11
  • So it looks like the actual null pointer is on `JmeDesktopSystem.showSettingsDialog`. Did the tutorial you modified work? If so have you removed a line about a settings dialog? – n00begon Jun 06 '12 at 02:25
  • It did work. What I changed was added the for loop and the AppSettings stuff. Now, I added the AppSettings stuff first and that worked. Then when I added the for loop, it died. So, I must have somehow did something else when I was adding the for loop. – Patrick Aquilone Jun 06 '12 at 02:39
  • Ok, I changed the AppSettings settings = new AppSettings(false); to AppSettings settings = new AppSettings(true); and it works. The false is supposed to not show the splash dialog or so I thought. – Patrick Aquilone Jun 06 '12 at 02:40

2 Answers2

0

Ok, changing

AppSettings settings = new AppSettings(false);

to

AppSettings settings = new AppSettings(true);

fixed my problem. Now to figure out why the false didn't work.

Patrick Aquilone
  • 584
  • 2
  • 11
  • 28
  • have you ever seen that page?: http://hub.jmonkeyengine.org/javadoc/ and maybe even that one?: https://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/core/com/jme3/system/AppSettings.java?r=10615 don't forget, you have the power of Java opensource! – noncom Aug 13 '13 at 14:59
0

False doesn't load the default settings, meaning you're supposed to set them all manually. This is probably the reason for the NPE. To hide the settings dialog, use

app.setShowSettings(false);
Zoltán
  • 21,321
  • 14
  • 93
  • 134