Artikel werden geladen

    Introduction to Computer Graphics: Using Java 2D and 3D

    Introduction to Computer Graphics: Using Java 2D and 3D

    Autoren:

    Verlag:
    SPRINGER VERLAG   Weitere Titel dieses Verlages anzeigen

    Erschienen: Januar 2008
    Seiten: 283
    Sprache: Englisch
    Maße: 231x155x18
    Einband: Kartoniert / Broschiert
    ISBN: 1846288479
    EAN: 9781846288470

    Inhaltsverzeichnis

    Contents
    List of Figuresxiii
    1.Introduction1
    1.1Application fields1
    1.2From a real scene to an image3
    1.3Organisation of the book4
    2.Basic principles of two-dimensional graphics7
    2.1Raster versus vector graphics7
    2.2The first Java 2D program10
    2.3Basic geometric objects14
    2.4Basic geometric objects in Java 2D17
    2.5Geometric transformations23
    2.6Homogeneous coordinates28
    2.7Applications of transformations31
    2.8Geometric transformations in Java 2D33
    2.9Animation and movements based on transformations37
    2.10Movements via transformations in Java 2D39
    2.11Interpolators for continuous changes41
    2.12Implementation of interpolators in Java 2D44
    2.13Single or double precision45
    2.14Exercises48
    3.Drawing lines and curves49
    3.1Lines and pixel graphics49
    3.2The midpoint algorithm for lines52
    3.3Structural algorithms60
    3.4Pixel densities and line styles63
      3.4.1Different line styles with Java 2D66
    3.5Line clipping67
    3.6The midpoint algorithm for circles75
    3.7Drawing arbitrary curves79
    3.8Antialiasing80
      3.8.1Antialiasing with Java 2D82
    3.9Drawing thick lines83
      3.9.1Drawing thick lines with Java 2D84
    3.10Exercises86
    4.Areas, text and colours87
    4.1Filling areas87
    4.2Buffered images in Java 2D91
      4.2.1Double buffering in Java 2D92
      4.2.2Loading and saving of images with Java 2D94
      4.2.3Textures in Java 2D95
    4.3Displaying text96
    4.4Text in Java 2D97
    4.5Grey images and intensities99
    4.6Colour models101
      4.6.1Colours in Java 2D106
    4.7Colour interpolation107
    4.8Colour interpolation with Java 2D110
    4.9Exercises112
    5.Basic principles of three-dimensional graphics113
    5.1From a 3D world to a model113
    5.2Geometric transformations115
      5.2.1Java 3D118
      5.2.2Geometric transformations in Java 3D119
    5.3The scenegraph120
    5.4Elementary geometric objects in Java 3D123
    5.5The scenegraph in Java 3D124
    5.6Animation and moving objects130
    5.7Animation in Java 3D133
    5.8Projections139
      5.8.1Projections in Java 3D146
    5.9Exercises147
    6.Modelling three-dimensional objects149
    6.1Three-dimensional objects and their surfaces149
    6.2Topological notions152
    6.3Modelling techniques154
    6.4Surface modelling with polygons in Java 3D159
    6.5Importing geometric objects into Java 3D162
    6.6Parametric curves and freeform surfaces163
      6.6.1Parametric curves164
      6.6.2Efficient computation of polynomials170
      6.6.3Freeform surfaces171
    6.7Normal vectors for surfaces173
      6.7.1Normal vectors in Java 3D176
    6.8Exercises178
    7.Visible surface determination179
    7.1The clipping volume179
      7.1.1Clipping in Java 3D182
    7.2Principles of algorithms for visible surface determination183
      7.2.1Image-precision and object-precision algorithms183
      7.2.2Back-face culling184
      7.2.3Spatial partitioning186
    7.3Image-precision techniques187
      7.3.1The z-buffer algorithm187
      7.3.2Scan line technique for edges190
      7.3.3Ray casting192
    7.4Priority algorithms195
    7.5Exercises199
    8.Illumination and shading201
    8.1Light sources202
    8.2Light sources in Java 3D206
    8.3Reflection208
    8.4Shading in Java 3D216
    8.5Shading218
      8.5.1Constant and Gouraud shading in Java 3D222
    8.6Shadows222
    8.7Transparency224
      8.7.1Transparency in Java 3D226
    8.8Textures227
    8.9Textures in Java 3D229
    8.10The radiosity model231
    8.11Ray tracing236
    8.12Exercises238
    9.Special effects and virtual reality239
    9.1Fog and particle systems240
    9.2Fog in Java 3D242
    9.3Dynamic surfaces243
    9.4Interaction245
    9.5Interaction in Java 3D245
    9.6Collision detection249
    9.7Collision detection in Java 3D250
    9.8Sound effects256
    9.9Sound effects in Java 3D257
    9.10Stereoscopic viewing258
    9.11Exercises263
    Appendix: Useful links265
    Appendix: Example programs267
    Appendix: References to Java 2D classes and methods273
    Appendix: References to Java 3D classes and methods275
    Bibliography277
    Index281



    Vorwort

    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

    Klappentext

    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:

    • Presents computer graphics theory and practice in integrated combination
    • Focuses on the increasingly used Java 3D (and 2D in the first section of the book)
    • Uses many pedagogical tools, including numerous easy-to-understand example programs and end-of-chapter exercises
    • Offers Internet support for students and instructors (found at http://public.rz.fh-wolfenbuettel.de/klawonn/computergraphics), such as additional exercises, solutions, program examples, slides for lecturers and links to useful websites
    • Provides an ideal, self-contained introduction to computer graphics


    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

    Register

    Index


    A

    aliasing 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


    B

    B-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


    C

    CAD, 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


    D

    deferred shading, 216
    depth-buffer algorithm, 187
    difference, 16
    directional light source, 203
    dither matrix, 101
    dot product, 23
    double buffering, 37, 92


    E

    environment mapping, 228, 232


    F

    fog, 240
    - exponential, 240
    - linear, 240 font, 96
    form factor, 233 form parameter, 170

    freeform surface, 164, 171


    G

    geometric transformation (2D), 23
    Gouraud shading, 219
    graphics output primitive, 14


    H

    halftoning, 99
    head-mounted display, 260
    hidden line algorithm, 4

    hidden line elimination, 183
    hidden surface algorithm, 4

    hidden surface elimination, 183
    HLS model, 104
    homogeneous coordinates, 28, 116
    HSV model, 104
    hue, 102


    I

    image-precision algorithm, 183
    intensity, 102
    interior, 153
    interpolation, 165
    interpolator 2D, 41
    intersection, 16


    J

    jaggies, 9

    Java 2D, 10


    K

    kernel, 153
    kerning, 96
    knot, 167


    L

    level 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


    M

    midpoint algorithm
    - for circles, 75
    - for lines, 59
    monocular, 258
    moving pen, 83


    N

    neighbourhood, 153
    NURBS, 169


    O

    object-precision algorithm, 183
    octree, 154
    octree algorithm, 187
    odd parity rule, 87


    P

    parallax
    - 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, 8

    pixel replication, 83
    pixel-oriented graphics, 8

    point, 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


    Q

    quadtree, 155


    R

    radiosity 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, 4

    rendering pipeline, 4
    RGB model, 102
    right-hand rule, 115
    rotation, 25, 117
    roundoff error, 45


    S

    saturation, 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, 9

    stereoscopic viewing, 259
    stretching, 24
    structural algorithm, 60
    supersampling, 194
    swarm behaviour, 241
    sweep representation, 156
    symmetric difference, 16


    T

    tesselation, 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


    U

    union, 16
    unweighted area sampling, 80


    V

    vanishing 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


    W

    Warn model, 204
    Wave format, 257
    Wavefront Object, 162
    weighted area sampling, 81
    wire frame model, 159
    world coordinates, 31


    Y

    YIQ model, 104


    Z

    z-buffer algorithm, 187