Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

3d translate

BortelsBortels Mod
edited May 2012 in Questions Posts: 1,557

So - "translate(a,b)" effectively moves the origin a pixels right, b pixels up.

If I do "translate(a,b,c)" - what's c? More specifically - what units? And/or what are the clipping planes?

I'm trying to plot things in a 3d volume - and they keep disappearing.

Comments

  • SimeonSimeon Admin Mod
    Posts: 5,387

    @Bortels, c is in the same units as a and b — that is, a and b aren't strictly "pixels," It's just the way the default orthographic projection is set up. That is.

    ortho( 0, WIDTH, 0, HEIGHT, -1, 1)

    To understand clipping planes, imagine that the ortho() function creates a cube around your scene. The cube's lowest extremity is 0,0,-1 and its farthest is WIDTH,HEIGHT,1. Anything that falls outside of the cube won't be rendered, it will be "clipped" by the GPU. By default the near and far clipping planes do not provide much depth, you can change them, though.

    It sounds like your 3D volumes are exceeding the clipping planes. Extend them in order to encompass your scene.

  • Posts: 1,255

    So, if you created a DEPTH value set to an arbitrary value, say 1000, you could do

    ortho(0,0,0,WIDTH,HEIGHT,DEPTH) 
    

    And have a system where the "back" of the world was at 0 and the "front" at 1000?

    I confess, I've left the 3D projections alone not because I don't find them neat, but because I find the examples confusing... and I generaly grok both geometry and programming fairly well.

  • SimeonSimeon Admin Mod
    Posts: 5,387

    That's correct, though the arguments to ortho are in this order: ortho( left, right, bottom, top, near, far)

    Generally since everything is drawn at z=0 by default, you'd want your orthographic projection to heave a near plane of -depth and a far plane of depth.

    With perspective projection the near plane must be greater than zero.

  • BortelsBortels Mod
    Posts: 1,557

    So - making sure I understand - depth is -1 to 1, with -1 on my side of the screen, and 1 into the screen? And I can change that with ortho()?

    Good enough! (I was drawing planets, and when I put them in "deeper" - they just disappeared. This explains why...)

  • SimeonSimeon Admin Mod
    Posts: 5,387

    That's correct, try it with -1000 to 1000 for example. (Note that the same 32 bit precision is stretched over the specified range.)

Sign In or Register to comment.