How does Z parameter of ofTranslate work?

looking at ofTranslate there is a z paramenter, how does it affect drawing?

I was expecting it to draw things bigger or smaller if they are “closer” or “father” away, when drawing 2d shapes, but it doesn’t quite work that way.

I wonder if it is drawing them on the z axis but there is no perspective implemented in the …“renderer”? 3d coordinate system? or whatever it’s called, I’m too much of a newb.

It affects your objects by translating them along the z-axis.
When you look at your app window, the positive x-axis can be pictured from the top left corner of the window to the top right right corner, and the positive y-axis from top left to bottom left corner. Of course each axis is probably more of a normalised vector (length/magnitude 1) just pointing in a direction.
In this setup, the z-axis is perpendicular to the plane formed by the x- and y-axis (i.e. your app window), which means that it points away from you (or comes towards you), if that makes sense?

One way to test if your code works is to ofEnableDepthTest() (link), which draws objects by depth, as opposed to, by draw order.
Furthermore, you can setup an ofEasyCam() (link), which lets you rotate your view with your mouse, much like CG or CAD apps do in their viewports.
Once you have rotated, paned, or zoomed-in or out, the x- and y-axis obviously won’t correspond to your window width and height anymore. Instead, you can think of them a a plane that sits at an origin point in space, has an x- and y-axis and its normal is the z-axis. The normal is a vector that is calculated by getting the cross product between both axes (link).

Haha, yes there is. It’s just a matter of perspective. :wink:

when I use ofEasyCam I can see perspective, but now it draws the 2D stuff in a quadrant that isn’t the center of the screen. It seems like using a camera centers the screen at 0,0,0, while not using a camera puts the 0,0,0 at the corner of the screen.

Not sure how to make the ofEasyCam center on the standard plane that you get when drawing without a camera?

Tried doing

camEasyCam.begin(ofRectangle(0, 0, ofGetWidth(), ofGetHeight()));

but it wouldn’t center on my ofDrawRectangle calls.

Also, when not using a camera, does the standard plane have an orthographic projection? It seems like it doesn’t have depth-perspective

Yes, that sounds about right. In 2D, the origin is in the top left corner of the window. In 3D, the camera targets the origin directly, which puts it in the scene center.
You can also set the camera to target anything else with camera.setTarget(), in your case probably camera.setTarget(glm::vec3(ofGetWidth()/2, ofGetHeight()/2, 0)). This makes the camera itself rotate to target something.

There is no standard plane. There’s just an imaginary world axis in 3D, made up by three directional vectors, for orientation purposes. What you probably mean by “standard plane” would be the plane of the world x-axis and y-axis. Understand though that the origin of this world axis is relative. It’s position can be the (0, 0, 0), but doesn’t have to be!

As I understand it, this only defines the viewport, the window through which you see the scene, but doesn’t change the camera position.
If you want to change the camera position you need to use an ofTranslate(). You can move, rotate, and scale cameras like any other object.

Orthographic projection can be enabled for an ofCamera by calling camera.enableOrtho(). I’m not sure, if that’s possible for ofEasyCams?
Sure it does, remember that you should enableDepthTest() for the drawing, otherwise the objects get rendered by draw order!