[SOLVED] Model Loads throw nullpointerexception

Hello guyz,

I started a new project in jmonkey and I have a problem loading scene via assetManager.
In previous project I loaded scene in same way as I do now, without any problem.

My code:

In main class I’m just using:

ChessBoard chessBoard = new ChessBoard();

@Override
    public void simpleInitApp() {
        chessBoard.simpleInitApp();
    }

Can anyone help me, where is the problem?

Edit:

Errors occured during face triangulation: Unable to find two closest vertices while triangulating face in mesh: TemporalMesh [name=Cube.001, vertices.size()=32]Please apply triangulation modifier in blender as a workaround and load again!. The face will be triangulated with the most direct algorithm, but the results might not be identical to blender.

What does this mean? I took a look on my chessboard, in blender it looks normály and jmonkey just can’t convert it? Why? It means I have to remake in different way to make it actually work right?

Thanks

The assetManager is null?

This probably does not init the variable at all… You should debug line by line.

Easy:
A) NPE in Line 33 means that something you accessed to using . was null.
This can only be assetManager. I can’t tell you why that is the case though, maybe some wrong setup/startup?

B) It is only a warning. The Engine can only use Meshes made out of triangles. Your Model uses Quads or something different and the Conversion algorithm just failed for one of those. Technically you can do what it tells you: Mesh → Modifiers → Triangulate, then Blender will do the triangulation (it is more powerful).

Note that you should only do this (click apply) on a copy of your model or something since it will change your Mesh, so when you want to edit all is suddenly triangles.

Edit: How about super.simpleInitApp(); before Line 33?

Actually I tried to make it all happen in one class and it is working.

Just, how can I make it work, when I want to make stuff like light, scene and models in one class, meanwhile in main.class I will just call all the other classes to make board, add pieces etc?
If I want to load model I have to extend from SImpleApplication cause without it I have no access to rootNode to make it visible.

You can use AppStates. I suggest the tutorials.

I have done all the tutorials in “F1” help like year ago. But as I know, there is nothing about it. In Tutorials it is not actually OOP, everything is in simpleInitApp(); which will not help me at all. I just want to make all stuff “loading assets” in another class and just “use” simpleInitApp from that class in main class to make it more organized. That’s all. Nothing more :slight_smile:

I can’t use super.simpleInitApp → I can’t access directly to abstract method in SimpleApplication

Any other idea? :smile:

As I said above, I want to make it more OOP. That’s only reason why I want to make initialization in another class.

Thanks

As he said, take a look at Redirect Notice about AppStates.
To use them extend BaseAppState however if you just want to construct something I would make “usual” classes and just call their “load” method, so the Mainclass still organizes things. To load something you don’t need the rootNode

Do you manually execute ChessBoards simpleInitApp? And do you have both Main and ChessBoard extend SimpleApplication?

That is wrong, you only have one Application, the others being AppStates (for seperate features) or a usual class even.

Which is to have a simple working example, everything else would only complicate learning

Ok, I will take a look, hope it will help me :slight_smile:

Thanks guyz.

This is more of a java question, but you need to look into “class constructors” and “method arguments”. Those are the keywords you should be googling.

I made up some changes and tried few new things but still I have a problems.

After getting into SimpleApplication and assetManager I have still same problem.
Code:

It still have same problem, It is null. Well if I use it in Main class, everything is fine, then why this does not work?

And another problem about Blender chessboard. I used triangulation (modification). But it still can’t convert properly the model.

What do I incorrect? Why does it not look same?

@Darkchaos

Try moving the ChessBoard initialization to simpleInitApp().
And for blender, it’s probably the material. And I’ve had it that without a restart, on importing the same model again (same blender file name) that the SDK just uses the first version you imported. So try adding “_V02” and so on to your file name and reimport.

Thanks man, helped a lot.

Well I have another problem that model can’t load texture made up in blender but will find out somewhere else :slight_smile:

Thanks guyz

Have you done it with UVs in blender?