Ok, I have been trying to use models in jme. I first make a model in 3ds max, export it to .obj along with a .mtl. When I import it and double click to view the only file in the models directory (.j3o) nothing happens. Also, when I try to edit the HelloAssets tutorial, the game doesn’t run at all. What should I do? How can I import my own models?
I just saw this topic: http://hub.jmonkeyengine.org/groups/graphics/forum/topic/process-for-importing-models-built-in-3dstudio-max/ , do I have to download the mentioned exporter?
Did you turn on the light when you were looking at the j3o model?
It doesnt come up at all. I click on view model and nothing happens.
Hello!
In the sceneviewer window (the middle one that’s probably black when you start up), your model will be displayed. However, without a light it probably won’t be visible. Try clicking the little lightbulb icon on the sceneviewer window and see if that helps and we’ll go from there
Cheers!
~FlaH
Thanks! It was my fault, I closed the sceneviewer by mistake. Sorry for wasting your time. However, I still cannot write the code which runs the program and shows the model.
If theres really an error displaying the model then you will get a small warning sign in the lower right with a stack trace of the exception.
This is my current code: [java]Spatial Ufo = assetManager.loadModel("Models/Ufo/Ufo.j30");
Material mat = new Material(assetManager, "Comman/MatDefs/Misc/ShowNormals.j3md");
Ufo.setMaterial(mat);
rootNode.attachChild(Ufo);[/java]
Yeah, no light in your scene. :roll: And why you set the ShowNormals material?
The light is later on, that is the part which doesnt work when I change it. I used the ShowNormals because I tried using the tutorial. I understand though that I can remove it. The game just doesn’t run at all.
What do you mean “doesn’t run”. Theres either an exception in the error log (probably with a good description on whats wrong) or you cant even compile it because of syntax errors which are normally underlined red.
A black window comes up, the cursor goes in the middle and then it exits.
The following is in the Output section (in red), however there is Build Successful in Green:
Jul 14, 2011 8:29:02 PM com.jme3.asset.DesktopAssetManager
INFO: DesktopAssetManager created.
Jul 14, 2011 8:29:02 PM com.jme3.renderer.Camera
INFO: Camera created (W: 640, H: 480)
Jul 14, 2011 8:29:02 PM com.jme3.renderer.Camera
INFO: Camera created (W: 640, H: 480)
Jul 14, 2011 8:29:02 PM com.jme3.input.lwjgl.LwjglMouseInput initialize
INFO: Mouse created.
Jul 14, 2011 8:29:02 PM com.jme3.input.lwjgl.LwjglKeyInput initialize
INFO: Keyboard created.
Jul 14, 2011 8:29:02 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: AudioRenderer supports 64 channels
Jul 14, 2011 8:29:02 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio effect extension version: 1.0
Jul 14, 2011 8:29:02 PM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio max auxilary sends: 1
Jul 14, 2011 8:29:02 PM com.jme3.material.MaterialDef
INFO: Loaded material definition: Unshaded
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Gui Node)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (BitmapFont) attached to this node (null)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (Statistics View)
Jul 14, 2011 8:29:02 PM com.jme3.scene.Node attachChild
INFO: Child (Statistics View) attached to this node (Gui Node)
Jul 14, 2011 8:29:02 PM com.jme3.asset.DesktopAssetManager loadAsset
WARNING: No loader registered for type j30.
Jul 14, 2011 8:29:02 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at com.jme3.scene.Node.attachChild(Node.java:251)
at mygame.HelloAssets.simpleInitApp(HelloAssets.java:21)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:218)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:138)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:206)
at java.lang.Thread.run(Thread.java:662)
BUILD SUCCESSFUL (total time: 6 seconds)
Dude, j-3-o jay-three-oh! Not jay-three-zero… What happens is this: you try to load a model and it fails because of the wrong name, you get null returned from loadModel, attachChild fails with a NPE because your variable is null.
Generally NPE’s are always your fault and they should always be easy to find. Its simple: you have a variable thats null somewhere, find out which.
Thanks a lot. I appreciate your time The game runs, although I can’t see the model. Thanks a lot, hopefully sometime I will be able to help others like you.
I have tried everything, however the model cannot seem to appear. I inserted teapot instead of the model’s name and a teapot appeared. Any suggestions?
EDIT: Problem solved. Apparently it was too big and the camera was inside it.