• No results found

[ " OpenSceneGraph 3.0. Beginner s Guide. open source i. OpenSceneGraph, one of the best 3D graphics engines

N/A
N/A
Protected

Academic year: 2021

Share "[ " OpenSceneGraph 3.0. Beginner s Guide. open source i. OpenSceneGraph, one of the best 3D graphics engines"

Copied!
8
0
0

Loading.... (view fulltext now)

Full text

(1)

OpenSceneGraph

3.0

Beginner

s

Guide

Create

high-performance

virtual

reality applications

with

OpenSceneGraph,

one

of the

best

3D

graphics engines

Rui

Wang

Xuelei

Qian

Ti.i;H;:r.c.HE

1

INf-OV

i!,"

A'fiOt

JSi..ii»L10 I HG< UN IVt-!! V,I

TATSB

I III,J OTH L K HANNOVER

J

[

" U » i i SH ; N

open

source

i:3m»ft«i!f *«fHM'«m:t>cmmam

BIRMINGHAM -MUM8AI TlBAJB Hannover

(2)

Table

of

Contents

Preface

1

Chapter

1:

The

Journey

into

OpenSceneGraph

7

A

quick

overview of

rendering

middleware 8

Scene

graphs

8

The Birth and

development

of OSG 9

Components

10

Why

OSG? 12

WhousesOSG? 13

Havea

quick

taste 14

Timeforaction

-say "Hello World" OSG

style

14

Live in

community

15

Summary

17

Chapter

2:

Compilation

and

Installation

of

OpenSceneGraph

19

System requirements

20

Using

the installer 20

Timeforaction-

installing

OSG 21

Running

utilities 26

Timeforaction-

playing

with

osgviewer

26

Using

the

project

wizard 29

Time foraction-

creating

yoursolution withoneclick 29

Prebuilts

making

trouble? 30

Cross-platform building

31

Starting

CMake 31

Time for action

-running

CMake in GUI mode 32

Setting

up

options

35

Generating packages using

Visual Studio 37

Time for action-

building

withaVisualStudiosolution 37

(3)

Table

of

Contents

Time for action-

building

witha UNIX makefile 38

Configuring

environment variables 40

Summary

41

Chapter

3:

Creating

Your First OSG

Program

43

Constructing

yourown

projects

44

Time for action-

building

applications

with CMake 44

Using

a root node 46

Time for action-

improving

the "Hello World"

example

47

Understanding

memory

management

48

ref_ptr<>

and

Referenced

classes 48

Collecting garbage:

why

and how 50

Tracing

the

managed

entities 52

Timefor action-

monitoring

counted

objects

52

Parsing

command-line

arguments

55

Time for action-

reading

the model filename from the command line 55

Tracing

with the notifier 57

Redirecting

the notifier 57

Time for

action-saving

the

log

file 58

Summary

60

Chapter

4:

Building Geometry

Models

61

How

OpenGL

draws

objects

62

Geode and Drawable classes 62

Rendering

basic

shapes

63

Time for action-

quickly creating simple objects

64

Storing

arraydata 66

Vertices andvertex

attributes

66

Specifying drawing

types 68

Time for action-

drawing

acolored

quad

68

Indexing primitives

72

Time for action-

drawing

an octahedron 73

Using

polygonal techniques

77

Time for action-

tessellating

a

polygon

78

Rereading geometry

attributes 81

Customizing

a

primitive

functor 82

Time for action-

collecting triangle

faces 82

Implementing

yourowndrawables 86

Using OpenGL drawing

calls 87

Time for action-

creating

the famous

OpenGL

teapot

87

Summary

91

(4)

Chapter

5:

Managing

Scene

Graph

93

The

Group

interface 94

Managing

parent nodes 94

Time for action-

adding

modelstothescene

graph

96

Traversing

thescene

graph

98

Transformation

nodes 99

Understanding

the matrix 100

The MatrixTransform class 101

Time for action

-performing

translations of child nodes 101

Switch nodes 104

Time foraction-

switching

between the normal and

damaged

Cessna 105

Level-of-detail

nodes 107

Time for action-

constructing

a LODCessna 108

Proxy

and

paging

nodes 110

Time for action-

loading

a modelatruntime 110

Customizing

yourown NodeKits 112

Timefor action-

animating

the switch node 113

The visitor

design pattern

116

Visiting

scene

graph

structures 117

Time for action-

analyzing

theCessna structure 118

Summary

121

Chapter

6:

Creating

Realistic

Rendering

Effects

123

Encapsulating

the

OpenGL

statemachine 124

Attributes and modes 124

Time for action-

setting polygon

modes of different nodes 126

Inheriting

renderstates 128

Timefor action-

lighting

the

glider

ornot 129

Playing

with fixed-function effects 131

Time for action

-applying

simple fog

tomodels 134

Lights

and

light

sources 136

Timefor action

-creating light

sourcesin thescene 137

The

Image

class 140

The basis oftexture

mapping

141

Time for action-

loading

and

applying

2Dtextures 143

Handling rendering

order 146

Time for action-

achieving

the translucent effect 148

Understanding graphics

shaders 152

Using uniforms

153

Time for action-

implementing

a cartooncow 154

(5)

Table

of

Contents

Time for action-

generating

a Beziercurve 158

Summary

162

Chapter

7:

Viewing

the World

163

From worldto screen 164

The Camera class 165

Rendering

order

of

cameras 167

Timefor action-

creating

anHUD camera 168

Using

a

single

viewer 170

Digging

into the simulation

loop

170

Time for action

-customizing

the simulation

loop

172

Using

a

composite

viewer 175

Timefor action-

rendering

more scenes atonetime 176

Changing

global display settings

179

Time for action-

enabling global multisampling

180

Stereo visualization 182

Time for action-

rendering anaglyph

stereo scenes 183

Rendering

totextures 184

Frame

buffer, pixel buffer,

and FBO 185

Time

for

action-

drawing

aircraftson a loaded terrain 186

Summary

192

Chapter

8:

Animating

Scene

Objects

193

Taking

referencesto

functions

193

List of callbacks 194

Time foraction-

switching

nodes in the

update

traversal 195

Avoiding

conflicting

modifications 198

Time

for

action-

drawing

a

geometry

dynamically

199

Understanding

ease motions 203

Animating

the

transformation

nodes 205

Time for action-

making

useof the animation

path

205

Changing

rendering

states 208

Time

for

action-fading

in 209

Playing

moviesontextures 214

Time for action-

rendering

a

flashing spotlight

215

Creating

complex

key-frame

animations 218

Channels and animation managers 220

Time for

action

-

managing

animation channels

221

Loading

and

rendering

characters 225

Time for action-

creating

and

driving

a character

system

225

Summary

228

(6)

Chapter

9:

Interacting

with Outside Elements

231

Variousevents 232

Handling

mouseand

keyboard inputs

233

Time for action-

driving

the Cessna 234

Adding

customized events 239

Timeforaction-

creating

a usertimer 239

Picking objects

243

Intersection 243

Time for action-

clicking

and

selecting

geometries

245

Windows, graphics

contexts,

andcameras 249

The Traits class 250

Time for action-

configuring

the traits ofa

rendering

window 251

Integrating

OSG intoawindow 254

Time for action-

attaching

OSGwith

awindow handlein Win32 255

Summary

260

Chapter

10:

Saving

and

Loading

Files 263

Understanding file

I/O plugins

264

Discovery

of

specified

extension 265

Supported

file formats 266

The

pseudo-loader

270

Timeforaction-

reading

files fromthe Internet 271

Configuring third-party dependencies

272

Time for action-

adding

libcurl

support

for OSG 273

Writing

yourown

plugins

276

Handling

the datastream 278

Timefor action-

designing

and

parsing

a newfile format 279

Serializing

OSG nativescenes 283

Creating serializers

284

Time for action-

creating

serializers for user-defined classes 285

Summary

289

Chapter

11:

Developing

Visual

Components

291

Creating

billboardsina scene 292

Time for action-

creating

banners

facing

you 292

Creating

texts 296

Time for action

-writing

descriptions

for the Cessna 297

Creating

3D texts 300

Timeforaction-

creating

texts in the world space 301

Creating

particle

animations 303

(7)

Table

of

Contents

Time for action-

receiving

and

casting

shadows 311

Implementing special

effects

315

Time

for action-

drawing

the outline of models 316

Playing

withmoreNodeKits 318

Summary

319

Chapter

12:

Improving Rendering Efficiency

321

OpenThreads

basics 322

Time

for

action-

using

a

separate

data receiver thread 322

Understanding

multithreaded

rendering

328

Time for action-

switching

between different

threading

models 328

Dynamic

scene

culling

335

Occluders and occludees 336

Time

for

action-

adding

occludersto a

complex

scene 337

Improving

your

application

341

Time for action-

sharing

textureswithacustomized callback 343

Paging huge

scenedata 347

Making

use of the

quad-tree

348

Time foraction-

building

a

quad-tree

for massive

rendering

348

Summary

357

Appendix:

Pop

Quiz

Answers

35_9_

Chapter

2 359

Dependencies

of

osgviewer

359

The difference between

ALL_BUILD

and 'build all' 359

Chapter

3 360

Configuring

OSG

path options yourselves

360

Releaseasmart

pointer

360

Chapter

4 360

Results of different

primitive types

360

Optimizing

indexed

geometries

360

Chapter

5 361

Fast

dynamic casting

361

Matrix

multiplications

361

Chapter

6 361

Lights

withoutsources 361

Replacements

of built-in uniforms 361

Chapter

7 362

Changing

model positions

in the HUDcamera 362 Anotherway to

display

thesame scene in differentviews 362

Chapter

8 362

(8)

Choosing

the

alpha

setter and the callback 363

Chapter

9 363

Handling

eventswithin nodes 363

Globaland node-related events 363

Chapter

10 363

Getting

rid of

pseudo-loaders

363

Understanding

the inheritance relations 364

Chapter

11 364

Text

positions

andthe

projection

matrix 364

Chapter

12 364

Carefully blocking

threads 364

References

Related documents

Ne bi bilo dobro da student na svako povijesno pitanje odgovara izjavom da je riječ o Božjoj providnosti. Sve dok ne budemo dali najveći mogući doprinos rješavanju svjetovnih

A combination of biological and physical treatment that utilizes biofilm growth on granular activated carbon (BIO-GAC) has advantages for removal of BTEX in addition to other produced

MATC participates in the Wisconsin Retirement System (WRS), which is in much better financial shape than the retirement funds of many other state and local governments. The

Aluminum, Polymers, Glass, Metal Casting, Mining, Steel. Ohio

To convince the readers even further, we provide another trace comparison in Figure 10, again based on the same experimental setup (the Mirage machine using 8 cores for computations,

Using the World Bank’s Enterprise Surveys database, they find that reported constraints reflect country characteristics and vary systematically by level of income—the most

The long run rise in the domestic and foreign real commodity price leads to the striking result that an increase in the growth rate of domestic money supply causes a steady

We use the 1939 distribution of population across cities to calculate the market potential derived by each West German city from markets in East Germany and the regions of Germany