Issue with Renderer.QUEUE_ORTHO

Everyone,



This is a noob question, but I've been getting a bruise where I've been banging my head on the wall over it, so its time to swallow pride …



Im attempting to draw a grid in orthographic perspective.  After some problems I tried to draw just a single line, and the issue Im having is that if I draw it in default mode (which I assume is perspective), I get the line on my screen, and if include "line.setRenderQueueMode(Renderer.QUEUE_ORTHO)" as shown in the snippet below, I get nothing.



        Vector3f[] vertices = new Vector3f[2];

        vertices[0] = new Vector3f(0, 16, 0);

        vertices[1] = new Vector3f(0, -16, 0);

        line = new Line("grid", vertices, null, null, null);       

        line.setLightCombineMode(LightCombineMode.Off);

        line.setDefaultColor(new ColorRGBA(0, 1, 0, 1));

        line.setLocalRotation(new Quaternion(0, 0, 0, 1));

        line.setLocalTranslation(0, 0, 0);

        line.setLocalScale(new Vector3f(1,1,1));

        line.setRenderQueueMode(Renderer.QUEUE_ORTHO);



In the method that calls the above snippet, I do the things one is usually supposed to do with the root node:



        rootNode.attachChild(line);

        rootNode.updateGeometricState(0, true);

        rootNode.updateRenderState();



Is there something obvious that Im missing here?



Thanks in advance,



jonbitzen

The line was drawn at 0,0, which is at the very lower left corner of the screen.

add a line.setLocalTranslation(display.getWidth()/2, display.getHeight()/2, 0); to display it in the middle.



Also a line.setCullHint(CullHint.Never); can't hurt if you have problems, to make sure its not anciently culled, not sure if its actually needed tho :slight_smile:

Hey Core-Dump -



Thanks very much for your response, that fixed the problem, but it has created new questions!



Originally when I coded this thing, I did it without orthographic projection [nix everything between setLocalRotation and setRenderQueueMode inclusive], and my line (reaching to +/- 16) almost reached to the top and bottom, but not quite, so I assumed that the perspective transformation made the line appear smaller than it was. which is what caused me to try orthographic projection.



Is the orthographic projection in a screen coordinate system then?  I was originally trying to create a grid in world units in the XY plane at z=0 (I calculated 16 in my code snippet from the frustrum half-angle and camera distance from the origin == 42).  Now I get a short line segment in the middle of the screen, and the only way to make it stretch top-to-bottom is to change the vertices to be +/-.



I'm a bit mystified by the relation among the coordinate systems. 



Thanks,



jonbitzen

Is the orthographic projection in a screen coordinate system then?

yes, with coordinates from from 0,0 (lower left)  to screenwidth/ screenheigth (upper right)

Well it depends what you need the grid for.
The ortho mode is mostly used to draw a HUD or GUI.
If you want to draw a grid like in blender or other 3d modeller, you should draw that in perspective mode. see http://www.jmonkeyengine.com/jmeforum/index.php?topic=7983.0
What do you need the grid for ?

Im working on a spaceship game with a top-down view.  I want to have the spaceship stay in the center, and have the grid move to provide a sense of motion.  So, I want the location of each line on the grid to directly correspond to a location in the world coordinate system.

I'd like to avoid having the player see the edges of the grid if they zoom out too far.  So I wanted to create a 2D grid that would overlap the screen by at least 2 grid sections on each side so that I could basically just scoot that relatively small piece of geometry around the ship so that it would lie on world coordinate lines according to whatever the grid scale was (1, 5, 10, etc.).

I scanned the link you sent - I'll have a closer look, it seems it may represent a wheel I dont have to invent.  Thanks!

jonbitzen