Preface – OpenSceneGraph 3 Cookbook

Preface

During the last 12 years, OpenSceneGraph, which is one of the best 3D graphics programming interfaces in the world, has grown up so rapidly that it has already become the industry's leading open source scene graph technology. The latest distribution, OpenSceneGraph 3.0, now runs on all Microsoft Windows platforms, Apple Mac OS X, iOS (including iPhone and iPad), GNU/Linux, Android, IRIX, Solaris, HP-UX, AIX, and FreeBSD operating systems, with the efforts of 464 contributors around the world, and over 5,000 developers of the osg-users mailing list/forum and diverse and growing communities.

In the year 2010, I wrote the book "OpenSceneGraph 3.0 Beginner’s Guide" with the help of Dr. Xuelei Qian. It was published by Packt Publishing, and could help the readers gain an overview of scene graphs and the basic concepts in OpenSceneGraph. But one book is far less than enough, especially for those who want to continuously study this high-quality library in depth and play with some state-of-art techniques. So the book "OpenSceneGraph 3 Cookbook" comes onto the scene, with over 80 recipes demonstrating how to make use of some advanced API features and create programs for industrial demands.

In this book, we will work on different goals, which originate from actual projects and customer needs, and try to make use of the cutting-edge graphics techniques, or integrate with other famous and stable libraries to satisfy various multi-level and multi-aspect demands.

Some of the recipes are too long and too complicated to fit into any of the chapters, so they will only appear in the source code package, which can be downloaded from the Packt website, or the author's Github repository as described later.

What this book covers

Chapter 1, Customizing OpenSceneGraph, introduces some advance topics about the configuration and compilation, including build steps on mobile devices and the automatic generation of the API documentation.

Chapter 2, Designing the Scene Graph, explains the management of scene graph, as well as the implementation of user-node functionalities in various ways.

Chapter 3, Editing Geometry Models, shows how to create polygonal meshes and make them animated. It also introduces some solutions for modifying existing geometric properties.

Chapter 4, Manipulating the View, discusses the topics of multi-screen and multi-view rendering, and the camera manipulation using input devices such as the joysticks.

Chapter 5, Animating Everything, introduces almost all kinds of real-time animation implementations as well as the integration of physics engines.

Chapter 6, Designing Creative Effects, discusses some cutting-edge techniques about realistic rendering with GPU and shaders. It also demonstrates a common way to create post-processing framework for complicated scene effects.

Chapter 7, Visualizing the World, is a totally independent chapter that demonstrates the generation of landscape pieces and even the entire earth, using VirtualPlanetBuilder.

Chapter 8, Managing Massive Amounts of Data, shows some advanced ways to manage massive data in OpenSceneGraph applications, with the help of some modern hardware features such as occlusion query and draw instancing.

Chapter 9, Integrating with GUI, covers the integration of OpenSceneGraph and other graphics user interfaces (GUI), including 2D and 3D widgets, mobile programs, and web browsers.

What you need for this book

To use this book, you will need a graphic card with robust OpenGL support, with the latest OpenGL device driver installed from your graphics hardware vendor.

You will need to download OpenSceneGraph 3.0.1 from http://www.openscenegraph.org. Some recipes may require the latest developer version. The CMake utility is also necessary for compiling OpenSceneGraph and the source code of this book. You may download it from http://www.cmake.org/.

You will also need a working compiler which transforms C++ source code into executable files. Some recommended ones include: gcc (on Unices), XCode (on Mac OS X), and mingw32 and Visual Studio (on Windows).

Who this book is for

This book is intended for software developers, researchers, and students who are already familiar with the basic concepts of OpenSceneGraph and can write simple programs with it. A basic knowledge of C++ programming is also expected. Some experience of using and integrating platform-independent APIs is also useful, but is not required.

General real-time computer graphics knowledge would be sufficient. Some familiarity with 3D vectors, quaternion numbers, and matrix transformations is helpful.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "For Debian and Ubuntu users, make sure you have the root permission and type the command apt-get in the terminal as shown in the following command line."

A block of code is set as follows:

// Create the text and place it in an HUD camera
osgText::Text* text = osgCookBook::createText(
osg::Vec3( 50.0f, 50.0f, 0.0f), "", 10.0f);
osg::ref_ptr<osg::Geode> textGeode = new osg::Geode;
textGeode->addDrawable( text );

Any command-line input or output is written as follows:

# sudo apt-get install subversion

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "You may easily download the binary packages of specified platform in the Binary Packages section".

Note

Warnings or important notes appear in a box like this.

Note

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to, and mention the book title through the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can also download the latest version of the source code package at the author's GitHub repository https://github.com/xarray/osgRecipes. All recipes of this book are included in this link, as well as more OSG-related examples written by the author and other contributors.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website, or added to any list of existing errata, under the Errata section of that title.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.