Acknowledgements Obviously,there would be no OpenSceneGraph book if there were not an OpenSceneGraph.Both Don Burns and Robert Osfield have been instrumental in OSG's genesis and development-thanks to them both.But I'd be remiss in not thanking the entire OSG community,over 1600 strong,for their support and contribution to this important open source standard. I'd like to thank Robert Osfield of OpenSceneGraph Professional Services for suggesting that the first OpenSceneGraph book should take the form of a free "quick start"guide.I'd also like to thank Roy Latham of CGSD and Don Burns of Andes Computer Engineering for funding the book's initial revision. Thanks (again)to Robert Osfield,and also Leandro Motta Barros,who both wrote partial OSG documentation in the past.These efforts served as stepping stones for this book. Thanks to Ben Discoe and the Virtual Terrain Project.This book's example code uses a tree image from their foliage library. Many in the OSG community served as technical reviewers for this book,or have provided other assistance.I'd like to thank Sohaib Athar,Ellery Chan,Edgar Ellis, Andreas Goebel,Chris "Xenon"Hanson,Farshid Lashkari,Gordon Tomlinson,and John Wojnaroski.All of these individuals have contributed in some way,whether they were aware of it or not. Finally,I must thank Deedre Martz for providing professional copyediting services.Once again,she's helped hide my sloppy writing style. OpenSceneGraph Quick Start Guide ix
OpenSceneGraph Quick Start Guide ix Acknowledgements Obviously, there would be no OpenSceneGraph book if there were not an OpenSceneGraph. Both Don Burns and Robert Osfield have been instrumental in OSG’s genesis and development—thanks to them both. But I’d be remiss in not thanking the entire OSG community, over 1600 strong, for their support and contribution to this important open source standard. I’d like to thank Robert Osfield of OpenSceneGraph Professional Services for suggesting that the first OpenSceneGraph book should take the form of a free “quick start” guide. I’d also like to thank Roy Latham of CGSD and Don Burns of Andes Computer Engineering for funding the book’s initial revision. Thanks (again) to Robert Osfield, and also Leandro Motta Barros, who both wrote partial OSG documentation in the past. These efforts served as stepping stones for this book. Thanks to Ben Discoe and the Virtual Terrain Project. This book’s example code uses a tree image from their foliage library. Many in the OSG community served as technical reviewers for this book, or have provided other assistance. I’d like to thank Sohaib Athar, Ellery Chan, Edgar Ellis, Andreas Goebel, Chris “Xenon” Hanson, Farshid Lashkari, Gordon Tomlinson, and John Wojnaroski. All of these individuals have contributed in some way, whether they were aware of it or not. Finally, I must thank Deedre Martz for providing professional copyediting services. Once again, she’s helped hide my sloppy writing style
1 An Overview of Scene Graphs and OpenSceneGraph This first chapter provides you with an introduction to the concept of a scene graph. You'll learn about OSG's history and organization,get a glimpse of its capabilities,learn how to obtain and install OSG,and run a few simple examples.This chapter helps you become familiar with scene graphs and OSG,but it contains no details on writing OSG- based applications.Chapters 2 and 3 cover that topic in more detail.This chapter is purely an introduction. 1.1 History of OpenSceneGraph In 1997,Don Burns was employed as a software consultant at Silicon Graphics,Inc.(now simply SGD)with an after-hours interest in hang gliding.Inevitably,his dual-interest in computer graphics and hang gliding,along with his access to high-end rendering hardware, resulted in his development of a hang gliding simulator that ran on SGI Onyx systems using the (SGI proprietary)Performer scene graph. Encouraged by fellow hang gliding enthusiasts to make his simulator available on more affordable hardware,Don began experimenting with Mesa3D on a Linux system with 3dfx Voodoo hardware.While this system provided acceptable OpenGL support,scene graphs were not available on Linux at that time.To fill this requirement,Don began to write "SG,"a simplified Performer-like scene graph.His emphasis with SG was simplicity and ease of use.SG filled the scene graph requirement and allowed his hang gliding simulator to run on low-cost Linux systems. In 1998,Don met Robert Osfield on an email list for hang gliding enthusiasts.Robert was working for Midland Valley Exploration,a Glasgow,Scotland,oil and gas company,so also had an interest in computer graphics and visualization.The two began to collaborate on improving the simulator.Robert was a supporter of open source,and suggested continuing to develop SG as a standalone open source scene graph project,with Robert as OpenSceneGraph Quick Start Guide 1
OpenSceneGraph Quick Start Guide 1 1 An Overview of Scene Graphs and OpenSceneGraph This first chapter provides you with an introduction to the concept of a scene graph. You’ll learn about OSG’s history and organization, get a glimpse of its capabilities, learn how to obtain and install OSG, and run a few simple examples. This chapter helps you become familiar with scene graphs and OSG, but it contains no details on writing OSGbased applications. Chapters 2 and 3 cover that topic in more detail. This chapter is purely an introduction. 1.1 History of OpenSceneGraph In 1997, Don Burns was employed as a software consultant at Silicon Graphics, Inc. (now simply SGI) with an after-hours interest in hang gliding. Inevitably, his dual-interest in computer graphics and hang gliding, along with his access to high-end rendering hardware, resulted in his development of a hang gliding simulator that ran on SGI Onyx systems using the (SGI proprietary) Performer scene graph. Encouraged by fellow hang gliding enthusiasts to make his simulator available on more affordable hardware, Don began experimenting with Mesa3D on a Linux system with 3dfx Voodoo hardware. While this system provided acceptable OpenGL support, scene graphs were not available on Linux at that time. To fill this requirement, Don began to write “SG,” a simplified Performer-like scene graph. His emphasis with SG was simplicity and ease of use. SG filled the scene graph requirement and allowed his hang gliding simulator to run on low-cost Linux systems. In 1998, Don met Robert Osfield on an email list for hang gliding enthusiasts. Robert was working for Midland Valley Exploration, a Glasgow, Scotland, oil and gas company, so also had an interest in computer graphics and visualization. The two began to collaborate on improving the simulator. Robert was a supporter of open source, and suggested continuing to develop SG as a standalone open source scene graph project, with Robert as
An Overview of Scene Graphs and OpenSceneGraph the project lead.The name was changed to OpenSceneGraph,and initially nine people were on the osg-users email list. In late 2000,Brede Johansen made the first major public contribution to OpenSceneGraph when he added the OpenFlight OSG plugin module.He developed the plugin while employed at Kongsberg Maritime Ship Simulation,Kongsberg,Norway,which ships the OSG-based SeaView R5 visual system product. Also in the year 2000,Robert left his salaried position to develop OSG on a fulltime basis, doing business as OpenSceneGraph Professional Services.At this time,he designed and implemented many of the core features you see in OSG today.This was accomplished without clients or pay. Don had moved on to Keyhole Technologies (now the Google Earth department of Google),and subsequently resigned in 2001.He also formed his own company,Andes Computer Engineering,based in San Jose,California,primarily to continue with OSG development.The first OpenSceneGraph birds-of-a-feather(BOF)meeting occurred at SIGGRAPH 2001.While only 12 people attended,the audience included representatives from Magic Earth,who were looking for an open source scene graph library to support their oil and gas application.They decided to contract with both Don and Robert for support and development,and became OSG's first paying customer. Each year,attendance at the OSG BOF continued to grow.The osg-users email list membership continues to grow at a phenomenal pace,as Figure 1-1 illustrates.As this book went to press,osg-users had more than 1600 subscribers. OSG features and add-on libraries were developed at a rapid pace.In 2003,the OSG companion library,Producer(originally called OSGMP),was created to provide a multipipe rendering capability for Magic Earth.In 2004,large database paging,terrain support,and shader support were added.2006 included a complete revamp of the OpenFlight plugin,as well as the creation of osgViewer,an integrated library for managing and rendering views of a scene. Today,several high-performance applications use OSG to manage rendering complex 2D 1500 1000 500 1998 2000 2002 2004 2006 Figure 1-1 osg-users email list growth The osg-users email list has grown significantly over time
2 An Overview of Scene Graphs and OpenSceneGraph the project lead. The name was changed to OpenSceneGraph, and initially nine people were on the osg-users email list. In late 2000, Brede Johansen made the first major public contribution to OpenSceneGraph when he added the OpenFlight OSG plugin module. He developed the plugin while employed at Kongsberg Maritime Ship Simulation, Kongsberg, Norway, which ships the OSG-based SeaView R5 visual system product. Also in the year 2000, Robert left his salaried position to develop OSG on a fulltime basis, doing business as OpenSceneGraph Professional Services. At this time, he designed and implemented many of the core features you see in OSG today. This was accomplished without clients or pay. Don had moved on to Keyhole Technologies (now the Google Earth department of Google), and subsequently resigned in 2001. He also formed his own company, Andes Computer Engineering, based in San Jose, California, primarily to continue with OSG development. The first OpenSceneGraph birds-of-a-feather (BOF) meeting occurred at SIGGRAPH 2001. While only 12 people attended, the audience included representatives from Magic Earth, who were looking for an open source scene graph library to support their oil and gas application. They decided to contract with both Don and Robert for support and development, and became OSG’s first paying customer. Each year, attendance at the OSG BOF continued to grow. The osg-users email list membership continues to grow at a phenomenal pace, as Figure 1-1 illustrates. As this book went to press, osg-users had more than 1600 subscribers. OSG features and add-on libraries were developed at a rapid pace. In 2003, the OSG companion library, Producer (originally called OSGMP), was created to provide a multipipe rendering capability for Magic Earth. In 2004, large database paging, terrain support, and shader support were added. 2006 included a complete revamp of the OpenFlight plugin, as well as the creation of osgViewer, an integrated library for managing and rendering views of a scene. Today, several high-performance applications use OSG to manage rendering complex 2D Figure 1-1 osg-users email list growth The osg-users email list has grown significantly over time
OpenSceneGraph Quick Start Guide 3 and 3D scenes.Though most OSG-based applications are in the visualization and simulation industries,OSG is found in nearly every field that employs 3D graphics, including geographic information systems(GIS),computer-aided design(CAD),modeling and digital content creation (DCC,database development,virtual reality,animation, gaming,and entertainment. 1.2 Installing OSG The previous section describes OSG's origin.This section explains how to obtain and install OSG,so you can run OSG examples and develop your own OSG applications. The OSG Wiki Web site [OSGWiki]offers many different packages and mechanisms for downloading OSG: Runtime binaries-Use an OSG runtime binary package to install the OSG libraries necessary to run OSG examples and applications. OSG source code-OSG developers should obtain a copy of the OSG source code.OSG provides many mechanisms for obtaining a complete OSG source code tree.You can obtain a compressed archive of a stable OSG release, download a nightly tarball (a compressed archive of the current source),or use Subversion (SVN)to check out the current source. OpenThreads-The core OSG libraries rely on OpenThreads for multithreading support.You must have an Open'Threads development environment to build OSG from source and build OSG-based applications. Third-party dependencies-If you're building OSG from source,some optional components require non-OSG software packages,such as libT'IFF,libPNG,etc. If these third-party components aren't present on your build system,the optional OSG components fail to build. Sample dataset-This is a collection of 2D images,3D models,and other data files. The following sections describe how to obtain and install the OSG runtime binaries. Although OSG runs on a wide variety of platforms,only Apple Mac OS X,Fedora Linux, and Microsoft Windows are covered here.For information on obtaining OSG for other platforms,see the OSG Wiki Web site [OSGWiki]. If installable binaries aren't available for your platform,or to create your own OSG development kit,you'll need to build OSG from source code.For information on obtaining OSG source code,the third party dependencies,OpenThreads,and the sample dataset,refer to the OSG Wiki Web site [OSGWiki]
OpenSceneGraph Quick Start Guide 3 and 3D scenes. Though most OSG-based applications are in the visualization and simulation industries, OSG is found in nearly every field that employs 3D graphics, including geographic information systems (GIS), computer-aided design (CAD), modeling and digital content creation (DCC), database development, virtual reality, animation, gaming, and entertainment. 1.2 Installing OSG The previous section describes OSG’s origin. This section explains how to obtain and install OSG, so you can run OSG examples and develop your own OSG applications. The OSG Wiki Web site [OSGWiki] offers many different packages and mechanisms for downloading OSG: • Runtime binaries—Use an OSG runtime binary package to install the OSG libraries necessary to run OSG examples and applications. • OSG source code—OSG developers should obtain a copy of the OSG source code. OSG provides many mechanisms for obtaining a complete OSG source code tree. You can obtain a compressed archive of a stable OSG release, download a nightly tarball (a compressed archive of the current source), or use Subversion (SVN) to check out the current source. • OpenThreads—The core OSG libraries rely on OpenThreads for multithreading support. You must have an OpenThreads development environment to build OSG from source and build OSG-based applications. • Third-party dependencies—If you’re building OSG from source, some optional components require non-OSG software packages, such as libTIFF, libPNG, etc. If these third-party components aren’t present on your build system, the optional OSG components fail to build. • Sample dataset—This is a collection of 2D images, 3D models, and other data files. The following sections describe how to obtain and install the OSG runtime binaries. Although OSG runs on a wide variety of platforms, only Apple Mac OS X, Fedora Linux, and Microsoft Windows are covered here. For information on obtaining OSG for other platforms, see the OSG Wiki Web site [OSGWiki]. If installable binaries aren’t available for your platform, or to create your own OSG development kit, you’ll need to build OSG from source code. For information on obtaining OSG source code, the third party dependencies, OpenThreads, and the sample dataset, refer to the OSG Wiki Web site [OSGWiki]
An Overview of Scene Graphs and OpenSceneGraph 1.2.1 Hardware Requirements OSG runs on a wide variety of hardware platforms and operating systems,and should run on most computer systems available today. ● Processor-OSG can be compiled to run on most contemporary CPUs.OSG is thread-safe and can take advantage of multi-processor and dual core architectures.OSG runs on both 32-and 64-bit processors. Graphics-Your system should feature an AGP or PCI-Express graphics card. OSG runs on most professional-and consumer-grade graphics hardware designed for modeling,simulation,and gaming.OSG requires graphics hardware with robust OpenGL support.Obtain and install the latest OpenGL device driver from your graphics hardware vendor.OSG's onboard graphics RAM requirements vary based on your usage,but 256MB is a good starting point.OSG runs on multi-pipe systems,and can take advantage of multiple graphics cards to increase rendering speed. ● RAM-The minimum system RAM requirement varies depending on the amount and type of data you intend to display with OSG.1GB is a good starting point, but you might need more for larger data sets. Disk-Like RAM,amount of secondary storage depends on your data requirements.As with any application,fast RPM and large disk caches can reduce data load times. 1.2.2 Apple Mac OS X OSG for Apple Mac OS X is available from the OSG Wiki Web site [OSGWiki]as a disk image (.dmg)file.It contains both run-time binaries and a full development environment. T'o install this package,perform the following steps. 1.From the OSG Wiki Web site [OSGWiki],select Downloads. 2.Download the OSG Universal Binaries for OSG v1.3.This is a.dmg file 3.After the download completes,mount the.dmg file. 4.Drag the contents of the .dmg Frameworks folder into /System/Frameworks. 5. In /Library/Application Support,create a new folder called OpenSceneGraph. Drag Plugins from the.dmg into this new folder. 1.2.3 Fedora Linux OSG is also available for other flavors of Linux.Many Linux environments provide a package installer interface that allows you to search for a package and install it.For example,in Ubuntu Linux,run the Synaptic Package Installer and search for
4 An Overview of Scene Graphs and OpenSceneGraph 1.2.1 Hardware Requirements OSG runs on a wide variety of hardware platforms and operating systems, and should run on most computer systems available today. • Processor—OSG can be compiled to run on most contemporary CPUs. OSG is thread-safe and can take advantage of multi-processor and dual core architectures. OSG runs on both 32- and 64-bit processors. • Graphics—Your system should feature an AGP or PCI-Express graphics card. OSG runs on most professional- and consumer-grade graphics hardware designed for modeling, simulation, and gaming. OSG requires graphics hardware with robust OpenGL support. Obtain and install the latest OpenGL device driver from your graphics hardware vendor. OSG’s onboard graphics RAM requirements vary based on your usage, but 256MB is a good starting point. OSG runs on multi-pipe systems, and can take advantage of multiple graphics cards to increase rendering speed. • RAM—The minimum system RAM requirement varies depending on the amount and type of data you intend to display with OSG. 1GB is a good starting point, but you might need more for larger data sets. • Disk—Like RAM, amount of secondary storage depends on your data requirements. As with any application, fast RPM and large disk caches can reduce data load times. 1.2.2 Apple Mac OS X OSG for Apple Mac OS X is available from the OSG Wiki Web site [OSGWiki] as a disk image (.dmg) file. It contains both run-time binaries and a full development environment. To install this package, perform the following steps. 1. From the OSG Wiki Web site [OSGWiki], select Downloads. 2. Download the OSG Universal Binaries for OSG v1.3. This is a .dmg file. 3. After the download completes, mount the .dmg file. 4. Drag the contents of the .dmg Frameworks folder into /System/Frameworks. 5. In /Library/Application Support, create a new folder called OpenSceneGraph. Drag Plugins from the .dmg into this new folder. 1.2.3 Fedora Linux OSG is also available for other flavors of Linux. Many Linux environments provide a package installer interface that allows you to search for a package and install it. For example, in Ubuntu Linux, run the Synaptic Package Installer and search for