OpenSceneGraph 3.0
Beginner's Guide
Table of Contents
OpenSceneGraph 3.0
Credits
Foreword
About the Authors
Acknowledgement
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Time for actionâheading
What just happened?
Pop quizâheading
Have a go heroâheading
Reader feedback
Customer support
Errata
Piracy
Questions
1. The Journey into OpenSceneGraph
A quick overview of rendering middleware
Scene graphs
The Birth and development of OSG
Components
Why OSG?
Who uses OSG?
Have a quick taste
Time for actionâsay "Hello World" OSG style
What just happened?
Live in community
Summary
2. Compilation and Installation of OpenSceneGraph
System requirements
Using the installer
Time for actionâinstalling OSG
What just happened?
Running utilities
Time for actionâplaying with osgviewer
What just happened?
Pop quizâdependencies of osgviewer
Have a go heroâplaying with osgconv
Using the project wizard
Time for actionâcreating your solution with one click
What just happened?
Have a go heroâconstructing "Hello World" with the wizard
Prebuilts making trouble?
Cross-platform building
Starting CMake
Time for actionârunning CMake in GUI mode
What just happened?
Setting up options
Generating packages using Visual Studio
Time for actionâbuilding with a Visual Studio solution
What just happened?
Pop quizâthe difference between ALL_BUILD and 'build all'
Generating packages using gcc
Time for actionâbuilding with a UNIX makefile
What just happened?
Have a go heroâchecking mis-compiled parts
Configuring environment variables
Summary
3. Creating Your First OSG Program
Constructing your own projects
Time for actionâbuilding applications with CMake
What just happened?
Pop quizâconfiguring OSG path options yourselves
Have a go heroâtesting with different generators
Using a root node
Time for actionâimproving the "Hello World" example
What just happened?
Understanding memory management
ref_ptr<> and Referenced classes
Collecting garbage: why and how
Tracing the managed entities
Time for actionâmonitoring counted objects
What just happened?
Have a go heroâreturning from a function
Pop quizârelease a smart pointer
Parsing command-line arguments
Time for actionâreading the model filename from the command line
What just happened?
Tracing with the notifier
Redirecting the notifier
Time for actionâsaving the log file
What just happened?
Summary
4. Building Geometry Models
How OpenGL draws objects
Geode and Drawable classes
Rendering basic shapes
Time for actionâquickly creating simple objects
What just happened?
Storing array data
Vertices and vertex attributes
Specifying drawing types
Time for actionâdrawing a colored quad
What just happened?
Pop quizâresults of different primitive types
Indexing primitives
Time for actionâdrawing an octahedron
What just happened?
Pop quizâoptimizing indexed geometries
Have a go heroâchallenges with cubes and pyramids
Using polygonal techniques
Time for actionâtessellating a polygon
What just happened?
Rereading geometry attributes
Customizing a primitive functor
Time for actionâcollecting triangle faces
What just happened?
Have a go heroâanalyzing topology of a geometry
Implementing your own drawables
Using OpenGL drawing calls
Time for actionâcreating the famous OpenGL teapot
What just happened?
Summary
5. Managing Scene Graph
The Group interface
Managing parent nodes
Time for actionâadding models to the scene graph
What just happened?
Pop quizâfast dynamic casting
Traversing the scene graph
Transformation nodes
Understanding the matrix
The MatrixTransform class
Time for actionâperforming translations of child nodes
What just happened?
Pop quizâmatrix multiplications
Have a go heroâmaking use of the PositionAttitudeTransform class
Switch nodes
Time for actionâswitching between the normal and damaged Cessna
What just happened?
Level-of-detail nodes
Time for actionâconstructing a LOD Cessna
What just happened?
Proxy and paging nodes
Time for actionâloading a model at runtime
What just happened?
Have a go heroâworking with the PagedLOD class
Customizing your own NodeKits
Time for actionâanimating the switch node
What just happened?
Have a go heroâcreating a tracker node
The visitor design pattern
Visiting scene graph structures
Time for actionâanalyzing the Cessna structure
What just happened?
Summary
6. Creating Realistic Rendering Effects
Encapsulating the OpenGL state machine
Attributes and modes
Time for actionâsetting polygon modes of different nodes
What just happened?
Inheriting render states
Time for actionâlighting the glider or not
What just happened?
Playing with fixed-function effects
Time for actionâapplying simple fog to models
What just happened?
Have a go heroâsearching for more effects
Lights and light sources
Time for actionâcreating light sources in the scene
What just happened?
Pop quizâlights without sources
The Image class
The basis of texture mapping
Time for actionâloading and applying 2D textures
What just happened?
Have a go heroâmaking use of filters and wrapping modes
Handling rendering order
Time for actionâachieving the translucent effect
What just happened?
Understanding graphics shaders
Using uniforms
Time for actionâimplementing a cartoon cow
What just happened?
Pop quizâreplacements of built-in uniforms
Have a go heroâsetting vertex attributes to shaders
Working with the geometry shader
Time for actionâgenerating a Bezier curve
What just happened?
Have a go heroâhaving fun with shaders
Summary
7. Viewing the World
From world to...