Orthographic camera

Hi All,



I am tryng to create an orthogonal camera in top of my scene, my code looks like this:





                this.camOrtho = this.getRenderer().createCamera(this.getWidth(), this.getHeight());



this.camOrtho.setDirection(new Vector3f(0, -1, 0));

this.camOrtho.setLocation(new Vector3f(0.0f, 10.0f, 0.0f));



this.camOrtho.setParallelProjection(true);



this.getRenderer().setCamera(this.camOrtho);

this.cam.update();



Doing this i don't see my scene, what i am making wrong?

I just ran into the same problems. It seams that all this is caused by the setDirection method of the Camera object.



I played a bit with the values and found that different lengths of the direction vector cause different camera behaviour.

e.g. (0.0f, -1.0f, -1.0f) causes the scene to be culled too early while (0.0f, -10.0f, -10.0f) works just fine.





Anyone mind enlighting me why the vector length of the camera vector matters? Is this maybe a jME bug?



Edit: I need to add something. I'm not using orthographic projection, but the normal perspective projection. Though, I wouldn't wonder if the problems are related to each other.

Hi mp,



We talked deeper in the following thread:



http://www.jmonkeyengine.com/jmeforum/index.php?topic=5104.0



Jordi.

Reading the Javadoc comment helped a lot. Took me about an hour to figure out that Camera.setDirection is no method you should ever call alone.



http://www.jmonkeyengine.com/doc/com/jme/renderer/AbstractCamera.html#setDirection(com.jme.math.Vector3f)
setDirection sets the direction this camera is facing. In most cases, this changes the up and left vectors of the camera. If your left or up vectors change, you must updates those as well for correct culling.


Thus, if I call Camera.setDirection I also need to make sure that Camera.setTop and Camera.setLeft are called with the right values.

Bottom line: I will use Camera.setFrame. It does all in one step and you can't forget to set the up or left vector.