IRIS Performer™ Programmer's Guide
Total Page:16
File Type:pdf, Size:1020Kb
IRIS Performer™ Programmer’s Guide Document Number 007-1680-030 CONTRIBUTORS Edited by Steven Hiatt Illustrated by Dany Galgani Production by Derrald Vogt Engineering contributions by Sharon Clay, Brad Grantham, Don Hatch, Jim Helman, Michael Jones, Martin McDonald, John Rohlf, Allan Schaffer, Chris Tanner, and Jenny Zhao © Copyright 1995, Silicon Graphics, Inc.— All Rights Reserved This document contains proprietary and confidential information of Silicon Graphics, Inc. The contents of this document may not be disclosed to third parties, copied, or duplicated in any form, in whole or in part, without the prior written permission of Silicon Graphics, Inc. RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure of the technical data contained in this document by the Government is subject to restrictions as set forth in subdivision (c) (1) (ii) of the Rights in Technical Data and Computer Software clause at DFARS 52.227-7013 and/ or in similar or successor clauses in the FAR, or in the DOD or NASA FAR Supplement. Unpublished rights reserved under the Copyright Laws of the United States. Contractor/manufacturer is Silicon Graphics, Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. Indigo, IRIS, OpenGL, Silicon Graphics, and the Silicon Graphics logo are registered trademarks and Crimson, Elan Graphics, Geometry Pipeline, ImageVision Library, Indigo Elan, Indigo2, Indy, IRIS GL, IRIS Graphics Library, IRIS Indigo, IRIS InSight, IRIS Inventor, IRIS Performer, IRIX, Onyx, Personal IRIS, Power Series, RealityEngine, RealityEngine2, and Showcase are trademarks of Silicon Graphics, Inc. AutoCAD is a registered trademark of Autodesk, Inc. X Window System is a trademark of Massachusetts Institute of Technology. IRIS Performer™ Programmer’s Guide Document Number 007-1680-030 Contents Examples xv Figures xix Tables xxi About This Guide xxv Why Use IRIS Performer? xxv What You Should Know Before Reading This Guide xxvi How to Use This Guide xxvi What This Guide Contains xxvii Conventions xxviii Bibliography xxix Computer Graphics xxix The IRIS GL and OpenGL Graphics Libraries xxx X, Xt, IRIS IM, and Window Systems xxxi Visual Simulation xxxii Mathematics of Flight Simulation xxxii Virtual Reality xxxiii Geometric Reasoning xxxiii Conference Proceedings xxxiii Survey Articles in Magazines xxxiv Internet Resources xxxv iii Contents 1. Getting Acquainted With IRIS Performer 3 Exploring the IRIS Performer Sample Scenes 3 Installing the Software 3 Exploring Code 9 Going Beyond Visual Simulation 10 Deciding Where to Start 10 2. IRIS Performer Basics 13 What Is IRIS Performer? 13 Applications 16 Features 16 Survey of Visual Simulation Techniques 19 Low-Latency Image Generation 21 Consistent Frame Rates 22 Rich Scene Content 23 Texture Mapping 25 Character Animation 26 Database Construction 28 Overview of the IRIS Performer Libraries 29 The libpf Visual Simulation Library 29 The libpr High-Performance Rendering Library 32 The libpfdu Geometry Builder Library 36 The libpfdb Loader Library 37 Database Formats and IRIS Performer 38 Graphics Libraries 40 OpenGL 40 Porting From IRIS GL to OpenGL 40 The pfWindow Windowing Functions 41 X and IRIS IM 41 iv pfObjects and the Class Hierarchy 42 Inheritance Graph 43 User Data 45 pfDelete() and Reference Counting 46 Copying Objects with pfCopy() 49 Determining Object Type 50 3. Building a Visual Simulation Application 55 Overview 55 Setting Up the Basic Elements 61 Using IRIS Performer Header Files 61 Initializing and Configuring IRIS Performer 62 Setting Up a Pipe 63 Frame Rate and Synchronization 63 Setting Up a Channel 64 Creating and Loading a Scene Graph 64 Simulation Loop 65 Performance 66 Compiling and Linking IRIS Performer Applications 67 4. Setting Up the Display Environment 73 Using Pipes 73 The Functional Stages of a Pipeline 73 Creating and Configuring a pfPipe 75 Example of pfPipe Use 77 Using pfPipeWindows 79 Creating, Configuring and Opening pfPipeWindow 79 pfPipeWindows in Action 90 v Contents Using Channels 92 Creating and Configuring a pfChannel 92 Setting Up a Scene 92 Setting Up a Viewport 93 Setting Up a Viewing Frustum 93 Setting Up a Viewpoint 95 Example of Channel Use 98 Using Multiple Channels 100 Using Channel Groups 105 5. Nodes and Node Types 111 Nodes 112 Attribute Inheritance 112 pfNode 115 pfGroup 117 Working With Nodes 120 Instancing 120 Bounding Volumes 123 Node Types 125 pfScene Nodes 125 pfSCS Nodes 126 pfDCS Nodes 126 pfSwitch Nodes 127 pfSequence Nodes 128 pfLOD Nodes 130 pfLayer Nodes 131 pfLightPoint Nodes 132 pfLightSource Nodes 133 pfGeode Nodes 137 pfText Nodes 138 pfBillboard Nodes 140 pfPartition Nodes 144 Sample Program 146 vi 6. Database Traversal 153 Scene Graph Hierarchy 155 Database Traversals 155 State Inheritance 156 Database Organization 156 Application Traversal 157 Cull Traversal 158 Traversal Order 159 Visibility Culling 159 Organizing a Database for Efficient Culling 163 Sorting the Scene 166 Paths Through the Scene Graph 168 Draw Traversal 169 Controlling and Customizing Traversals 169 pfChannel Traversal Modes 169 pfNode Draw Mask 170 pfNode Cull and Draw Callbacks 171 Process Callbacks 174 Process Callbacks and Passthrough Data 176 Intersection Traversal 179 Testing Line Segment Intersections 179 Intersection Requests: pfSegSets 180 Intersection Return Data: pfHit Objects 180 Intersection Masks 181 Discriminator Callbacks 183 Line Segment Clipping 184 Traversing Special Nodes 185 Picking 185 Performance 185 Intersection Methods for Segments 186 vii Contents 7. Frame and Load Control 191 Frame-Rate Management 191 Selecting the Frame Rate 192 Achieving the Frame Rate 192 Fixing the Frame Rate 193 Level-of-Detail Management 198 Level-of-Detail Models 199 Level of Detail States 202 Level-of-Detail Range Processing 204 Level-of-Detail Transition Blending 207 Terrain Level of Detail 209 Dynamic Load Management 210 Successful Multiprocessing With IRIS Performer 213 Review of Rendering Stages 214 Choosing a Multiprocessing Model 214 Asynchronous Database Processing 220 Rules for Invoking Functions While Multiprocessing 222 Multiprocessing and Memory 226 Shared Memory and pfInit() 226 pfDataPools 227 Passthrough Data 228 8. Creating Visual Effects 231 Using pfEarthSky 231 Atmospheric Effects 232 Light Points 236 pfLightPoint 236 pfLPointState 237 Spotlights and Shadows 242 Morphing 244 viii 9. Importing Databases 251 Overview of Performer Database Creation and Conversion 251 libpfdu - Utilities for Creation of Efficient Performer Run-Time structures 252 pfdLoadFile - Loading Arbitrary Databases into Performer 252 Database Loading Details 254 Developing Custom Importers 257 Structure and interpretation of the Database File Format 258 Scene Graph Creation using Nodes as defined in libpf 258 Defining Geometry and Graphics State for libpr 258 Creation of a Performer Database Converter using libpfdu 259 Supported Database Formats 269 Description of Supported Formats 271 AutoDesk 3DS Format 271 Silicon Graphics BIN Format 271 Side Effects POLY Format 273 Brigham Young University BYU Format 275 Designer’s Workbench DWB Format 276 AutoCAD DXF Format 277 MultiGen OpenFlight Format 280 McDonnell-Douglas GDS Format 282 Silicon Graphics GFO Format 282 Silicon Graphics IM Format 284 AAI/Graphicon IRTP Format 285 Silicon Graphics Open Inventor Format 285 Lightscape Technologies LSA and LSB Formats 287 Medit Productions MEDIT Format 291 NFF Neutral File Format 292 Wavefront Technology OBJ Format 293 Silicon Graphics PHD Format 295 Silicon Graphics PTU Format 298 SIMNET S1000 Format 300 USNA Standard Graphics Format 302 ix Contents Silicon Graphics SGO Format 303 USNA Simple Polygon File Format 307 Sierpinski Sponge Loader 308 Star Chart Format 308 3D Lithography STL Format 309 SuperViewer SV Format 311 Geometry Center Triangle Format 314 UNC Walkthrough Format 314 10. libpr Basics 317 Overview 317 Design Motivation 317 Key Features 318 Geometry 319 Geometry Sets 320 3D Text 328 Graphics State 333 Rendering Modes 335 Rendering Values 340 Enable / Disable 340 Rendering Attributes 341 Graphics Library Matrix Routines 352 Sprite Transformations 353 Display Lists 355 State Management 355 State Override 357 pfGeoState 357 Windows 363 Configuring the framebuffer of a pfWindow 367 pfWindows and GL Windows 370 Manipulating a pfWindow 372 Communicating with the Window System 374 More pfWindow Examples 374 libpr Sample Code 378 x Managing Nongraphic System Tasks 384 Clocks 384 Memory Allocation 385 Asynchronous I/O 391 Error-Handling and Notification 391 File Search Paths 393 11. Math Routines 397 Vector Operations 397 Matrix Operations 399 Quaternion Operations 404 Matrix Stack Operations 407 Creating and Transforming Volumes 408 Defining a Volume 408 Creating Bounding Volumes 410 Transforming Bounding Volumes 411 Intersecting Volumes 412 Point-Volume Intersection Tests 412 Volume-Volume Intersection Tests 412 Creating and Working With Line Segments 414 Intersecting With Volumes 415 Intersecting With Planes and Triangles 416 Intersecting With pfGeoSets 416 General Math Routine Example Program 419 12. Statistics 425 Interpreting Statistics Displays 426 Status Line 427 Stage Timing Graph 427 Load and Stress 430 CPU Statistics 430 Rendering Statistics 432 Fill Statistics 432 xi Contents Collecting and Accessing Statistics in Your Application 433 Displaying Statistics Simply 434 Enabling and Disabling Statistics for a Channel 435 Statistics in libpr and libpf—pfStats Versus pfFrameStats 435 Statistics Rules of Use 436 Reducing the Cost of Statistics 439 Statistics Output