assetManager throws a NPE

Hello,

After having finnished to draw a demonatration map with the build in terrain editor. The result is a Map_demo1.j3o in the “Scenes” folder and the used taxtures in the “Textures” folder.



Now i started programming a simple MapLoader class which now should only load the map. (I have also tryed to implement the water as specified in the watermonkey tutorial, but thats not the current problem.)



No matter what i do, a call to any assetManager function results in a null pointer exeption. I am extending SimpleApplication so i guess i don’t need to call super.initialize() (if i do the application crashes during runtime).



Can you see the error, or how do i initialize to AssetManager correctly? here is the code:



Main.java:

[java]

package Startup;





import com.jme3.app.SimpleApplication;

import com.jme3.math.Vector3f;





/**

  • test
  • @author normenhansen

    /

    public class Main extends SimpleApplication {

    private MapLoader MapManager;



    public static void main(String[] args) {

    Main app = new Main();

    app.start();

    }



    @Override

    public void simpleInitApp() {

    this.MapManager=new MapLoader();

    this.rootNode.attachChild(this.MapManager.doLoadNewMap("", new Vector3f(-4.9f, -1.3f, 5.9f),0.1f, true, this));

    }



    @Override

    public void simpleUpdate(float tpf){

    //this.MapManager.doUpdateMap(tpf);

    }

    }

    [/java]



    MapLoader.java:

    [java]

    /

  • To change this template, choose Tools | Templates
  • and open the template in the editor.

    */

    package Startup;



    import com.jme3.asset.AssetManager;

    import com.jme3.bounding.BoundingVolume;

    import com.jme3.collision.Collidable;

    import com.jme3.collision.CollisionResults;

    import com.jme3.collision.UnsupportedCollisionException;

    import com.jme3.math.FastMath;

    import com.jme3.math.Vector3f;

    import com.jme3.post.FilterPostProcessor;

    import com.jme3.scene.Node;

    import com.jme3.scene.SceneGraphVisitor;

    import com.jme3.scene.Spatial;

    import com.jme3.water.WaterFilter;

    import java.util.Queue;



    /**

    *
  • @author zzuegg

    */

    public class MapLoader {

    Node map;

    private FilterPostProcessor ffp;

    private WaterFilter water;

    private Vector3f lightDirection;

    private boolean waves;

    private float waterHeight;

    private float waterHeightMod;

    private float time;

    private Main master;

    private AssetManager assetManager;



    void MapLoader(Main program){

    this.master=program;

    this.assetManager=master.getAssetManager();

    }





    Node doLoadNewMap(String mapname, Vector3f ld, float waterInit, boolean waves,Main program){



    this.lightDirection= new Vector3f(-4.9f, -1.3f, 5.9f);

    this.waves=waves;

    this.waterHeight=waterInit;

    this.time=0;

    this.map=new Node();



    System.out.println(this.assetManager.toString());



    Spatial terrain=this.assetManager.loadModel("Scenes/Map_demo1.j3o");

    map.attachChild(terrain);



    //this.ffp=new FilterPostProcessor(this.assetManager);

    //this.water=new WaterFilter(this.map,this.lightDirection);

    //this.water.setWaterHeight(this.waterHeight);

    //this.ffp.addFilter(this.water);

    //master.getViewPort().addProcessor(this.ffp);



    return map;

    }



    void doUpdateMap(float tpf){

    master.simpleUpdate(tpf);

    time+=tpf;

    waterHeightMod = (float) Math.cos(((time * 0.6f) % FastMath.TWO_PI)) * 1.5f;

    water.setWaterHeight(waterHeight+waterHeightMod);

    }





    }



    [/java]

Sorry, i have not found a “Topic delete” button. I have found the problem myself. The problem was that i did not pass the main program correctly to the MapLoader

computer says no

computer says no

What?

“computer says no”



LOL, Carol Beer is one of the greatest :smiley: HAHAHA, now must watch ‘her’ from youtube!

:D:D:D

for you unaware people:

http://www.youtube.com/watch?v=Ly3Ew3wQ4PA

C, definitely C. :wink:

If the assetManager should ever throw a NPE instead of a “KirillEducatesYouAboutYourDeficiency” exception then the world is doomed xD

Friendly community here…

Everyone has been a little sillier lately. Maybe it’s the new less serious monkey.

@zzuegg

Friendly community here…


Sorry, don’t feel personally offended :slight_smile: Be sure that well formulated posts backed with code like yours will be promptly answered on these forums, if you add error code you should get an answer in less than one day. But as @pspeed hinted at, the jMonkeyEngine is a living and breathing project and you will find people here, not hotline drones :wink: Welcome to the jME community :slight_smile:

@zzuegg

Friendly community here…

rly? whats "unfriendly" about trolling a thread that you wanted deleted anyways? theres no negative comments directed towards anyone here or anywhere on this forum (except that one person, who shall not be named :P), you won't find a friendlier community than ours <3