Virtual Reality Excursions WITH PROGRAMS IN С Christopher D. Watkins Stephen R. Marenka AP PROFESSIONAL лхял^^ Boston San Diego New York ^fss\0 London Sydney Tokyo Toronto
Contents List of Illustrations Acknowledgments Biographies It's All in the Name Initialization xv xviii xxi xxii xxiii Chapter 1 Virtual Reality Applications 1 Introduction 1 Section 1 Architectural Walkthroughs and Computer-Aided Design 2 Section 2 Augmentation and Decision Support 11 Section 3 Telecommunications and Virtual Interfaces 13 Molecular Studies 14 Teleoperation and Telepresence Remote and Hazardous Workplaces 16 Section 4 Training 18 Section 5 Scientific Research 20 Section 6 Entertainment 22 Section 7 Medical Applications Using Virtual Reality 25 Computer-Aided Designed Treatment 25 Virtual Treatments and Rehabilitation 26 Therapy with Digital Puppets 29 Augmentation 32 Helping the Physician 32 Helping the Handicapped 33 Sign Language 34 v
Virtual Surgery 35 Interfaces 35 Remote Workplaces 37 Training 38 Application Notes 41 Chapter 2 From Whence Virtual Reality A Brief and Incomplete History 43 Introduction 43 Section 1 Classical History 44 In the Oral Tradition, Theater and the Dramatic Arts 44 In the Manner of Records and Writing 47 The Beginning of Electronic Communication 47 Morton Heilig and the Experience Theater 49 Section 2 The Age of Information Technology and the Dawn of Cyberspace 52 ARPA and the ARC 52 Douglas Engelbart and Intelligence Augmentation 54 Sketchpad "The Most Important Program Ever Written" 55 Ivan and the Sword of Damocles 58 ARPAnet and the Internet 60 Xerox PARC 60 Myron Krueger and Responsive Environments 62 MIT's Arch-Mac and the Media Lab 66 The Aspen Movie Map and Surrogate Travel 67 Atari Research 69 NASA Ames Human Factors Research Division 70 Jaron Lanier and VPL 73 Frederick Brooks and UNC Chapel Hill 76 Brooks and Intelligence Amplification 76 Molecular Docking 78 The Architectural Walkthrough 80 Medical Imaging and Three-Dimensional Interactive Graphics 81 More History Related to VR 82 Flight Simulation 83 Evans and Sutherland 85 Military HMDs 86 So What's the History of VR? 87
VIRTUAL REALITY EXCURSIONS vii Chapter 3 From the Point of View 89 Introduction 89 Section 1 Of Sight 90 Section 2 Of Sound 116 Section 3 On Haptics 119 Perception 121 Chapter 4 Virtual Considerations 125 Introduction 125 Section 1 Desktop versus Immersion (What's the View?) 125 The World through a Window 126 Boom-Mounted Displays 127 Immersion in a Room 128 Gloves and Goggles 128 Section 2 Future Possibilities 129 Architectural Walkthroughs and Computer-Aided Design. 129 Augmentation 130 Augmenting the Handicapped 131 Telecommunications 132 Remote and Hazardous Workplaces 133 Computer Interfaces 133 The Metamedium 134 Agents and Animation 134 Training 135 Scientific Exploration 136 Entertainment 136 Section 3 Virtual Reality and Society 137 The Internet (and the Matrix) 138 Virtual Identities 139 Virtual Community 140 NetLaw 141 Section 4 Wireheads Living in a Virtual Environment 142 Living in Virtual Environments 142 VR as the Ultimate Drug 143 Reality Check 143 Section 5 Teledildonics (Cybersex) and Home Entertainment 143
VIM CONTENTS Section 6 Simulator Sickness 144 Section 7 The Contributions of Science Fiction 145 The Classics 145 Cyberpunks 146 Final Considerations 147 Chapter 5 Technical Considerations for Virtual Reality Systems 149 Section 1 The Concept of a Virtual Reality System 149 A Brief, Yet Premature Overview of a VR system 150 Section 2 The Mathematics of Three-dimensional Computer Graphics (Geometry, Matrix Algebra, and Trigonometry) 153 A Discussion on Data Types and Structures 154 General Types 154 Point and Vector Types 155 Polygon Types 156 Three-dimensional Graphics World Types 157 Control Types 157 Basic Mathematics Functions and Macros 158 Comparison Functions and Macros 159 Swapping Functions and Macros 160 Power Functions 160 Pseudo-Random Number Generation Functions 160 Two-dimensional Vector Functions and Macros 161 Three-dimensional Vector Functions and Macros 162 3x3 Matrix Functions for Two-Dimensional Manipulations 164 4x4 Matrix Functions for Three-Dimensional Manipulations 165 How the Functions Work 166 Functions Involving Radians and Degrees 166 The ALG_COSD and ALG_SDSJD Functions 168 The ALG_POWER and ALG_POWER_INT Functions 168 The ALG_LOG Function 168 The ALG_EXP10 Function 169 The ALG_SIGN Function 169 The ALG_MIN, ALG_MIN3, ALG_MIN4, ALG_MAX, ALGJVIAX3, ALG_MAX4 Functions 169 Vector and Matrix Functions 169 The ALG_VEC2_MAKE and ALG_VEC3_MAKE Functions...171 The ALG_VEC2_COMPONENTS and ALG_VEC3_COMPONENTS Functions 171 The ALG_VEC2_AVERAGE and ALG VEC3_AVERAGE Functions 171
VIRTUAL REALITY EXCURSIONS ix The ALG_VEC2_NEGATE and ALG_VEC3_NEGATE Functions 171 The ALG_VEC2_DOT and ALG_VEC3 JX)T Functions 172 The ALG_VEC2_LENGTH and ALG_VEC3_LENGTH Functions 173 The ALG_VEC2_NORMALIZE and ALG_VEC3_NORMALIZE Functions 174 The ALG_VEC2_MINIMUM and ALG_VEC3_MINIMUM Functions 175 The ALG_VEC2_MAXIMUM and ALG_VEC3_MAXIMUM Functions 175 The ALG_VEC2_COMPARE and ALG_VEC3_COMPARE Functions 176 The ALG_VEC2_COPY and ALG_VEC3_COPY Functions 176 The ALG_VEC2_ADD and ALG_VEC3_ADD Functions 176 The ALG_VEC2_SUB and ALG_VEC3_SUB Functions 178 The ALG_VEC2_LIN_COMB and ALG_VEC3_LIN_COMB Functions 178 The ALG_VEC2_SCAL_MULT and ALG_VEC3_SCAL_MULT Functions 178 ALG_VEC3_ADD_SCAL_MULT Functions 179 The ALG_VEC2_MUL and ALG_VEC3_MUL Functions 179 The ALG_VEC2_DETERMINANT Function 180 The ALG_VEC3_CROSS Function 180 The ALG_VEC2JZERO and ALG_VEC3_ZERO Functions 181 Affine Transformation Routines 181 The alg_copy_4x4_matrix Function 182 The alg_multiply_4x4_matrix Function 182 The alg_zero_4x4_matrix Function 183 The alg_identity_4x4_matrix Function 183 The alg_scale_4x4_matrix Function 183 The alg_rotate_4x4_matrix Function 184 The alg_translate_4x4_matrix Function 185 The alg_transform_4x4_matrix Function 186 Pseudo-Random Number Generation 187 The ALG_RAND Function 188 The ALG_RAND_INT Function 188 On to the Program Listings 188 PROGRAM LISTINGS 188 Section 3 Database Hierarchy and Bubba 218 World Order 218 The Features of an Ideal Database Modeler 220 Primitive Support and Manipulation 220 Object Support and Manipulation 221
x CONTENTS Database View Update in Human-Tolerable Time 221 Free Movement through the Database 222 Hiding Gory Details of the Database 222 The Importance of Hierarchy in Database Construction 223 Reuse 223 Flexibility 224 Locality and Extensibility 224 Efficiency 224 A Virtual Reality Modeler 225 Materials Factory 225 Laws of Nature Maker 225 Object Builder 225 World Builder 225 Stimulus/Response Linker 226 Involver 226 Bubba's Database Hierarchy Primitives, Objects, and Worlds 226 Quick Review of Bubba's Graphics Primitives 227 The Polygon Primitive 227 The Rectangular Prism Primitive 227 The Sphere Primitive 227 The Ring Primitive 227 The Cone Primitive 227 Section 4 Filling Polygons and Antialising 228 The Polygon 228 Our Polygon Definitions 229 Color Filling the Convex Polygon 230 Drawing Adjacent Polygons 231 The Polygon Filling Routine 231 Image Quality and Spatial Aliasing 232 Anti-Aliasing 233 Motion Anti-Aliasing 234 Wagon Wheels and Temporal Aliasing 234 Motion Blur 235 Textures and Aliasing 235 Progressive Refinement 235 PROGRAM LISTINGS 236 Section 5 Projecting Polygons 247 Parallel Projection 248 Perspective Projection 249 PROGRAM LISTINGS 251 Section 6 Clipping Polygons 253
VIRTUAL REALITY EXCURSIONS xi The Sutherland-Hodgman Polygon Algorithm used for Z-Clipping 256 The Liang-Barsky Polygon Algorithm used for Screen-Clipping... 258 Viewports, Windows, and Screens 262 PROGRAM LISTINGS 262 Section 7 Removing Hidden Polygons 274 The Backface Removal Algorithm 275 The Z Buffer Algorithm [Catmull 1974] 278 Scan Line Algorithms [Carpenter 1976] 278 The Painter's Algorithm [Newell 1972] 279 Position Comparison Tests for Polygons 279 The Binary Space Partitioning Algorithm [Fuchs 1980] 280 PROGRAM LISTINGS 281 Section 8 Shading and Texturing Polygons 291 A Simple Shading Model 291 Background Illumination (Ka) 293 Diffuse Illumination (Kd) 293 Specular Illumination (Kh) 294 Shadows 296 Reflection and Refraction 297 Texture Mapping and Textures 300 Noise 301 Totally New Waves 301 Bump Mapping 302 Atmospheric Effects 302 Digital Image Warping 303 Bubba, Our Shading and Texturing 305 Section 9 Motion, Interaction, and Simulation 306 The Software 307 Any Simple Damped Motion Simulation 310 Mass-Spring Systems for Simulation 311 Particle Orbit Models for Simulation 316 More on Interaction 320 PROGRAM LISTINGS 321 Section 10 Bringing It All Together to Make the Interactive Visualizer Called Bubba 355 Conceptual Program Flow for the Interactive Visualizer 355 Begin Program 355 The Main Loop 356 After Main Loop 357 PROGRAM LISTINGS 358
Section 11 Stereo Vision and Our Anaglyph Glasses 368 Real 3-D 369 Our Anaglyph Glasses 370 PROGRAM LISTINGS 375 Section 12 Other Rendering Methodologies 384 RAY TRACING 384 Ray Tracing Theory 388 Interactive-Rate Ray Tracing? 391 Radiosity 391 Approximations for Radiosity 392 Advantages of Radiosity 392 THE IDEAL GRAPHICS CARD 393 Features 393 Custom hardware render processor performs 393 Additional features 393 Optional feature modules 394 Performance Specs for a PC 394 Conclusion 394 Modules for a Desktop Virtual Reality Software Development 396 Materials Factory 396 Laws of Nature Maker 396 Object Builder 397 World Builder 397 Stimulus/Response Linker 397 Involver 397 File Converter 397 Remote VR 398 Control VR 398 Immersion VR 398 Closing Comments 398 BOOKS 399 ORGANIZATIONS 400 Appendix A References 401 Network Reference List 401 FTP sites 401 TELNET sites 402 Discussions/Newsgroups 403 Internet 403 America Online 403 The Well 403
VIRTUAL REALITY EXCURSIONS xiii BIX 403 Bulletin Boards 403 Reference List of Companies 404 Appendix В Illustrations 409 Image Credits 409 Color Inserts 410 Gray-Scale Inserts 412 Multimedia Technology Laboratory 419 Overview and Projects 419 Ocular Surgery Simulator 419 Motion Interactive 420 3-D Scanner 421 Graphics, Visualization & Usability Center 421 Overview of the GVU Center 421 Overview of Virtual Environments at the GVU Center 422 Current Projects of the Virtual Environments Group at the GVU Center 423 THE PHOBIA PROJECT 423 THE DESIGN VIRTUAL ENVIRONMENT 423 SVE LIBRARY 424 Other VR Projects at the GVU Center 424 INTERACTIVE CONSTRUCTION VISUALIZER 424 SCIENTIFIC VISUALIZATION IN VIRTUAL ENVIRONMENTS 425 Members of the GVU Center Virtual Environments Group 425 Appendix С Glossary of Terms and People 427 A Complete Virtual Reality Glossary 435 Appendix D The С Language and Our Conventions 453 Introduction 453 The Benefits of С 454 Concepts of a Programming Language 454 Variables and Data Types 456 The Operators 458 Program Control 460
xiv CONTENTS Functions 462 Macros 463 Pointers and Arrays 464 Memory 464 Structures 465 Typedef 466 Input and Output 466 File I/O 467 Programming Style 468 Our Software Conventions 468 References 469 Appendix E Application Software 471 Program Bubba the Interactive 3-D Virtual World Visualizer 471 USING BUBBA THE CONTROLS 471 THE VIEWER 473 THE WORLD 474 VIEWER-OBJECT COLLISIONS 474 OBJECT ORIENTATIONS 475 OBJECT MOTIONS 475 OBJECT SURFACES 476 OBJECT COLORS 476 OBJECT TEXTURES 477 SOME OBJECT DEFINITIONS 478 Programs for the Anaglyph Glasses 483 FLYING 483 VIEWING 3-D SHAPES 483 VIEWING STEREO PAIRS AS A SINGLE IMAGE 484 MISCELLANEOUS 484 Programs Files And Directories 484 \VRBOOK\SOURCE\LIB 484 \VRBOOK\SOURCE\BIN 486 \VRBOOK\SOURCE 487 \VRBOOK\SOURCE\ANA_IMG 488 Appendix F Bibliography 489 VR References 489 Technical References 493 Index 497