calculation of a shear transform according to off-axis point of view

zanroversi's picture

Hello,

I experiment some openGL fundamentals operations like transformation matrices, frustum, off-axis rendering, head-tracking, etc... not for a specific project, just working around.

My goal is to find correct 2D points of 1024 Perspective patch (4 corners) to make the appropriate shear according to the position of a camera (or eye) in real space, in relation to screen size / position / rotation.

My target object is a square, I want to see a regular square from "any" point of view, at constant apparent size.

I would like to know if the following reasoning is correct :

  • default horizontal viewing angle in QC is 60°
  • a sprite is positioned at (x,y,z) = 0 and width = 2, it fits the screen (horizontally)
  • so the point of view in QC coordinates is at Z = 1/ tan (30°) = 1.73205
  • real world Z from screen = 1.73205 x half-width of screen

and

  • i've read somewhere that default frustum's Znear is 0.1 (no idea if QC does the same)
  • Is it why a sprite or GL point can't be seen on the screen (it vanishes) for Z > 1.63205 ( uh? equal to 1.73205 - 0.1)

As a first exercise, I've made the attached composition (with comments) + a top view of the same world. It gives some results, seems to work, but it may be not accurate. I really would like your opinion.

Any advice to achieve this properly ? Something with matrices only, I suppose 1024 perspective (thanks frz!) can be replaced by a appropriate transform matrix ?

Thanks by advance !

PreviewAttachmentSize
3Dview.qtz138.05 KB
top view.qtz137.72 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

jrs's picture
Re: calculation of a shear transform according to off-axis ...

I thought the default horizontal fov was 90° - you can use the "NI OpenGL Create Matrix" and "NI OpenGL Set Matrix" patches to view and and set the projection and modelview matrix's

zanroversi's picture
Re: calculation of a shear transform according to off-axis ...

Thanks jrs, i'll try this asap. ++