The Inventor Mentor Programming Object Oriented 3D Graphis With Open Inventor 2

  • Published on

  • View

  • Download


The Inventor Mentor:Programming ObjectOriented 3D Graphics with Open Inventor,Release 2About This Book What This Book Contains How to Use This Book What You Should Know Before Reading This Book Conventions Used in This Book Tips Advanced Information Key to Scene Graph Diagrams Suggestions for Further Reading Acknowledgments Color Plates

Chapter 1 Overview What Is Open Inventor? Objects, not Drawings Using Database Objects in a Variety of Ways Animation How Does Open Inventor Relate to OpenGL? The Inventor Toolkit The Scene Database Node Kits Manipulators Inventor Component Library Inventor Class Tree Extending the Toolkit Chapter 2 An Inventor Sampler "Hello, Cone" A Red Cone Using Engines to Make the Cone Spin Adding a Trackball Manipulator Adding the Examiner Viewer Naming Conventions Scene Basic Types Methods Types versus Fields

Coordinate Systems in Inventor Include Files

Chapter 3 Nodes and Groups The Scene Database Scene Graphs Types of Nodes Creating Nodes Whats in a Node? What Happens When You Apply an Action to a Node? (Advanced) Shape Nodes Property Nodes Groups Creating Groups Ordering of Children Why Is Order Important? Separators Other Subclasses of SoGroup Shared Instancing of Nodes Paths Where Do Paths Come From? What Are Paths Used For? Fields within a Node Why Fields? (Advanced) Single versus MultipleValue Fields SingleValue Fields: Setting and Getting Values MultipleValue Fields: Setting and Getting Values Ignore Flag (Advanced) Override Flag (Advanced) References and Deletion Reference Counting How Nodes Are Deleted Nodes with Zero References Summary of References and Deletion Node Types Naming Nodes Chapter 4 Cameras and Lights Using Lights and Cameras

Cameras SoCamera Subclasses of SoCamera SoPerspectiveCamera SoOrthographicCamera Mapping the Camera Aspect Ratio to the Viewport Viewing a Scene with Different Cameras Lights SoLight Subclasses of SoLight SoPointLight SoDirectionalLight SoSpotLight Using Multiple Lights

Chapter 5 Shapes, Properties, and Binding Simple Shapes Complex Shapes Face Set Indexed Face Set Triangle Strip Set Quad Mesh Property Nodes Material Node DrawStyle Node LightModel Node Environment Node ShapeHints Node Complexity Node Units Node Binding Nodes Indexed Binding Binding per Vertex Nuances (Advanced) Using a MaterialBinding Node Normal Binding Generating Normals Automatically Transformations SoTransform Node

Order of Transformations

Chapter 6 Text TwoDimensional Text Font Type and Size Using 2D Text ThreeDimensional Text Parts of 3D Text Profile Simple Use of 3D Text Advanced Use of 3D Text (Advanced) Chapter 7 Textures Creating Textured Objects What Is a Texture Map? Nodes Used for Texture Mapping Using the Defaults Key Concepts Wrapping a Texture around an Object How a Texture Affects the Underlying Colors (Advanced) Storing an Image (Advanced) SoTexture2 Node Fields of an SoTexture2 Node Transforming a Texture Map Mapping the Texture onto the Object Using the Default Texture Mapping Specifying Texture Coordinates Explicitly (Advanced) Using a TextureCoordinate Function Chapter 8 Curves and Surfaces Overview Classes Used with NURBS Shapes Parametric Curves Key Concepts Control Points and Order Continuity of a Curve Basis Function Summary of NURBS Relationships Rational Curves

NURBS Spells NURBS Examples of NURBS Curves BSpline Curve Uniform BSpline Curve Passing through Endpoints NURBS Surfaces Bezier Surface Trimming NURBS Surfaces Suggestions for Further Reading

Chapter 9 Applying Actions Inventor Actions General Model Applying an Action Rendering Setting the Transparency Quality Antialiasing Printing and Offscreen Rendering Caching Culling Part of the Scene Calculating a Bounding Box Create an Instance of the Action Apply the Action Obtain Results Accumulating a Transformation Matrix Create an Instance of the Action Apply the Action Obtain Results Writing to a File Searching for a Node Specify the Search Criteria Apply the Action Obtain the Results Picking Picking Style Create an Instance of the Action Set Parameters Apply the Action Obtain Results Using the Pick Action

Calling Back to the Application Create an Instance of the Action Register Callback Functions Apply the Action Using a Callback for Generated Primitives

Chapter 10 Handling Events and Selection Overview General Programming Model for Event Handling Using the X Window System Render Area Inventor Events (SoEvent) Scene Manager Inventor Event Handling How Nodes Handle Events: SoHandleEventAction SoNode SoGroup SoManipulator SoSelection Finding the Event Handler Using Event Callback Nodes (Advanced) Sending Events Directly to the Application (Advanced) Selection Managing the Selection List Highlighting Selected Objects Callback Functions for Selection Changes Chapter 11 File Format Writing a Scene Graph Reading a File into the Database File Format Syntax File Header Writing a Node Writing Values within a Field Ignore Flag Field Connections Global Fields Writing an Engine Writing a Path Defining and Using Shared Instances of Nodes

Writing a Node Kit Including Other Files ASCII and Binary Versions Reading in Extender Nodes and Engines File Format for Unknown Nodes and Engines Alternate Representation Reading from a String

Chapter 12 Sensors Introduction to Sensors Sensor Queues Key Terms Data Sensors General Sequence for Data Sensors Callback Function Priorities Triggering a Data Sensor Using a Field Sensor Using the Trigger Node and Field (Advanced) Other DelayQueue Sensors General Sequence for OneShot and Idle Sensors SoOneShotSensor SoIdleSensor TimerQueue Sensors General Sequence for TimerQueue Sensors SoAlarmSensor SoTimerSensor Processing the Sensor Queues (Advanced) Chapter 13 Engines Introduction to Engines General Uses of Engines Types of Engines Making Field Connections Multiple Connections Field Conversion Reference Counting Disabling a Connection Updating Values

Global Fields Animation Engines ElapsedTime Engine OneShot Engine TimeCounter Engine Gate Engine Arithmetic Engines Boolean Engine Calculator Engine Using the Calculator to Constrain Object Behavior Nodes Used for Animation Rotor Node Blinker Node

Chapter 14 Node Kits Why Node Kits? Hidden Children and SoNodeKitPath NodeKit Classes NodeKit Catalog Parts Created by Default Selecting Parts and Setting Values Other Methods: getPart() and setPart() The getPart() Method The setPart() Method Macros for Getting Parts The SO_GET_PART() Macro The SO_CHECK_PART() Macro Specifying Part Names Creating Paths to Parts Using List Parts Using Separator Kits to Create Motion Hierarchies Examples Simple Use of Node Kits Using Node Kits with Editors Creating a Motion Hierarchy Chapter 15 Draggers and Manipulators What Is a Dragger? Types of Draggers

Manipulators versus Draggers Simple Draggers Field Connections Callback Functions Using Multiple Draggers Manipulators Replacing a Node with a Manipulator Using the replaceNode() Method Customizing a Dragger (Advanced) Parts of a Dragger Changing a Part after Building the Dragger Changing the Default Geometry for a Part

Chapter 16 Inventor Component Library Introduction to Components Xt Utility Functions Render Area Methods Xt Devices Using the Overlay Planes (Advanced) Xt Components General Model Construct the Component Show and Hide the Component Passing Data to the Application Viewers Constructing a Viewer Specifying the Scene Graph for the Viewer Methods for SoXtViewer Methods for SoXtFullViewer Using the 3D Clipboard Creating an Instance of SoXtClipboard Copying Data onto the Clipboard Pasting Data from the Clipboard Chapter 17 Using Inventor with OpenGL Introduction OpenGL State Variables and Inventor ColorIndex Mode

Using an SoCallback Node Caching Using a Callback Node Applying a Render Action Inside a GLX Window

Appendix A An Introduction to ObjectOriented Programming for C Programmers What Is ObjectOriented Programming? Data Abstraction Inheritance Implementing Data Abstraction and Inheritance: Classes Class Hierarchies An Example of a Class: Sphere An Example of Inheritance: HollowSphere Suggested Reading Appendix B An Introduction to the C API Naming C Functions Abbreviating C Function Names Creating and Deleting Objects from C Overloaded C++ Methods Calling Functions C Classes and Manual Pages A Sample Open Inventor Program in C Appendix C Error Handling Runtime TypeChecking Posting an Error Handling an Error Debugging

The Inventor Mentor: Programming ObjectOriented 3D Graphics with Open Inventor, Release 2

About This BookThe Inventor Mentor introduces graphics programmers and application developers to Open Inventor, an objectoriented 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 online. If you are new to the C++ language, see Appendix A, "An Introduction to ObjectOriented Programming for C Programmers," to help you understand the references to classes, subclasses, and other objectoriented concepts used throughout this book. If you are using the C application programming interface, also see Appendix B, "An Introduction to the C API."

What This Book ContainsThis 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 Inventors 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

The Inventor Mentor: Programming ObjectOriented 3D Graphics with Open Inventor , Release 2 About This Book 1

Chapter 12, "Sensors," describes how Inventor sensors watch for certain types of events and invoke usersupplied 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 Inventors Xt components, which are program modules with a builtin 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 ObjectOriented Programming for C Programmers," describes basic concepts of objectoriented 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 Inventors error handling mechanism.

How to Use This BookIts unrealistic to expect anyone to read a lengthy programmers 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 online 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.

The Inventor Mentor: Programming ObjectOriented 3D Graphics with Open Inventor , Release 2 About This Book 2

What You Should Know Before Reading This BookThis book assumes you are familiar with basic concepts of 3D graphics programming. For example, it ass...


View more >