Camera shows nothing

Hello!



I have modified a bit the SimpleApplication class so that it doesn’t use FlyByCamera class at all. Then I redefined camera control system in my Main class so that camera moves and rotates. I also moved out to my Main class the procedures to show current camera info, like position, rotation and direction, and it moves/rotates perfect. But there’s one thing - camera shows nothing, except default information about scene and FPS in the lower left corner. I double checked camera’s location and lookAt vectors, I manually add one geometry and the info shows that there’s +1 object in the scene, virtually speaking.



What could be wrong?



I looked in the SimpleApplication and Application classes code and found the initCamera procedure that sets the cam’s resolution, creates a render manager and viewport, attaches cam to viewport. Everything seems ok. But nothing shows.



First, I thought it might be that the camera is created inside the geometry, but after I implemented camera’s move and rotate methods, I realized, that it is not the reason. What would it be then?

Have you added a light to the scene?

@ancalagon said:
Have you added a light to the scene?

I am using Common/MatDefs/Misc/Unshaded.j3md shader on the geometry, I believe you don't necessary need to add light to the scene to see objects with this material.
And I am using the default code from simple jme application, that is created automatically to show the blue box
[java]Box b = new Box(Vector3f.ZERO.addLocal(Vector3f.NAN), 1, 1, 1);
Geometry geom = new Geometry("Box", b);

Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
geom.setMaterial(mat);

rootNode.attachChild(geom);[/java]

I’m not sure to be honest. but try adding an AmbientLight just in case. If it does nothing, you can eliminate that possibility and move onto others.

@ancalagon said:
I'm not sure to be honest. but try adding an AmbientLight just in case. If it does nothing, you can eliminate that possibility and move onto others.

Added ambient light using:
[java] AmbientLight sun = new AmbientLight();
sun.setColor(ColorRGBA.White);
rootNode.addLight(sun);[/java]
Unfortunately I still get this:
http://i.imgur.com/BL0kh.png

Ok, it seems that I have found the problem. Somehow previous example code of box creation was pretty bad. I just changed [java]Box b = new Box(Vector3f.ZERO.addLocal(Vector3f.NAN), 1, 1, 1);[/java] to [java]Box b = new Box(Vector3f.ZERO, 1, 1, 1);[/java] and everything now works!

Have you remembered to remove the lenscap from the camera? :smiley: - Sorry couldnt resist.



As has been mentioned other places on these forums, creating boxes with offset of the mesh (and not zero centered) is normally begging for trouble. To move the box use setLocalTranslation(x,y,z).

NAN is an evil number that makes everything invalid. What you did was just put the box in a black hole, mathematically speaking