Professional Documents
Culture Documents
N2D Transformation N2D Transformation Device vs. Screen Coordinates Projective Rendering Pipeline
• general formulation • viewport/window location wrt actual display not available Scene.add(x) THREE.PerspectiveCamera(...)
within GL object world viewing
• reflect in y for upper vs. lower left origin
O2W W2V alter w
• scale by width, height, depth
• usually don’t care
OCS WCS VCS V2C
• use relative information when handling mouse events, not modeling viewing projection
• translate by width/2, height/2, depth/2 absolute coordinates transformation transformation transformation
Display z range is 0 to 1. clipping
• FCG includes additional translation for pixel centers at gl.depthRange(n,f) can • could get actual display height/width, window offsets from OS m.makeTranlation(x,y,z) camera.lookAt(...)
C2N /w
m.makeRotation(a,x,y,z) CCS
(.5, .5) instead of (0,0) reminder: constrain further, but depth = 1 • loose use of terms: device, display, window, screen... perspective
x.setMatrix(m)
NDC z range is -1 to 1 is both max and default 0 x 1024 division normalized
0 x 0 x OCS - object coordinate system
500 500 0 x 500 0 y canvas.{w,h} device
y y y offset N2D
0 y 0 y WCS - world coordinate system gl.viewport(x,y,a,b) NDCS
height height 0 y
1 1 x offset display VCS - viewing coordinate system viewport
viewport viewport height transformation
x viewport x viewport CCS - clipping coordinate system device
NDC NDC
300 display
-1 -1 NDCS - normalized device coordinate system DCS
width width 768
1 5 1 6 7 8
-1 300 -1 300 display width DCS - device coordinate system
normalized device
divide by w x=-1 x=1
(3-space
parallelepiped) 1 ymax-1
z=-4
scale & device real
translate (3-space midpoint -1
z=-1 1 xmax-1
parallelipiped) -1 -1 0 0
x
NDCS DCS
(z not shown) (z not shown)
z
framebuffer
VCS
top view
9 10 11 12
Perspective Example Projective Rendering Pipeline OpenGL Example Coord Sys: Frame vs Point
following pipeline from top/left to go back from end of pipeline to beginning: coord frame POV!
read down: transforming read up: transforming points,
scene.add(x) bottom/right: moving object POV object world viewing clipping between coordinate frames, up from frame B coords to
THREE.PerspectiveCamera(...) O2W W2V VCS V2C CCS
object world viewing alter w OCS WCS from frame A to frame B frame A coords
modeling viewing projection
O2W WCS W2V VCS V2C
OCS transformation transformation transformation
OpenGL command order
modeling viewing projection
transformation transformation transformation
clipping CCS DCS display
m.makeTranlation(x,y,z) camera.lookAt(...) gl.viewport(0,0,w,h); D2N gl.viewport(x,y,a,b) N2D
m.makeRotation(a,x,y,z)
C2N /w CCS
x.setMatrix(m) perspective
NDCS normalized device
division normalized VCS N2V THREE.PerspectiveCamera(...) V2N
OCS - object coordinate system THREE.PerspectiveCamera(view angle, aspect, near, far)
canvas.{w,h} VCS viewing
WCS - world coordinate system gl.viewport(x,y,a,b) N2D device
/w NDCS u_xformMatrix = Identity() V2W camera.lookAt(...) W2V
viewport
WCS
VCS - viewing coordinate system gl.uniformMatrix4fv(u_xformMatrix, false, xformMatrix); WCS world
transformation
OCS1 m.makeRotationX(…)
CCS - clipping coordinate system device W2O O2W
torsoGeometry.applyMatrix(u_xformMatrix );
DCS var torso = new THREE.Mesh(torsoGeometry,normalMaterial);
OCS object
NDCS - normalized device coordinate system
scene.add(torso); scene.add(object)
13 14 15 16
DCS - device coordinate system pipeline interpretation
Questions?
17