Presentation is loading. Please wait.

Presentation is loading. Please wait.

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 3D Viewing III.

Similar presentations


Presentation on theme: "I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 3D Viewing III."— Presentation transcript:

1 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 3D Viewing III

2 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 1/43 Review from last time: –specifying 3D view—setting up synthetic camera –the shape of 3D view volume (clipping region) The mathematics of planar geometric projections –how do we get from view specification to 2D picture? Viewing in Three Dimensions: Mathematics of Projections

3 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 2/43 deriving 2D picture from 3D view parameters is hard problem our method relies on fact that it’s easier to make a picture from canonical view volume (3D parallel projection cuboid) at canonical view position (camera at the origin, looking down the negative z-axis) than it is from user’s specified arbitrary position. We’ll break the process into three easier steps: 1.get parameters for view specification (covered in last lecture) 2.transform from specified view volume into canonical view volume 3.using canonical view, clip and project scene to make 2D picture Lecture Roadmap

4 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 3/43 Reduce degrees of freedom; five steps to specifying view volume –position camera (and therefore its view/film plane) –point it at what you want to see, with camera in orientation you want –define field of view (for a perspective view volume, aspect ratio of film and angle of view: somewhere between wide angle, normal, and zoom; for a parallel view volume, width and height) –choose perspective or parallel projection –determine the focal distance Stage One: Specifying a View Volume

5 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 4/43 Perspective Projection: Truncated Pyramid – Frustum Look vector is the center line of the pyramid, the vector that lines up with “the barrel of the lens” Note: For ease of specification, up vector need not to be perpendicular to Look vector, but they cannot be collinear Examples of a View Volume (1/2) Position Near distance Far distance Height angle Width angle = Look vector Up vector Height angle Aspect ratio x y z

6 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 5/43 Orthographic Parallel Projection: Truncated View Volume – Cuboid Orthographic parallel projection has no view angle parameter Examples of a View Volume (2/2) Height Width Look vector Near distance Position Far distance Up vector x y z

7 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 6/43 Placement of view volume (visible part of world) specified by camera’s position and orientation –Position (a point) –Look and Up vectors Shape of view volume specified by –horizontal and vertical view angles –front and back clipping planes Perspective projection: projectors intersect at Position Parallel projection: projectors parallel to Look vector, but never intersect (or intersect at infinity) Coordinate Systems –world coordinates – standard right-handed xyz 3-space –viewing reference coordinates – camera-space right handed coordinate system (u, v, n); origin at Position and axes rotated by orientation; used for transforming arbitrary view into canonical view Specifying Arbitrary 3D Views

8 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 7/43 We have now specified an arbitrary view using our viewing parameters Problem: map arbitrary view specification to 2D picture of scene. This is hard, both for clipping and for projection Solution: reduce to a simpler problem and solve Note: Look vector along negative, not positive, z-axis is arbitrary but makes math easier Arbitrary View Volume Too Complex – there is a view specification from which it is easy to take a picture. We’ll call it the canonical view: from the origin, looking down the negative z-axis – parallel projection – sits at origin: Position = (0, 0, 0) – looks along negative z-axis: Look vector = (0, 0, –1) – oriented upright: Up vector = (0, 1, 0) – film plane extending from –1 to 1 in x and y – think of the scene as lying behind a window and we’re looking through the window up n v u

9 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 8/43 Our goal is to transform our arbitrary view and the world to the canonical view volume, maintaining the relationship between view volume and world, then take picture –for parallel view volume, transformation is affine: made up of translations, rotations, and scales –in the case of a perspective view volume, it also contains a non-affine † perspective transformation that turns a frustum into a parallel view volume, a cuboid –the composite transformation that will transform the arbitrary view volume to the canonical view volume, named the normalizing transformation, is still a 4x4 homogeneous coordinate matrix that typically has an inverse –easy to clip against this canonical view volume; clipping planes are axis-aligned! –projection using the canonical view volume is even easier: just omit the z-coordinate –for oblique parallel projection, a shearing transform is part of the composite transform, to “de-oblique” the view volume Normalizing to the Canonical View Volume † Affine transformations preserve parallelism but not lengths and angles. The perspective transformation is a type of non-affine transformation known as a projective transformation, which does not preserve parallelism

10 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 9/43 Problem of taking a picture has now been reduced to problem of finding correct normalizing transformation It is a bit tricky to find the rotation component of the normalizing transformation. But it is easier to find the inverse of this rotational component (trust us) So we’ll digress for a moment and focus our attention on the inverse of the normalizing transformation, which is called the viewing transformation. The viewing transformation turns the canonical view into the arbitrary view, or (x, y, z) to (u, v, n) VT VT : (x, y, z) (u, v, n) NT NT : (u, v, n) (x, y, z) NT = VT - NT = VT - 1 Viewing Transformation (VT) Normalizing Transformation (NT)

11 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 4/43 Up x y z

12 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 4/43 Up x y z Durand and Cutler, MIT

13 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 4/43 Position Near distance Far distance Height angle Width angle = Look vector Up vector Height angle Aspect ratio VT VT : (x, y, z)  (u, v, n) NT NT : (u, v, n)  (x, y, z) NT = VT - 1 VT VT

14 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 10/43 We know the view specification: Position, Look vector, and Up vector We need to derive an affine transformation from these parameters that will translate and rotate the canonical view into our arbitrary viewWe need to derive an affine transformation from these parameters that will translate and rotate the canonical view into our arbitrary view –scaling of film (i.e. cross-section of view volume) to make a square cross-section will happen at a later stage, as will clipping Translation is easy to find: we want to translate the origin to the point Position; therefore, the translation matrix is Rotation is harder: how do we generate a rotation matrix from the viewing specifications that will turn x, y, z, into u, v, n? –a digression on rotation will help answer this Building Viewing Transformation from View Specification

15 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 4/43 VT VT : (x, y, z)  (u, v, n) Position Near distance Far distance Height angle Width angle = Look vector Up vector Height angle Aspect ratio u n v u n v T (Position) y x z

16 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 11/43 3 x 3 rotation matrices We learned about 3 x 3 matrices that “rotate” the world (we’re leaving out the homogeneous coordinate for simplicity) When they do, the three unit vectors that used to point along the x, y, and z axes are moved to new positions Because it is a rigid-body rotation –the new vectors are still unit vectors –the new vectors are still perpendicular to each other –the new vectors still satisfy the “right hand rule” Any matrix transformation that has these three properties is a rotation about some axis by some amount! Let’s call the three x-axis, y-axis, and z-axis-aligned unit vectors e 1, e 2, e 3 Writing out: Rotation (1/5)

17 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 12/43 Let’s call our rotation matrix M and suppose that it has columns v 1, v 2, and v 3 : When we multiply M by e 1, what do we get? Similarly for e 2 and e 3 : Rotation (2/5)

18 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 13/43 Thus, for any matrix M, we know that Me 1 is the first column of M If M is a rotation matrix, we know that Me 1 (i.e., where e 1 got rotated to) must be a unit-length vector (because rotations preserve length) Since Me 1 = v 1, first column of any rotation matrix M must be a unit vector Also, vectors e 1 and e 2 are perpendicular… So if M is a rotation matrix, vectors Me 1 and Me 2 are perpendicular… (if you start with perpendicular vectors and rotate them, they’re still perpendicular) But these are the first and second columns of M … Ditto for the other two pairs As we noted in slide on rotation matrices, for a rotation matrix with columns v i –columns must be unit vectors: ||v i || = 1 –columns are perpendicular: v i v j = 0 (i  j) Rotation (3/5)

19 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 14/43 Therefore (for rotation matrices) We can write this matrix of v i v j dot products as where M T is a matrix whose rows are v 1, v 2, and v 3 Also, for matrices in general, M -1 M = I, (actually, M -1 exists only for “well-behaved” matrices) Therefore, for rotation matrices only we have just shown that M -1 is simply M T M T is trivial to compute, M -1 takes considerable work: big win! Rotation (4/5)

20 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 15/43 Summary If M is a rotation matrix, then its columns are pairwise perpendicular and have unit length Inversely, if the columns of a matrix are pairwise perpendicular and have unit length and satisfy the right-hand rule, then the matrix is a rotation For such a matrix, Rotation (5/5)

21 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 16/43 Now we know that a rotation matrix is a matrix that will turn the perpendicular unit vectors e 1, e 2, and e 3 into the new perpendicular unit vectors v 1, v 2, and v 3 Additionally, we know that the columns of this matrix will be the vectors v 1, v 2, and v 3 Let’s call the vectors e 1, e 2, and e 3 the world-space axes x, y, and z, and let’s call the vectors v 1, v 2, and v 3 the camera-space unit vector axes u, v, and n We want to build a rotation matrix that will normalize (u, v, n) into (x, y, z). We just found a matrix, M, that will turn (x, y, z) into (u, v, n). Conversely, M -1 =M T turns (u, v, n) into (x, y, z). The rows of M T will just be u, v, and n Reduces the problem of finding the correct rotation matrix into finding the correct perpendicular unit vectors u, v, and n Restatement of rotation problem: find u, v, and n using Position, and the Look vector and Up vector, then applying M T to get the x, y, z unit vectors e 1, e 2, e 3 Building the Orientation Matrix

22 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 17/43 We know that the (u, v, n) axes we want will have the properties that –our arbitrary Look Vector will lie along the negative n-axis –a projection of the Up Vector into the plane perpendicular to the n-axis will lie along the v- axis –The u-axis will be mutually perpendicular to the v and n-axes, and will form a right-handed coordinate system Plan of attack: first find n from Look, then find u from n and Up, then find v from n and u Finding u, v, and n from Position, Look, and Up (1/6)

23 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 18/43 Finding n Finding n is easy. Look vector in canonical volume lies on –z. Since z maps to n, n is a normalized vector pointing in the opposite direction from our arbitrary Look vector Finding u, v, and n (2/6) Look up n v u Now would be a good time to review right hand rule.

24 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 19/43 Finding u Problem: orientation of u-axis is constrained by v and n-axes... But we don’t have a v-axis yet. How can we proceed? Solution: we will use Up vector instead of v-axis. The only problem with this is that (u, Up, n) will not necessarily form an orthogonal basis, i.e., mutually perpendicular and unit vectors (because Up is at an arbitrary angle to n). We’ll correct this later. The constraints on u are: –1. must be perpendicular to plane spanned by n-axis and Up vector –2. (u, Up, n) must form a right-handed (though not mutually perpendicular) coordinate system To satisfy (1), we can use cross-product, but which one should we use? –n X Up and Up X n are both perpendicular to the plane, but in different directions... Answer: cross-products are right-handed, so use Up X n to satisfy (2) as well –Use cross-product applet to convince yourself that “order matters” in cross-product: Applets->Linear Algebra->Cross Product Finding u, v, and n (3/6)

25 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 20/43 Finding u, cont’d. So, the formula is: Note: n is unit length, but Up vector might not be unit length or perpendicular to n, so we had to normalize u Problem: what happens if Up and n are parallel? Answer: the length ||Up x n|| is zero, which means we would divide by 0 in the above equation. Bad stuff, don’t let it happen! –try it out on the applet As a reminder, the cross product of two vectors a and b is: Finding u, v, and n (4/6)

26 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 21/43 Finding v From previous slide, we currently have (u, Up, n) but coordinate system not mutually perpendicular Finding v just as easy as finding u; v must be perpendicular to u & n, & (u, v, n) must be right- handed coordinate system Again using right hand rule: Do not need to normalize v... why? Since n and u are unit length and mutually perpendicular, then their cross product is also unit length (see the applet!). Finding u, v, and n (5/6)

27 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 22/43 To summarize The viewing transformation is now fully specified –knowing u, v, and n, we can rotate the canonical view into the user-specified orientation –we already know how to translate the view Important: Note that we don’t actually apply the forward viewing transformation. Instead, the inverse viewing transformation, namely the normalizing transformation, will be used to map the arbitrary view into the canonical view Finding u, v, and n (6/6)

28 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S The Viewing Problem for Parallel Projection Given a parallel view specification and vertices of a bunch of objects, we use the normalizing transformation, i.e., the inverse viewing transformation, to normalize the view volume to a cuboid at the origin, then clip, and then project by ignoring z The Viewing Problem for Perspective Projection Normalize the perspective view specification to a unit frustum at the origin looking down the –z axis; then transform the perspective view volume into a parallel (cuboid) view volume, simplifying both clipping and projection Andries van Dam September 23, 2004 3D Viewing III 23/43 Transforming to the Canonical View Back clip plane transforms to z = -1 Front clip plane transforms to z = 0 (1, 1, 0) Note: it’s a cuboid, not a cube (makes transformation arithmetic and clipping easy)

29 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 24/43 The Parallel Case Decomposes into multiple steps Each step defined by a matrix transformation The product of these matrices defines the whole transformation in one, more “complex,” composite matrix. The steps are: –move the eye/camera to the origin –transform the view so that (u, v, n) is aligned with (x, y, z) –adjust the scales so that the view volume fits between –1 and 1 in x and y, the back clip plane lies at z = –1, the front plane at z = 0 The Perspective Case Same as parallel, but add one more step: –distort pyramid to cuboid to achieve perspective distortion and aligns the front clip plane with z = 0 Steps for Normalizing View Volume

30 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 25/43 Get the eye to the origin We want a matrix that will take (Pos x, Pos y, Pos z ) to (0, 0, 0) Solution: it’s just the inverse of the translation we found for producing the viewing transform translation (t x, t y, t z ) = (–Pos x, –Pos y, –Pos z ) We will take the matrix: and we will multiply all vertices explicitly (and the camera implicitly) to preserve relationship between camera and scene, i.e., for all vertices p This will move Position to (0, 0, 0) Perspective (1/4)

31 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 26/43 Position now at origin But we’re hardly done! Still need to: align orientation with x,y,z world coordinate system normalize proportions of the view volume The Current Situation Look x z y

32 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 27/43 Rotate the view and align with the world coordinate system We found out that the view transformation matrix M with columns u, v, and n would rotate the x, y, z axes into the u, v, and n axes We now apply inverse (transpose) of that rotation, M T, to scene. That is, a matrix with rows u, v, and n will rotate the axes u, v, and n into the axes x, y, and z Now every vertex in the scene (and the camera implicitly) get multiplied by the composite matrix We’ve translated and rotated, so that the Position is at the origin, and the (u, v, n) coordinates and the (x, y, z) coordinates are aligned Perspective (2/4) current situation

33 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 28/43 We’ve gotten things more or less to right place, but proportions of view volume need to be normalized. Last affine transformation: scaling Adjust so that corners of far clipping plane eventually lie at (+1, +1, –1) One mathematical operation works for both parallel and perspective view volumes Imagine vectors emanating from origin passing through corners of far clipping plane. For perspective view volume, these are edges of volume. For parallel, these lie inside view volume First step: force vectors into 45-degree angles with x and y axes We’ll do this by scaling in x and y Perspective (3/4)

34 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 27/43 current situation Look vector x y x XY Plane ZX Plane

35 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 29/43 Scaling Clipping Planes Looking down from above, we see this: Want to scale in x to make angle 90 degrees Need to scale in x by Similarly in y Perspective (4/4)

36 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 30/43 The scale matrix we need looks like this: So our current composite transformation looks like this: The xy scaling matrix

37 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 31/43 Relative proportions of view volume planes now correct, but back clipping plane probably lying at some z  –1 We need to shrink back plane to be at z = –1 The z distance from eye to that point has not changed: it’s still far (distance to far clipping plane) If we scale in z only, proportions of volume will change; instead we’ll scale uniformly: One more scaling matrix

38 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 32/43 Far plane at z = –1. Near clip plane now at z = –k (note k > 0) The Current Situation x y z

39 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 33/43 Our near-final composite normalizing transformation for the canonical perspective view volume is Exactly the same tricks suffice to get the parallel view volume to the canonical one The Results It is always a good time to review the right hand rule.

40 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 34/43 We’ve put the perspective view volume into canonical position, orientation and size Let’s look at a particular point on the original near clipping plane lying on the Look vector: It gets moved to a location on the negative z-axis, say The Perspective Transformation (1/5) Position Look

41 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 35/43 What is the value of k? Trace through the steps. p first gets moved to just (near)Look This point is then rotated to (near)(–e 3 ) The xy scaling has no effect, and the xyz scaling changes this to, so –but far is –1, so -near/far is simply near The Perspective Transformation (2/5) Look Position p p Look

42 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 36/43 We now transform the points in the standard perspective view volume between –k and –1 into the standard parallel view volume The “z-buffer,” used for visible surface calculation, needs the z values to be [0 1], not [–1 0]. So the perspective transformation must also transform the scene to the range z = 0 to z = 1 The matrix that does this is just (Remember that 0< k <1 …) The Perspective Transformation (3/5) Note: not 1! Flip the z-axis and unhinge

43 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 37/43 Take a typical point and rewrite it as where ; p is parameterized by distance along frustum –when d = 0, p is on near clip plane; when d = (1-k), p is on far clip plane –depending on x, y, and z, p may or may not actually fall within frustum Apply D (from previous slide) to p to get new point p’ Note: must divide through by !!! –this causes x and y to be “perspectivized”, with points closest to near clip plane being scaled up most –understanding homogenous coordinates is essential for correct viewing The Perspective Transformation (4/5) Try values of d: 0, 1-k, ½(1-k), -1, 1

44 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S The Perspective Transformation (5/5) Andries van Dam September 23, 2004 3D Viewing III 38/43 Again consider What happens to x and y when d gets very large? –If d increases beyond (1-k), p is now beyond frustum (such lines will be clipped) This result provides perspective foreshortening: parallel lines converge to a vanishing point What happens when d is negative? –p is now before near clip plane, possibly behind COP –result: when (k+d) becomes negative, sign of x and y is flipped: text would be upside-down and backwards –you won’t see these points because they are clipped What happens after perspective transformation? Answer: parallel projection is applied to determine location of points onto the film plane –projection is easy: drop z! –however, we still need to keep the z ordering intact for visible surface determination

45 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 39/43 Final transformation: Note that once the viewing parameters (Position, Up vector, Look vector, Height angle, Aspect ratio, Near, and Far) are known, the matrices can all be computed and multiplied together to get single 4x4 matrix that is applied to all vertices to get them from “world space” to the standard parallel view volume. Huge win for homogeneous coordinates! The End Result

46 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 40/43 We said that taking picture from canonical view would be easy. Final steps: clipping, projecting onto film plane Need to clip scene against sides of view volume However, we’ve normalized our view volume into an axis-aligned cuboid that extends from –1 to 1 in x and y and from 0 to 1 in z Note: This is the flipped (in z) version of the canonical view volume Clipping is easy! Test x and y components of vertices against +/-1. Test z components against 0 and 1 Clipping Back clip plane transforms to the xy plane here Front clip plane transforms to here (1, -1, 1) (-1, -1, 1) (-1, 1, 0) (1, 1, 1) (-1, -1, 0) (1, 1, 0) (1, -1, 0) (-1, 1, 1) x y z

47 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 41/43 Vertices falling within these values are saved, and vertices falling outside get clipped; edges get clipped by knowing x,y or z value at an intersection plane. Substitute x, y, or z = 1 in the corresponding parametric line equations to solve for t In 2D: Clipping (cont.) (x 0, y 0, z 0 ) (x 1, y 1, z 1 ) t=0 t=1 (1, 1) (-1, -1) x y (x 0, y 0 ) (x 1, y 1 ) x=1

48 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 42/43 We can make a picture by simple strategy of taking each point, “ignoring z” to project it onto the xy-plane A point (x,y,z) where turns into the point (x´, y´) in screen space (assuming viewport is the entire screen) with by - ignoring z - If viewport inside a Window Manager’s window, we need to scale down & translate to produce “window coordinates” Note: because it’s a parallel projection we could have projected onto front plane, back plane, or any intermediate plane … final pixmap would have been same Projection 1. Note that these functions are not exactly correct since if x or y is ever 1, then we will get x’ or y’ to be 1024 which is out of our range, so we need to make sure that we handle these cases gracefully. In most cases, making sure that we get the floor of 512(x+1) will address this problem since the desired x will be less than 1.

49 I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 43/43 In summary, entire problem can be reduced to a composite matrix multiplication of vertices, clipping, and a final matrix multiplication to produce screen coordinates. Final composite matrix (CTM) is composite of all modeling (instance) transformations (CMTM) accumulated during scene graph traversal from root to leaf, composited with final composite normalizing transformation (N) applied to the root/world coordinate system: That’s all there is to it, folks! Summary


Download ppt "I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, 2004 3D Viewing III 3D Viewing III."

Similar presentations


Ads by Google