Artikel werden geladen
Autoren:
Verlag:
SPRINGER VERLAG Weitere Titel dieses Verlages anzeigen
| Contents | ||||||
| List of Figures | xiii | |||||
| 1. | Introduction | 1 | ||||
| 1.1 | Application fields | 1 | ||||
| 1.2 | From a real scene to an image | 3 | ||||
| 1.3 | Organisation of the book | 4 | ||||
| 2. | Basic principles of two-dimensional graphics | 7 | ||||
| 2.1 | Raster versus vector graphics | 7 | ||||
| 2.2 | The first Java 2D program | 10 | ||||
| 2.3 | Basic geometric objects | 14 | ||||
| 2.4 | Basic geometric objects in Java 2D | 17 | ||||
| 2.5 | Geometric transformations | 23 | ||||
| 2.6 | Homogeneous coordinates | 28 | ||||
| 2.7 | Applications of transformations | 31 | ||||
| 2.8 | Geometric transformations in Java 2D | 33 | ||||
| 2.9 | Animation and movements based on transformations | 37 | ||||
| 2.10 | Movements via transformations in Java 2D | 39 | ||||
| 2.11 | Interpolators for continuous changes | 41 | ||||
| 2.12 | Implementation of interpolators in Java 2D | 44 | ||||
| 2.13 | Single or double precision | 45 | ||||
| 2.14 | Exercises | 48 | ||||
| 3. | Drawing lines and curves | 49 | ||||
| 3.1 | Lines and pixel graphics | 49 | ||||
| 3.2 | The midpoint algorithm for lines | 52 | ||||
| 3.3 | Structural algorithms | 60 | ||||
| 3.4 | Pixel densities and line styles | 63 | ||||
| 3.4.1 | Different line styles with Java 2D | 66 | ||||
| 3.5 | Line clipping | 67 | ||||
| 3.6 | The midpoint algorithm for circles | 75 | ||||
| 3.7 | Drawing arbitrary curves | 79 | ||||
| 3.8 | Antialiasing | 80 | ||||
| 3.8.1 | Antialiasing with Java 2D | 82 | ||||
| 3.9 | Drawing thick lines | 83 | ||||
| 3.9.1 | Drawing thick lines with Java 2D | 84 | ||||
| 3.10 | Exercises | 86 | ||||
| 4. | Areas, text and colours | 87 | ||||
| 4.1 | Filling areas | 87 | ||||
| 4.2 | Buffered images in Java 2D | 91 | ||||
| 4.2.1 | Double buffering in Java 2D | 92 | ||||
| 4.2.2 | Loading and saving of images with Java 2D | 94 | ||||
| 4.2.3 | Textures in Java 2D | 95 | ||||
| 4.3 | Displaying text | 96 | ||||
| 4.4 | Text in Java 2D | 97 | ||||
| 4.5 | Grey images and intensities | 99 | ||||
| 4.6 | Colour models | 101 | ||||
| 4.6.1 | Colours in Java 2D | 106 | ||||
| 4.7 | Colour interpolation | 107 | ||||
| 4.8 | Colour interpolation with Java 2D | 110 | ||||
| 4.9 | Exercises | 112 | ||||
| 5. | Basic principles of three-dimensional graphics | 113 | ||||
| 5.1 | From a 3D world to a model | 113 | ||||
| 5.2 | Geometric transformations | 115 | ||||
| 5.2.1 | Java 3D | 118 | ||||
| 5.2.2 | Geometric transformations in Java 3D | 119 | ||||
| 5.3 | The scenegraph | 120 | ||||
| 5.4 | Elementary geometric objects in Java 3D | 123 | ||||
| 5.5 | The scenegraph in Java 3D | 124 | ||||
| 5.6 | Animation and moving objects | 130 | ||||
| 5.7 | Animation in Java 3D | 133 | ||||
| 5.8 | Projections | 139 | ||||
| 5.8.1 | Projections in Java 3D | 146 | ||||
| 5.9 | Exercises | 147 | ||||
| 6. | Modelling three-dimensional objects | 149 | ||||
| 6.1 | Three-dimensional objects and their surfaces | 149 | ||||
| 6.2 | Topological notions | 152 | ||||
| 6.3 | Modelling techniques | 154 | ||||
| 6.4 | Surface modelling with polygons in Java 3D | 159 | ||||
| 6.5 | Importing geometric objects into Java 3D | 162 | ||||
| 6.6 | Parametric curves and freeform surfaces | 163 | ||||
| 6.6.1 | Parametric curves | 164 | ||||
| 6.6.2 | Efficient computation of polynomials | 170 | ||||
| 6.6.3 | Freeform surfaces | 171 | ||||
| 6.7 | Normal vectors for surfaces | 173 | ||||
| 6.7.1 | Normal vectors in Java 3D | 176 | ||||
| 6.8 | Exercises | 178 | ||||
| 7. | Visible surface determination | 179 | ||||
| 7.1 | The clipping volume | 179 | ||||
| 7.1.1 | Clipping in Java 3D | 182 | ||||
| 7.2 | Principles of algorithms for visible surface determination | 183 | ||||
| 7.2.1 | Image-precision and object-precision algorithms | 183 | ||||
| 7.2.2 | Back-face culling | 184 | ||||
| 7.2.3 | Spatial partitioning | 186 | ||||
| 7.3 | Image-precision techniques | 187 | ||||
| 7.3.1 | The z-buffer algorithm | 187 | ||||
| 7.3.2 | Scan line technique for edges | 190 | ||||
| 7.3.3 | Ray casting | 192 | ||||
| 7.4 | Priority algorithms | 195 | ||||
| 7.5 | Exercises | 199 | ||||
| 8. | Illumination and shading | 201 | ||||
| 8.1 | Light sources | 202 | ||||
| 8.2 | Light sources in Java 3D | 206 | ||||
| 8.3 | Reflection | 208 | ||||
| 8.4 | Shading in Java 3D | 216 | ||||
| 8.5 | Shading | 218 | ||||
| 8.5.1 | Constant and Gouraud shading in Java 3D | 222 | ||||
| 8.6 | Shadows | 222 | ||||
| 8.7 | Transparency | 224 | ||||
| 8.7.1 | Transparency in Java 3D | 226 | ||||
| 8.8 | Textures | 227 | ||||
| 8.9 | Textures in Java 3D | 229 | ||||
| 8.10 | The radiosity model | 231 | ||||
| 8.11 | Ray tracing | 236 | ||||
| 8.12 | Exercises | 238 | ||||
| 9. | Special effects and virtual reality | 239 | ||||
| 9.1 | Fog and particle systems | 240 | ||||
| 9.2 | Fog in Java 3D | 242 | ||||
| 9.3 | Dynamic surfaces | 243 | ||||
| 9.4 | Interaction | 245 | ||||
| 9.5 | Interaction in Java 3D | 245 | ||||
| 9.6 | Collision detection | 249 | ||||
| 9.7 | Collision detection in Java 3D | 250 | ||||
| 9.8 | Sound effects | 256 | ||||
| 9.9 | Sound effects in Java 3D | 257 | ||||
| 9.10 | Stereoscopic viewing | 258 | ||||
| 9.11 | Exercises | 263 | ||||
| Appendix: Useful links | 265 | |||||
| Appendix: Example programs | 267 | |||||
| Appendix: References to Java 2D classes and methods | 273 | |||||
| Appendix: References to Java 3D classes and methods | 275 | |||||
| Bibliography | 277 | |||||
| Index | 281 | |||||
Preface
Early computer graphics started as a research and application field that was the domain of only a few experts, for instance in the area of computer aided design (CAD). Nowadays, any person using a personal computer benefits from the developments in computer graphics. Operating systems and application programs with graphical user interfaces (GUIs) belong to the simplest applications of computer graphics. Visualisation techniques, ranging from simple histograms to dynamic 3D animations showing changes of winds or currents over time, use computer graphics in the same manner as popular computer games. Even those who do not use a personal computer might see the results of computer graphics on TV or in cinemas where parts of scenes or even a whole movie might be produced by computer graphics techniques.
Without powerful hardware in the form of fast processors, sufficiently large memory and special graphics cards, most of these applications would not have been possible. In addition to these hardware requirements efficient algorithms as well as programming tools that are easy to use and flexible at the time are required. Nowadays, a standard personal computer is sufficient to generate impressive graphics and animations using freely available programming platforms like Open-GL or Java 3D. In addition to at least an elementary understanding of programming, the use of such platforms also requires basic knowledge about the underlying background, concepts and methods of computer graphics.
Aims of the book
The aim of this book is to explain the necessary background and principles of computer graphics combined with direct applications in concrete and simple examples. Coupling the theory with the practical examples enables the reader to apply the technical concepts directly and to visually understand what they mean.
Java 2D and Java 3D build the basis for the practical examples. Wherever possible, the introduced concepts and theory of computer graphics are immediately followed by their counterparts in Java 2D and Java 3D. However, the intention of this book is not to provide a complete introduction to Java 2D or Java 3D, which would both need a multivolume edition themselves without even touching the underlying theoretical concepts of computer graphics.
In order to directly apply computer graphics concepts introduced in this book, the book focusses on the parts of Java 2D and Java 3D that are absolutely relevant for these concepts. Sometimes a simple solution is preferred over the most general one so that not all possible options and additional parameters for an implementation will be discussed. The example programs are kept as simple as possible in order to concentrate on the important concepts and not to disguise them in complex, but more impressive scenes.
There are some selected additional topics-for instance the computation of shadows within computer graphics-that are introduced in the book, although Java 3D does not provide such techniques yet.
Why Java?
There are various reasons for using Java 2D and Java 3D as application platforms. The programming language Java becomes more and more popular in applications and teaching so that extensions like Java 2D/3D seem to be the most obvious choice. Many universities use Java as the introductory programming language, not only in computer science, but also in other areas so that students with a basic knowledge in Java can immediately start to work with Java 2D/3D. Specifically, for multimedia applications Java is very often the language of first choice.
Overview
The first chapters of the book focus on aspects of two-dimensional computer graphics like how to create and draw lines, curves and geometric shapes, handling of colours and techniques for animated graphics.
Chapter 5 and all following chapters cover topics of three-dimensional computer graphics. This includes modelling of 3D objects and scenes, producing images from virtual 3D scenes, animation, interaction, illumination and shading. The last chapter introduces selected special topics, for example special effects like fog, sound effects and stereoscopic viewing.
Guidelines for the reader
In order to be able to apply the computer graphics concepts introduced in this book, the reader will need only very elementary knowledge of the programming language Java. The example programs in this book use Java 3D but also Java 2D in the first chapters, since two-dimensional representations are essential for computer graphics and the geometrical concepts are easier to understand in two dimensions than in three. The necessary background of Java 2D and Java 3D is included as application sections in this book.
Although the coupling of theory and practice was a main guideline for writing this book, the book can also be used as an introduction to the general concepts of computer graphics without focussing on specific platforms or learning how to use Java 2D or Java 3D. Skipping all sections and subsections containing the word "Java" in their headlines, the book will remain completely self-contained in the sense of a more theoretical basic introduction to computer graphics. For some of the computer graphics concepts introduced in this book it is assumed that the reader has basic knowledge about vectors, matrices and elementary calculus.
Supplemental resources
Including the complete source code of all mentioned example programs would have led to a thicker, but less readable book. In addition, no one would like to take the burden of typing the source code again in order to run the examples. Therefore, the book itself only contains those relevant excerpts of the source code that are referred to in the text. The complete source code of all example programs and additional programs can be downloaded from the book web site at http://public.rz.fh-wolfenbuettel.de/~klawonn/computergraphics. This online service also provides additional exercises concerning the theoretical background as well programming tasks including sketches of solutions, teaching material in the form of slides and some files that are needed for the example programs. The links mentioned in the appendix and further links to some interesting web sites can also be found at the online service of this book.
Acknowledgements
Over the years, the questions, remarks and proposals of my students had a great influence on how this book was written. I cannot list all of them by name, but I would like to mention at least Daniel Beier, Thomas Weber, Jana Volkmer and especially Dave Bahr for reading the manuscript and their extremely helpful comments. I also would like to thank Katharina Tschumitschew and Gerry Gehrmann for designing the online service of the book and for some 3D models that I could use in my programs. The book was first published in German and without the encouragement and support of Catherine Brett from Springer Verlag in London this English version would have been impossible. Thanks also to Frank Ganz from Springer, who seems to know everything about LATEX. My very personal thanks go to my parents and my wife Keiko for their love and for always accepting my sometimes extremely heavy overload of work.
Wolfenbüttel, September 2007
Frank Klawonn
UNDERGRADUATE TOPICS in COMPUTER SCIENCE
Undergraduate Topics in Computer Science (UTiCS) delivers highquality instructional content for undergraduates studying in ail areas of computing and information science. From core foundational and theoretical material to final-year topics and applications, UTiCS books take a fresh, concise, and modern approach and are ideal for self-study or for a one or two-semester course. The texts are all authored by established experts in their fields, reviewed by an international advisory board, and contain numerous examples and problems. Many include fully worked solutions.
Frank Klawonn
Introduction to Computer Graphics
Using Java 2D and 3D
Computer graphics comprises the creation and representation of simple graphical elements and images, as well as modern techniques for rendering a virtual reality. To apply these techniques correctly, one requires a basic understanding of the fundamental concepts in graphics.
This book introduces the most important basic concepts of computer graphics, coupling the technical background and theory with practical examples and applications throughout. Its userfriendly approach enables the reader to gain understanding through the theory at work, via the many example programs provided. With only elementary knowledge of the programming language Java, the reader will be able to create their own images and animations immediately, using Java 2D and/or Java 3D.
Features:
Written for second year undergraduates and above, this readerfriendly, clear and concise textbook will be an essential tool for those studying Computer Science and Computer Engineering.
ISBN 978-1-84628-847-0
springer.com
Index
Aaliasing effect, 8
alpha-blending, 225
ambient light, 202
anaglyph image, 260
anchor, 90
Animation, 130
antialiasing, 80
API, 10
Application Programming Interface, 10
approximation, 165
area, 14
area subdivision algorithm, 187
attenuation, 203
atmospheric, 203
Audio format, 257
augmented reality, 3
BB-spline, 167
back-face culling, 184
Bernstein polynomial, 166
Bezier curve, 166
Bezier point, 166
- inner, 167
Bezier surface, 172
binocular, 258
bitmask, 64
boundary, 153
boundary point, 153
Bresenham algorithm
- for circles, 75
- for lines, 59
Brons' algorithm, 62
bump mapping, 228
CCAD, 2
CAM, 2
centre of projection, 139
CIEXYZ model, 103
clipping, 4, 67- 2D- 4
- 3D- 4
- three-dimensional, 179
clipping area, 67
clipping plane
- back, 181
- front, 181
clipping region, 67
clipping volume, 179, 180
closure, 153
CMY model, 103
CMYK model, 103
CNS model, 106
Cohen-Sutherland line clipping, 70
coherence, 194
collision detection, 249
colour model
- additive, 102
- perception-oriented, 106
- subtractive, 102
constructive solid geometry, 156
control point, 15, 164
controllability, 164
convex, 14
convex combination, 41
coordinate system
- right-handed, 115
CSG, 156
curve, 14
Cyrus-Beck line clipping, 72
Ddeferred shading, 216
depth-buffer algorithm, 187
difference, 16
directional light source, 203
dither matrix, 101
dot product, 23
double buffering, 37, 92
Eenvironment mapping, 228, 232
Ffog, 240
- exponential, 240
- linear, 240 font, 96
form factor, 233 form parameter, 170freeform surface, 164, 171
Ggeometric transformation (2D), 23
Gouraud shading, 219
graphics output primitive, 14
Hhalftoning, 99
head-mounted display, 260
hidden line algorithm, 4hidden line elimination, 183
hidden surface algorithm, 4hidden surface elimination, 183
HLS model, 104
homogeneous coordinates, 28, 116
HSV model, 104
hue, 102
Iimage-precision algorithm, 183
intensity, 102
interior, 153
interpolation, 165
interpolator 2D, 41
intersection, 16
Jjaggies, 9
Java 2D, 10
Kkernel, 153
kerning, 96
knot, 167
Llevel of detail, 159
ligature, 96
light ambient, 202
light map, 228, 236
light source
- directional, 203
- point, 203
lightness, 102
line, 14
line clipping, 68
line style, 64
Linienbreite, 83
liquid crystal shutter glasses, 260
locality principle, 164
LOD, 159
Mmidpoint algorithm
- for circles, 75
- for lines, 59
monocular, 258
moving pen, 83
Nneighbourhood, 153
NURBS, 169
Oobject-precision algorithm, 183
octree, 154
octree algorithm, 187
odd parity rule, 87
Pparallax
- divergent, 262
- negative, 262
positive, 262
particle system, 241
perspective projection
- one-point, 145
- three-point, 145
- two-point, 145
Phong illumination model, 214
Phong shading, 220
pixel graphics, 8pixel replication, 83
pixel-oriented graphics, 8point, 14, 23
- inner, 153
point light source, 203
polarisation, 260
polygon, 14
polyline, 14
primitive, 14
priority algorithm, 195
progressive refinement approach, 235
projection, 139
parallel, 140
perspective, 139
projection plane, 139
projector, 139
proportional font, 96
Qquadtree, 155
Rradiosity model, 232
raster graphics, 8
raster-oriented graphics, 8
ray casting, 192
ray tracing, 237
recursive ray tracing, 237
recursive subdivision algorithm, 187
reflection
- diffuse, 210
- specular, 211
reflection mapping, 228
regularisation, 152, 153
rendering, 4rendering pipeline, 4
RGB model, 102
right-hand rule, 115
rotation, 25, 117
roundoff error, 45
Ssaturation, 102
scaling, 24, 116
scan conversion, 8
scan line technique, 88, 190
scenegraph, 121
screen-door transparency, 226
set
- closed, 153
- open, 153
- regular, 153
Shading, 202
shading, 210
- constant, 218
- flat, 218
- interpolated, 219
shadow, 222
shear transformation, 25
shrinking, 24
skeleton, 244
smoothing operator, 107
smoothness-Glattheit, 165
spatial partitioning, 186
specular reflection coefficient, 214
specular reflection exponent, 214
spotlight, 204
staircasing, 9stereoscopic viewing, 259
stretching, 24
structural algorithm, 60
supersampling, 194
swarm behaviour, 241
sweep representation, 156
symmetric difference, 16
Ttesselation, 150
texel, 228
texture, 90, 227
texture map, 227
transformation group, 121, 122
transformation matrix, 29
translation, 26, 116
translucent, 224
transmission coefficient, 224
transparency, 224
- filtered, 224
- interpolated, 224
triangulation, 108
two-pass z-buffer algorithm, 223
two-pass depth buffer algorithm, 223
Uunion, 16
unweighted area sampling, 80
Vvanishing point, 144
vector, 23
vector graphics, 7
vector-oriented graphics, 7
view platform, 124
viewport, 31
virtual reality, 3, 239
visible line determination, 183
visible surface determination, 183
volume- bounding, 249
voxel, 154
WWarn model, 204
Wave format, 257
Wavefront Object, 162
weighted area sampling, 81
wire frame model, 159
world coordinates, 31
YYIQ model, 104
Zz-buffer algorithm, 187