Title: Introduction to 3D Computer Graphics
1Fac. of Comp., Eng. Tech. Staffordshire
University
3D Computer Graphics
Introduction to 3D Computer Graphics
Dr. Claude C. Chibelushi
2Outline
- Definition
- Applications
- Typical Processing Steps
- Modelling and Rendering
- Typical Data Structures
- Summary
3Definition
3D graphics generally deals with graphical
display of 3D objects as seen by viewer
What is 3D Computer Graphics?
4Definition
- 3D graphics generation of graphical display
(rendering) of 3D object(s) from specification
(model(s))
Modelling
5Applications
- Computer graphics is used in many applications,
e.g. - Entertainment (computer games, movie special
effects, ...) - Human computer interaction (GUI, ...)
- Science, education, medicine (visualisation )
- Business (advertising, e-commerce, ...)
- Art
6Typical Processing Steps
Wireframe polygonal model
Solid object
7Typical Processing Steps
Modelling numerical description of scene
objects, illumination, and viewer
Rendering operations that produce view of scene
projected onto view surface
8Typical Processing Steps
- Loading or generation of object (shape, surface
properties) model - Model coordinate transformation translation,
rotation, projection, ... - Hidden surface removal
- Shading
- Display
9Modelling
1438 facets
Human Head Model
10Modelling
7258 facets
Human Head Model
11Modelling
2074 facets
Teacher and Board Model
12Rendering
Shaded Facets (Human Head)
13Rendering
1438 facets
Shaded Human Head
14Rendering
7258 facets
Shaded Human Head
15Rendering
Shaded Teacher and Board
16Rendering
- Scan conversion
- Rendering requires scan conversion
- Scan conversion of graphics primitive
- point-by- point traversal of primitive
- along (horizontal) scan lines
- coherence often exploited (e.g. incremental
computation) - reduces computational cost
17Rendering
- Scan conversion of filled polygons
Common approach polygon interior filled line by
line, one point at a time
18Rendering
- Scan conversion of filled polygons
- Determines points between pairs of intersections
(scan-line / edges) - Can be complex if no shape constraints
- polygon may be convex and concave
- many possible combinations of interior and
exterior polygon regions
19Rendering
- Scan conversion of filled polygons
- General procedure
- find intersections of scan line with polygon edge
(use equation of line joining two vertices) - edge coherence, hence use incremental computation
- sort intersections left to right
- fill / shade / texture interior points between
intersection pairs along scan line
20Rendering
- Scan conversion of filled polygons
- Generic algorithm requires
- interior / exterior tests
- tests for intersections shared by two edges
- tests for slivers
- edges so close that no or only one discrete point
on scan-line segment - (see Hearn Baker pp. 117 - 126)
21Rendering
- Scan conversion of filled triangles
P1 (x1, y1, z1)
P2 (x2, y2, z2)
P3 (x3, y3, z3)
(1) Sort vertices
(2) Split into two
(3) Fill sub-triangles
22Rendering
- Scan conversion of filled triangles
- scanConv3DTr(P1, P2, P3) / scan conversion of
3D triangle / - sort(P1, P2, P3) // descending y coordinate
(y1 ? y2 ? y3) - if (vertices on single line)
- return
- if (flat top or flat bottom)
- fillFlatTB3DTr(P1, P2, P3)
- else
- yf y2 // subdivide polygon into flat top
/ bottom triangles - // (note also calculate xf, zf as required
interpolation) - fillFlatTB3DTr(P1, P2, Pf) // fill flat bottom
sub-triangle - fillFlatTB3DTr(P2, Pf, P3) // fill flat top
sub-triangle -
23Rendering
- Scan conversion of filled triangles
- fillFlatTB3DTr(Pa, Pb, Pc) / fill 3D triangle
assumes ya? yb ? yc / - if (flat bottom)
- calculate slope of edges PaPb and PaPc
- else
- calculate slope of edges PaPc and PbPc
- identify left and right edge
- for (each scan line between Pa and Pc)
- calculate edge intersections // to reduce
cost, exploit edge coherence - fill from left edge to right edge
-
24Data Structures
- Selection of data structures for computer
graphics often driven by need for efficiency - storage
- computation
- Trade-off between storage and computational
efficiency often applied
25Data Structures
- Data structures are required for
- scene specification
- object, polygon, point / vertex, ...
- mathematical manipulations
- vector, matrix,
- graphical display
- buffer, ...
- Typical data structures trees / scene graphs,
linked lists, arrays
26Data Structures
Linked list of objects
Linked lists of facets
- Computer graphics often use hierarchical data
structures, e.g.
Linked lists of vertices
- Note
- other possible levels object groups, facet
groups (surfaces), edges - vertex may also link back to facets which share
vertex (for shading)
Structures with x, y, z coordinates
27Data Structures
28Data Structures
/ 3D point or vertex with integer coordinates
/ typedef struct structTag3DiPoint
int xCoordinate, / x coordinate /
yCoordinate, / y coordinate /
zCoordinate / z coordinate /
int3DPoint, / 3D point /
pInt3DPoint, / pointer to a 3D point /
int3DVertex, / 3D vertex /
pInt3DVertex / pointer to a 3D vertex /
- Possible structure for 3D point or vertex
29Data Structures
/ Polygon in 3D space / typedef struct
structTag3DiPolygon int3DVertex i3SidedPoly3
int colour, visibilityFlag
float magNormal struct structTag3DiPolygon
link2NextPolygon / Other attributes can go
here / int3DPolygon, / 3D Polygon /
pInt3DPolygon, / pointer to a 3D Polygon /
int3DFacet, / 3D facet /
pInt3DFacet / pointer to a 3D facet /
- Possible structure for polygon
30Data Structures
/ Object in 3D space / typedef struct
structTag3DiObject pInt3DFacet pFacetList
pInt3DVertex pVertexArray int numVertices
int3DPoint worldPosition struct
structTag3DiObject link2NextObject / Other
attributes can go here / int3DObject,
/ 3D Object / pInt3DObject / pointer
to a 3D Object /
- Possible structure for 3D object
31Data Structures
- To cater for synthesis of copies of an object
- master / instance architecture
- master defines generic attributes of object
- instance defines attribute values of particular
copy
32Data Structures
Instances
Masters
tm transf. matrix att attributes
33Suggested Reading
- Preface relevant parts of Ch. 2, A. Watt, 3D
Computer Graphics, 3rd Ed., Addison-Wesley, 2000. - Relevant parts of Ch. 1 2, D. Hearn, M.P.
Baker, Computer Graphics, 2nd Ed. in C,
Prentice-Hall, 1996. - Relevant parts of Ch. 10, 11, 12, A. LaMothe,
Black Art of 3D Game Programming, Waite Group
Press, 1995.
34Suggested Reading
- J. Latta, A Look at the 3D Graphics Industry,
Computer Graphics, Vol. 33, No. 3, pp. 18 - 21,
1999 - C. Machover, Four Decades of Computer Graphics,
IEEE Computer Graphics and Applications, Vol. 14,
No. 6, pp. 14 - 19, 1994 - C. Machover, The Business of Computer Graphics,
IEEE Computer Graphics and Applications, Vol. 20,
No. 1, pp. 44-45, 2000 - N. Leavitt, 3D Technology Ready for the PC?,
IEEE Computer, Vol. 34, No. 11 , pp. 17-20, 2001
35Summary
- 3D graphics
- deals with synthetic (graphical) representation
of 3D information (typically a scene) - most successful application of computer
manipulation of images - Processing pipeline transformations, hidden
surface removal, shading, - Selection of data structures (trees, lists,
arrays, ) - often driven by computational and storage
efficiency
36Summary
- Polygon fill
- common approach line by line, point by point
traversal of polygon interior - requires computation of line intersections, and
sorting - tests for special cases may be required
- triangle can be divided into flat top and flat
bottom triangles - coherence often exploited