CH4 - 3D Graphics
CH4 - 3D Graphics
CH5: 3D Graphics
1
Outline
• 3D Geometry
• Representation of 3D Objects
• 3D Transformations
• 3D Display Methods
• Projections
• Parallel Projection
• Perspective Projection
2
3D Geometry - 3D co-ordinate systems
• A point in 3D space can be referenced relative to RHS or LHS Cartesian coordinate system using
three coordinate values.
• RHS -right-handedness is defined as any positive axis (x, y, or z) pointing toward the viewer. or
LHS Cartesian coordinate system- Left-handedness is defined as any positive axis (x, y, or z)
pointing away from the viewer.
• This can be represented as a matrix, (or as a matrix for homogenous transformations).
• We will normally be working with an RHS system.
• The transformation can be used to transform from a right-handed 3D Cartesian coordinate system to a
left-handed one and vice-versa.
3
Representation of 3D objects
• One way of representing a 3D object is as a list of 2D polygons in 3D
space.
• For example, a pyramid consists of a square base and four triangles.
• Curved surfaces may be approximated using polygons, although there are
techniques which represent curved surfaces more accurately, including
generalizations of Bezier and Spline curves.
• If 3D objects are represented as lists of edges (as opposed to polygons), then this
allows rendering of ‘see-through’ wireframe images.
• However, hidden-line removal for more realistic images is not possible because
this requires knowledge of the surfaces of the object.
4
wireframe images
Hidden line removal (HLR) is the method of computing which edges are not hidden by the faces of parts
for a specified view and the display of parts in the projection of a model into a 2D plane. Hidden line
removal is utilized by a CAD to display the visual lines
5
3D Transformations
• 3D transformations are just an extension of 2D ones.
• Just like 2D transformations are represented by matrices, 3D transformations
are represented by matrices.
Translation:
• Translation by is represented by the matrix:
Scaling:
• Scaling by the factors and , along the co-ordinate axes is given by the matrix:
6
3D Transformations
Rotation:
7
3D Display Methods – The 3D viewing
pipeline
• 3D viewing is more complex than 2D viewing because, while the world
coordinate systems is three dimensional, the device on which they are
displayed is usually two dimensional.
• This requires an additional transformation, namely the projection
transformation, in the viewing pipeline, whereby 3D coordinates are
transformed into 2D.
• The basic steps involved in 3D viewing are:
1. Transforming world coordinates into viewing coordinates;
2. Transforming viewing coordinates into projection coordinates (the projection
transformation);
3. Transforming projection coordinates into device coordinates.
8
3D Display Methods – The 3D viewing
pipeline
• The first step effectively defines a position and orientation for a virtual
camera, whereas the second step determines the kind of picture to be
taken.
• Note that whereas clipping in 2D is carried out before applying the
viewing pipeline, in 3D it is often delayed to just before the third step.
• This is because in 3D, clipping has to be performed against a view volume which
may be of an awkward shape e.g. a frustrum in the initial stages.
• After carrying out the projection transformation, the view volume is a
regular parallelepiped which is much easier to clip against.
9
3D Display Methods – The 3D viewing
pipeline
The view reference coordinate system
• The viewing-reference coordinate system () is
defined in terms of
• a view reference point () which represents the origin,
• a view-plane normal vector () and
• a view-up vector ().
• This is analogous to placing a camera (or an eye)
at the pointing in the direction given by the .
• The camera is then rotated around the
perpendicular to the plane that passes through it
(the camera) so that the is vertical.
10
3D Display Methods – The 3D viewing
pipeline
The view reference coordinate system
• The coordinate system is set up so that lies in the direction of the , and is in the
direction of the vector which is in the same plane of the and , is perpendicular to the
and makes an acute angle with the .
• is chosen so that is right-handed.
• The orthogonal unit vectors , and corresponding to the can be constructed as follows:
11
3D Display Methods – The 3D viewing
pipeline
The view reference coordinate system
• Transforming from world coordinates to viewing coordinates can be
achieved by first translating by and then aligning the coordinate axes by
rotation.
• Thus if is a point with world coordinates , its viewing coordinates can
be obtained using:
where
12
3D Display Methods – The 3D viewing
pipeline
The view reference coordinate system
• Aligning a viewing system with the world-coordinate axes using a
sequence of translate-rotate transformations:
13
3D Display Methods – The 3D viewing
pipeline
The view reference coordinate system
• General three-dimensional transformation pipeline, from modeling
coordinates to final device coordinate is:
14
Projections
• In general, a projection is a transformation from an n dimensional space to
an m dimensional space, where .
• We concentrate on projections from a 3D Cartesian coordinate system to a 2D one.
• Consider a set of points in viewing coordinates.
• To carry out a projection, a line (called a projector) is drawn from each
point to a fixed point called the center of projection (COP).
• The projectors intersect the view plane (which is perpendicular to ) at the points .
• Projections that can be represented as
15
Projections
• The following parameters must be supplied to fully describe a
projection:
• a window in the view plane that defines the boundaries of the picture to be
taken—this is specified in VRC coordinates and is usually, though not necessarily,
taken to be a rectangle with the VRP at the center;
• a COP towards which all projectors converge;
• front and back clipping planes:
• the front and back clipping planes define cut-off points beyond which graphic objects are
not considered for projection, effectively eliminating objects which are too close to (or
behind) the camera, or too far away from it.
16
Projections
• The position of the COP may tend to infinity; in such cases the projectors are parallel
to each other and their direction is referred to as the direction of projection.
17
Projections
• Parallel projections preserve all parallel lines as well as the angles in any plane parallel
to the plane of projection.
• Perspective projections preserve parallel lines and angles only in the planes parallel to
the plane of projection.
• However, scenes produced using a perspective
projection appear realistic because distant objects
appear smaller than near ones.
• In a scene produced by parallel projection, distant
objects have the same size as near ones.
• Perspective projections of parallel lines are either
parallel lines themselves (if they are parallel to
the view plane) or intersect at a vanishing point.
18
Parallel Projections
Orthographic projections
• If the projectors are perpendicular to the plane of projection, the
resulting parallel projection is called orthographic, otherwise it is called
oblique.
Orthographic projections
• A useful set of views produced by orthographic projections are the front
elevation, side elevation and plan view of an object.
• Such views are produced when the plane of projection is parallel to one of the
planes defined by any two principal axes of the world coordinate system, or
equivalently, the plane of projection intersects with only one world coordinate
principal axis.
19
Parallel Projections
Orthographic projections
• The front elevation of orthographic parallel projection can be
represented by the following transformation:
or by the matrix:
20
Parallel Projections
Orthographic projections
• If the projection is orthographic and the plane of projection intersects
with more than one world coordinate axis, then the resulting view is
termed axonometric.
• One useful axonometric projection is the isometric projection, which is produced
when the projection plane intersects each principal axis at the same distance
from the origin.
• The projected edges of an isometric view of a cube aligned along the world co-
ordinate axes have equal length.
21
Parallel Projections
Oblique projections
• Oblique parallel projections are produced when the projectors are not
perpendicular to the plane of projection.
• The direction of projection (DOP) may be
given by two angles: and .
• is defined as the angle each projector makes
with the plane of projection, and
• as the angle the horizontal makes with the
line that joins the projection with the
corresponding orthographic projection.
• is usually chosen to be 30◦ or 45◦.
22
Parallel Projections
Parallel projection transformation
• Consider the point with view coordinates projected to the point with
coordinates .
• Let be the orthographic projection of on the plane, and be the length of line .
• Then and the coordinates of are:
23
Parallel Projections
Parallel projection transformation
• In the case of an orthographic projection, we have and , giving us the
transformation:
25
Perspective Projections
• Multiplying by a value dependent on causes the size of objects to vary
depending on their distance from the origin.
• Note that a value , will cause problems as the projected point will be at infinity
i.e. objects are infinitely large at the view plane.
• Normally we will clip points for which .
• We can write the transformation in matrix form:
• This gives us the coordinate , which when homogenized gives us the point . 26
Mapping into a 2D Viewport
• Having constructed a normalized view volume in the shape of a regular
parallelepiped, a 2D image can be constructed by projecting the volume
orthographically.
• In the process of doing this, various other operations may be carried
out:
• Invisible edges and surfaces may be eliminated, and coloring and shading
algorithms may be applied to produce a more realistic image.
• Techniques for rendering are applied on the final image.
27
End of CH5!!!
• Thank You!!!
28
Chapter 6- Computer Animation
29
Computer Animation
1. Raster Methods for Computer Animation
2. Design of Animation Sequences
3. Traditional Animation Techniques
4. Computer-Animation Languages
5. OpenGL Animation Procedures
30
Computer Animation
• Computer-graphics methods are now commonly used to produce
animations for a variety of applications, including entertainment
(motion pictures and cartoons), advertising, scientific and
engineering studies, and training and education.
31
Computer Animation
• Two basic methods for constructing a motion sequence are real-time
animation and frame-by-frame animation.
33
Raster Methods for Computer Animation
• Most of the time, we can create simple animation sequences in our programs
using real-time methods.
• The animation can then be viewed by cycling through the completed frame
sequence, or the frames could be transferred to film.
34
Raster Methods for Computer Animation
• If we want to generate an animation in real time, however, we need
to produce the motion frames quickly enough so that a continuous
motion sequence is displayed.
• For a complex scene, one frame of the animation could take most of
the refresh cycle time to construct.
35
Raster Methods for Computer Animation
• For very complex animations, the frame construction time could be
greater than the time to refresh the screen, which can lead to erratic
motion and fractured frame displays.
36
Double Buffering
• One method for producing a real-time animation with a raster
system is to employ two refresh buffers.
• When that frame is complete, we switch the roles of the two buffers
so that the refresh routines use the second buffer during the
process of creating the next frame in the first buffer.
37
Double Buffering
• This alternating buffer process continues throughout the animation.
• Graphics libraries that permit such operations typically have one function
for activating the double buffering routines and another function for
interchanging the roles of the two buffers.
• For example, if the screen refresh rate is 60 frames per second and it
takes of a second to construct an animation frame, each frame is
displayed on the screen twice and the animation rate is only 30
frames each second.
40
Double Buffering
• Because of slight variations in the implementation time for the
routines that generate the primitives and their attributes, some frames
could take a little more time to construct and some a little less time.
• Thus, the animation frame rate can change abruptly and erratically.
• One way to compensate for this effect is to add a small time delay to
the program.
42
Operations
• Sequences of raster operations can be executed to produce realtime
animation for either two-dimensional or three-dimensional objects.
• We can also animate objects along two-dimensional motion paths
using colortable transformations.
• Here we predefine the object at successive positions along the
motion path and set the successive blocks of pixel values to color-
table entries.
• The pixels at the first position of the object are set to a foreground
color, and the pixels at the other object positions are set to the
background color.
43
Operations
• The animation is then accomplished by changing the color-table
values so that the object color at successive positions along the
animation path becomes the foreground color as the preceding
position is set to the background color (Figure 1).
44
Design of Animation Sequences
• Constructing an animation sequence can be a complicated task,
particularly when it involves a story line and multiple objects, each
of which can move in a different way.
45
Design of Animation Sequences
• The storyboard is an outline of the action. It defines the motion
sequence as a set of basic events that are to take place.
47
Design of Animation Sequences
• A key frame is a detailed drawing of the scene at a certain time in the
animation sequence.
• Within each key frame, each object (or character) is positioned according to the
time for that frame.
• Some key frames are chosen at extreme positions in the action; others are
spaced so that the time interval between key frames is not too great.
• More key frames are specified for intricate motions than for simple, slowly
varying motions.
• Development of the key frames is generally the responsibility of the senior
animators, and often a separate animator is assigned to each character in the
animation.
48
Design of Animation Sequences
• In-betweens are the intermediate frames between the key frames.
• The total number of frames, and hence the total number of in-betweens,
needed for an animation is determined by the display media that is to be used.
• Film requires 24 frames per second, and graphics terminals are refreshed at the
rate of 60 or more frames per second.
• Typically, time intervals for the motion are set up so that there are from three
to five in-betweens for each pair of key frames.
• Depending on the speed specified for the motion, some key frames could be
duplicated.
• As an example, a 1-minute film sequence with no duplication requires a total of
1,440 frames. If five in-betweens are required for each pair of key frames, then
288 key frames would need to be developed.
49
Design of Animation Sequences
• There are several other tasks that may be required, depending on
the application.
50
Traditional Animation Techniques
51
Computer-Animation Languages
• We can develop routines to design and control animation sequences
within a general-purpose programming language, such as C, C++,
Lisp, or Fortran, but several specialized animation languages have
been developed.
53