The Inventor Mentor introduces graphics programmers and application developers to Open Inventor, an object-oriented 3D toolkit. Open Inventor is a library of objects and methods used for interactive 3D graphics. Although it is written in C++, Open Inventor also includes C bindings.
For the sake of brevity, the examples included in this book are in C++. All C++ examples, as well as equivalent examples written in C, are available on-line. If you are new to the C++ language, see Appendix A, “An Introduction to Object-Oriented Programming for C Programmers,” to help you understand the references to classes, subclasses, and other object-oriented concepts used throughout this book. If you are using the C application programming interface, also see Appendix B, “An Introduction to the C API.”
This book describes how to write applications using the Open Inventor toolkit. The Inventor Toolmaker, a companion book for the advanced programmer, describes how to create new Inventor classes and how to customize existing classes.
The Inventor Mentor contains the following chapters:
Chapter 1, “Overview,” provides a general description of Open Inventor concepts and classes and how Inventor relates to OpenGL and the X Window System.
Chapter 2, “An Inventor Sampler,” presents a short program that creates a simple object. This program is then modified to show the use of important Inventor objects: engines, manipulators, and components.
Chapter 3, “Nodes and Groups,” introduces the concept of a scene graph and shows how to create nodes and combine them into different kinds of groups.
Chapter 4, “Cameras and Lights,” describes the camera nodes used to view a scene and the light nodes that provide illumination.
Chapter 5, “Shapes, Properties, and Binding,” describes how to create both simple and complex shapes and how to use property nodes, including material, draw style, and lighting model nodes. Binding materials and surface normals to shape nodes is also explained.
Chapter 6, “Text,” shows the use of 2D and 3D text nodes.
Chapter 7, “Textures,” describes how to apply textures to the surfaces of objects in a scene.
Chapter 8, “Curves and Surfaces,” explains how to use NURBS curves and surfaces.
Chapter 9, “Applying Actions,” describes how operations are applied to an Inventor scene graph. Actions include OpenGL rendering, picking, calculating a bounding box, calculating a transformation matrix, writing to a file, and searching the scene graph for certain types of nodes.
Chapter 10, “Handling Events and Selection,” explains how Inventor receives events from the window system. It also describes how the selection node manages a selection list and performs highlighting.
Chapter 11, “File Format,” describes Inventor's interchange file format, used for reading files into Inventor, writing files out from Inventor, and data exchanges such as copy and paste.
Chapter 12, “Sensors,” describes how Inventor sensors watch for certain types of events and invoke user-supplied callback functions when these events occur.
Chapter 13, “Engines,” describes how you can use Inventor engines to animate parts of a scene graph, or to create interdependencies among the nodes in the graph.
Chapter 14, “Node Kits,” introduces node kits, a convenient mechanism for creating groups of related Inventor nodes. Each node kit contains a catalog of nodes from which you select the desired nodes.
Chapter 15, “Draggers and Manipulators,” describes how to use draggers and manipulators, which are special objects in the scene graph that respond to user events. Manipulators are nodes with field values that can be edited directly by the user.
Chapter 16, “Inventor Component Library,” shows how to use Inventor's Xt components, which are program modules with a built-in user interface for changing the scene graph interactively. It also Chapter 17, “Using Inventor with OpenGL,” discusses how to use Inventor with the OpenGL Library.
There are three appendices:
Appendix A, “An Introduction to Object-Oriented Programming for C Programmers,” describes basic concepts of object-oriented programming, including data abstraction and inheritance.
Appendix B, “An Introduction to the C API,” explains the differences between the Open Inventor C and C++ interfaces.
Appendix C, “Error Handling,” describes Inventor's error handling mechanism.
It's unrealistic to expect anyone to read a lengthy programmer's guide from start to finish. After you read a few basic chapters, you can skim others and skip around, depending on your particular needs and goals. Here are a few suggested paths for making your way through this book.
For a basic understanding of how to create nodes and connect them into scene graphs, read Chapters 1 through 5. Then read Chapter 9, “Applying Actions,” and Chapter 10, “Handling Events and Selection.”
If you are mainly interested in reading files into the Inventor database, read Chapters 1 and 2 for an overview of Inventor, and then jump to Chapter 11, “File Format.”
If you are an experienced OpenGL programmer, Chapters 1, 2, 10, and 17, “Using Inventor with OpenGL,” are important chapters to begin with. Again, for a basic understanding of building a scene graph, you also need to read Chapters 3 through 5 and Chapter 9.
Chapter 15, “Draggers and Manipulators,” and Chapter 16, “Inventor Component Library,” describe the programming aspects of Inventor that have an associated user interface. The user interface for individual components is described in the on-line HELP cards provided for each class.
Once you understand the basic material presented in Chapters 1 through 5, you can skip to Chapter 13, “Engines,” and Chapter 14, “Node Kits.” Engines, like nodes, are basic building blocks in the scene graph. They allow you to animate parts of the scene graph and to incorporate additional behavior into scene graph objects. If you are creating scene graphs, node kits offer many shortcuts.
This book assumes you are familiar with basic concepts of 3D graphics programming. For example, it assumes you have a reasonable understanding of the following terms: lighting, rendering, vertex, polygon, light source, picking, matrix, OpenGL, pixel, surface normal. If these terms are new to you, consult one or two of the sources listed in “Suggestions for Further Reading,” later in this introduction.
In addition, this book assumes you have some familiarity with concepts related to object-oriented programming. See “Suggestions for Further Reading” as well as Appendices A and B for good background information.
This book uses boldface text font for all Inventor classes, methods, and field names: SoNode, SoMaterial, getValue(), setValue(), ambientColor, and center. Parentheses indicate methods. Code examples are in Courier font.
Several headings are used in paragrahs to highlight different kinds of text. Programming tips are marked with their own heading Tip:.
Figure In-1 shows the symbols used in the scene graph diagrams that appear throughout this guide.
For a general introduction to computer graphics, see the following:
Foley, J.D., A. van Dam, S. Feiner, and J.F. Hughes, Computer Graphics Principles and Practice, 2e. Reading, Mass.: Addison-Wesley, 1990.
Neider, Jackie, Tom Davis, Mason Woo, OpenGL Programming Guide. Reading, Mass.: Addison-Wesley, 1993.
Newman, W., and R. Sproull, Principles of Interactive Computer Graphics, 2e. New York: McGraw-Hill, 1979.
For an introduction to the C++ language, see the following:
Lippman, Stanley B., A C++ Primer, 2e. Reading, Mass.:Addison-Wesley, 1991.
Shapiro, Jonathan, A C++ Toolkit. Englewood Cliffs, N.J.: Prentice-Hall, Inc., 1991.
For an introduction to object-oriented programming, see
As a student of the Open Inventor toolkit, I am deeply indebted to the original Inventor mentors, who contributed so much to the development and content of this book: Rikk Carey, Gavin Bell, Alain Dumesny, Dave Immel, Paul Isaacs, Howard Look, David Mott, Paul Strauss, and Helga Thorvaldsdóttir. Even under the pressures of tight deadlines and numerous competing responsibilities, the members of the Inventor team consistently met my demands: they answered all questions, reviewed numerous drafts, and created the code examples that are the core of this book. Rikk Carey provided dynamic leadership for the Open Inventor project, rigorously questioning and challenging each decision. Paul Strauss, one of the chief architects of Inventor, probably read the most drafts and definitely added the most red (and green) ink to those drafts. His insightful and literate reviews were invaluable to me. Additional eagle-eyed reviewers included Ronen Barzel, Sam Chen, Beth Fryer, and Kevin Goldsmith.
Putting all the pieces of the puzzle together—screen shots, line art, color plates, text, code examples—also required a large cast of people. Rikk Carey created the cover image. Catherine Madonia used Rikk's scene to create the black-and-white images for the part- and chapter-title pages. Paul Isaacs showed his creative genius—not to mention his ability to work under brutal deadlines—in creating the many models and scenes for the images shown in Figure In-2 through Figure In-22. I'm also grateful to Maria Mortati, who designed the color plate section and persuaded me to make massive edits to the figure captions. Catherine Madonia helped by creating conceptual images and by taking snapshots of the example programs. The many details of dealing with vendors, coordinating printer tests and schedules, and producing the book were ably handled by Laura Cooper and Lorrie Williams. Line art was drawn by Kay Maitz, Cheri Brown, Dan Young, Howard Look, and Lorrie Williams. Helga Thorvaldsdóttir paid special attention to the code examples: writing many of them, and revising and polishing to the bitter end.
Many thanks to Kirk Alexander, of the Interactive Computer Graphics Laboratory at Princeton University, who supplied numerous images and revisions to satisfy our requests precisely. The Out-of-Box Experience, an application originally designed for the Silicon Graphics Indy workstation, shown in Figure In-38 through Figure In-41, was created by Leo Blume, Mark Daly, Kevin Goldsmith, Howard Look, and Chee Yu of Silicon Graphics, and Brad de Graf, Shari Glusker, Jill Huchital, Karen Hughes, Peter Oppenheimer, Mark Swain, Drew Takahashi, and Phil Zucco of (Colossal) Pictures. The art gallery tour shown in Figure In-31 is the work of Gavin Bell, Mark Daly, Kevin Goldsmith, and Linda Roy, all of Silicon Graphics. Many of the models used in the cover scene were created by Acuris, Inc.
I'd also like to thank Jackie Neider, manager of Developer Publications in the Visual Magic Division of Silicon Graphics, and the other members of my department—Patricia Creek, Arthur Evans, Liz Deeth, Beth Fryer, Jed Hartman, Ken Jones, John Stearns, Eleanor Bassler, and Carol Geary—for their consistent support and encouragement during the course of this project (and for sharing the high-speed printer).
And, most important, thanks to my husband, Steve, and my sons, Jeff and Evan, for a warm dinner and cheerful conversation at the end of some very long days.