Login  Register

School me on perspective implementation, please...

Posted by LordSmoke on Mar 30, 2017; 8:41pm
URL: https://forum.jogamp.org/School-me-on-perspective-implementation-please-tp4037826.html

I have made much progress in my JOGL/OpenGL programming. At this point, I can create, plot, color, animate various geometric models, but I am a bit stuck on implementing perspective. Models are built, colored, scaled, translated to fit in -1,1 x,y with aspect-correction.

I understand the geometry, the algebra, the matrix algebra, etc. of perspective projection. I am just not sure what to do with this information. Right now, I have the following transformations applied to raw vertex coordinates

AspectMx * AnimationMx * ViewMx * ModelMx * vertexDataVec

(there are others, but they are all identity at this point)

The ModelMx places the vertices (for, say, a unit cube) into world space
The ViewMx scales, translates the model into -1/1 x,y.
The AnimationMx spins it around using an FPSAnimator.
The AspectMx adjusts for the window shape

So, do I need a matrix to map my vertices further into a specified frustum? Do I then build a perspective matrix based on that frustum. Something like I am doing currently...

AspectMx * PerspectiveMx * FrustumMx * AnimationMx * ViewMx * ModelMx * vertexDataVec

Or are there some other context functions I should call. I see some fixed-pipeline code using something like glu.perspective (don't think that is relevant), and I see functions in FloatUtil for makePerspective, makeOrtho, makeFrustum, makeLookAt. Just not sure where to go with this.

Oh, I have written my own "working" perspective mx, but the model seems significantly smaller than that produce by my orthogonal projection matrix, which is really no different than no projection at this point.

TIA, LS

Also, not sure who, if anyone, cares or can do anything about it, but "googling" "jogl float util" brings up a first hit from 2004, v. 2.1.4 with deprecated functions using FloatBuffers. The more useful second entry is to the 2.3.1 version.

Heck, here's a pic (perspective on - it should really nearly fill the window)...