[SOLVED] J3o model mesh geometry


#1

Hi i wanted to know if i can set a j3o model from blender to geometry,and how to? I’ve made some cose and used Box and Geometry for objects in 3d world (hoping to fill them later with my models) and now i cant use a j3o model on place of box or add it to geom,i tried to finde any instructions in F1 in blender,but there is nothing similar… Any help is wellcome :slight_smile:
Oh and i dont need it phisics for now ,its a non collision world,but i use MyGeometry that extends Geometry to get and store alot of things i need soo i would really like to finde way to use geometry for that and probably without putting in box and model at same time…


#2

Have you read the tutorials?

The asset-pipeline information begins here:
https://jmonkeyengine.github.io/wiki/jme3/external/blender.html


#3

yep i did ,but all i try to do now is import a box created in blender, and still cant get it in Geometry


#4

right now i try this
Node MyCube = (Node) assetManager.loadModel(“Models/testModel/Cube.mesh.j3o”);
Geometry geom = (Geometry) MyCube.getChild(0);
System.out.println(MyCube.getChild(0).getClass()+" "+geom.getMesh());//+((Node) MyCube.getChild(0)).getChild(0).getClass()
Material mat_default = new Material(
assetManager, “Common/MatDefs/Misc/ShowNormals.j3md”);
Mesh mesh = geom.getMesh();
try{
Geometry spatGeom = new Geometry(“stringa1”, mesh);
Material spatGeomMat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
spatGeomMat.setTexture(“ColorMap”,assetManager.loadTexture(“Textures/Edilizia.png”));
spatGeom.setMaterial(spatGeomMat);
spatGeom.setLocalTranslation(1, 1,0);
spatGeom.setLocalScale(50, 50, 1);
MyCityBuilder.MainGameClass.permessoCostruire.attachChild(spatGeom); //needs mesh */
} catch(Exception e ){
e.printStackTrace();
} and i get this :frowning:

class com.jme3.scene.Geometry com.jme3.scene.Mesh@d01df37
java.lang.NullPointerException
at MyCityBuilder.TastoCasa.MenuTasti.MenuPrincipale.execute(MenuPrincipale.java:76)
at MyCityBuilder.MainGameClass.initCrossHairs(MainGameClass.java:1588)
at MyCityBuilder.MainGameClass.simpleInitApp(MainGameClass.java:764)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:226)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:744)


#5

First:

Second:

That ^^^ is what you lead with.

And then you tell us which line 76 is so that we can tell you exactly what your problem is in approximately 4.2 seconds.


#6

MyCityBuilder.MainGameClass.permessoCostruire.attachChild(spatGeom);
this is a node,and it works perfectly with other geometries that are made of box


#7

…is null.

My guess is that you never set it.

Your code organization, capitalization of fields like they are classes, use of static globals… all points to deep-seated problems.


#8

But it works fine for all other objects i put in it with the same class of same method.
Nope it doesnt … damn sor for make u wasting time ,some how that 1 is no setted… damn i used other 1 for others (objects)


#9

I’m telling you… with 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000% certainty:

This: MyCityBuilder.MainGameClass.permessoCostruire

is null.

If that’s the line the NPE is on. That value is null. !00% guaranteed or all your money back.

It’s up to you to sort out the spaghetti to figure out why. But often it’s the case with static globals that you set it in one case but not another, or this code runs before the code that set it, or 10000 different things that come from crappy design like this instead of using proper initialization, app states, and so on.

Edit: actually, if you don’t believe me… just use the most basic debugging building block and print the value right before that line.

Edit 2: I’ve also made (perhaps most egregiously) the assumption that MyCityBuilder is a class and that MainGameClass is an inner class… but that’s just based on the usage and naming. Given that you name your fields like classes then that could be a bad assumption on my part. In which case, either of those could be null also.


#10

Yeah you are right men ,i do belive u :slight_smile: i have cheked it as well and u are right


#11

As allways i messed up with some part of a code ,and its not setted as u said soo thnx ,i would never supposed by my self it was off couse all others was on,but seems it was last string in app starting soo that why it was broken :smiley:


#12

Quest solved thnx for help ,we can even close this tread(i just got overhelmed by chaose :smiley: )
sorry for disturb


#13

Programmers are very good at creating chaos.