# Scene Graphs

Λογισμικό & κατασκευή λογ/κού

13 Δεκ 2013 (πριν από 4 χρόνια και 6 μήνες)

108 εμφανίσεις

Pre
-
Test Results

Total Points:

75 pts

Pass (2/3)

50 pts, 66%

Took Pretest:

26 out of 40 students

Passed:

15 students (out of 26), 57%

Class Average:

45 pts

pass line: 50 pts

#

students

By Category

score

%

pass line

66 %

By Question

66% = pass

Q1 Which of the following is not an OpenGL primitive?

Q2 Which equation best describes specular lighting?

Q3 Which of the following interpolates the surface normal?

Q4 Which of the following gives correct silhouette shape?

Q5 Which of these commands can be placed inside glBegin/E?

Q6 What is the process of converting a polygon to pixels?

Q7 When defining a texture, which do you need?

Q8 Which of the following gives a yellow color?

Q9 What does an illumination model describe?

Q10 How many polygons in a tesselated cube?

Q11 What is the equation for diffuse lighting?

Q12 Short code to setup lighting in OpenGL?

Q13 Describe the surface normal?

Q14 Short code to render corners of a cube as points?

Q15 Two problems associated /w texture mapping?

Q16 How do you compute the surface normal on a sphere?

Pre
-
Test Conclusions

-

Final exam will be same level of difficulty!
Not same questions.

Note: Pre
-
no
math questions at all. The hardest was 6*4 = 24

You
might

be asked to calculate something in final exam.

-

Entire class needs to study to keep above 66%
(50 pts).

-

If you were in 50s, studying will put you
safely
above passing, and

additional studying puts you in reach of a good score.

-

If you were in 40s, you
need
to study to pass the final.

-

If you were in 20s/30s, you
must study hard

-
test will indicate which questions to focus on. )

-

Overall focus areas are
OpenGL
and Texturing.

You
must
know:

glEnable

glLightfv / glMaterialfv

glVertex3f / glColor3f / glNormal3f / glTexCoord3f

glBegin..glEnd

Scene Graphs

Department of Architecture and Media Technology

R. Hoetzlein

How do we represent a dynamic scene with moving parts?

Motivation:

Car in OpenGL

Wheels are attached to body..

All wheels should turn..

However..

Front wheels should turn

together for steering..

Car should move forward..

Wheels need to stay attached !

Reference Frames

0 1 2 3 4 5 6

Scene Graphs

Sample problem #1:

A ball is thrown inside a subway train which is 6 m long.

The ball starts at 1m, and ends at 5 m, after 2 secs.

What is the
local
position of the ball a 1 sec?

What if the train is moving at 2 meters/sec?

0 1 2 3 4 5 6

0 1 2 3 4 5 6 7 8 9 10

What is the
global

position of the ball, seen from
outside
the train?

Local Coordinates

Time 0

0 m

1 m

Time 1

2 m

3 m

Time 2

4 m

5 m

World Coordinates

Time 0

0 m

1 m

Time 1

2 m

5 m

Time 2

4 m

9 m

Train

Ball

relative to ground

relative to
train

What is the
speed
of the ball in the train?

What is the
speed
of the ball relative to the ground?

Local Coordinates

The position and orientation of an object

relative to another object.

World Coordinates

The position and orientation of an object

as it resides in a global space.

Albert Einstein (Theory of Relativity)
:

There is not absolute frame of reference.

The most common one in graphics: the Earth.

In astronomy, the Earth is moving.

Scene Graphs

Another example: How do we position robot arms?

50 deg

attached

40 deg

50 deg

40 deg

-
70

o

-
70

o

First joint: Angle changes

40 deg
to

50 deg

Second joint:
Relative
angle is the same. 70 deg

Absolute
angle changes.

50 deg

40 deg

0 deg

First joint: Angle changes

40 deg
to

50 deg

Second joint:
Relative
angle is the same. 70 deg

Absolute
angle changes.

0 deg

-
20 deg

-
30 deg

Local Angle

Time 0

40 deg

-
70 deg

Time 1

50 deg

-
70 deg

World Angle

Time 0

40 deg

-
30 deg

Time 1

50 deg

-
20 deg

Arm #1

Arm #2

relative to ground relative to Arm #1

Notice:

Angles can also be relative !

Local angle may stay fixed.

If parent object rotates, world angle will still change.

Observation:

The motion of objects is bound to the
parent object.

Thus, we can describe the motion of an object

as a
compound transformation
of the local and parent objects.

Car body

Wheels

OpenGL:

V

glTranslatef ( x, 0 ,0 );

M
car

glTranslatef ( 2, 0 ,0 );

M
wheel

glRotatef ( 45, 0, 0 );

Compound Transformation:

P’ = V M
parent

M
child

p

Example:

P’ = V M
car
M
wheel

p

Compound Transformation:

P’ = V M
parent

M
child

p

Example:

P’ = V M
car
M
wheel

p

M
car

= T (
d
, 0, 0 ) = [ 1 0 0 0

0 1 0 0

0 0 1 0

x 0 0 1 ]

M
wheel

= T( 1, 0, 0 ) R(
θ

) = [ cos
θ

-
sin
θ

0 0

sin
θ

cos
θ

0 0

0 0 1 0

0 0 0 1 ]

d

θ

[ 1 0 0 0

0 1 0 0

0 0 1 0

1 0 0 0 ]

What is M
total
?

Scene Graphs

A language

for describing the transformation, materials or other

properties of objects by expressing them in a tree or graph.

Scene graphs are
descriptive
, as opposed to
imperative.

C/C++, OpenGL are imperative languages:

OpenGL does
not
support scene graphs.

OpenGL is command
-
based.

Immediate mode
libraries such as IRIS OpenGL [3],

StarbaseTM [8], and RenderManTM [ 101 provide a set
of drawing commands that can be used by applications
to create visual representations of modeled 3D objects.

Display lists
are used by packages such as GKS [4]
and PHIGS+ [7] (and, to a lesser extent, some
immediate mode libraries) to collect drawing commands
into simple linear lists. Neither of these approaches
truly exploits any correlation between modeled objects,
such as chairs and airplanes, with the commands used
to represent them visually;

By using object
-
oriented techniques, IRIS Inventor is

able to provide a higher level of 3D graphics
programming to application developers, compared to
conventional 3D libraries.

IRIS Inventor

Paul Strauss, SGI, 1993

Cosmo 3D, 1990s

IRIS Performer

A High
-
Performance Multiprocessing Toolkit for Real
-
time Graphics

John Rohlf, James Helman (SGI), 1996

Scene graph allows similar objects to be
grouped
for performance.

Group: those outside camera, those with same texture, those part of same object

Scene Graphs

In practice

Scene Graphs

In practice

Tank

Turret

Transformation

graph

Tank

Turret

Construction

graph

box

curve

box

cylinder

Turret

Steel

Rubber

Tank

Material graph

Turret

Tank

Motion graph

Engine

affixed
to tank)

(turret is
constructed
from box and cylinder)

(tank & turret are metal, tread is

rubber)

causes
the tank to move)

Maya Hypergraph

Maya Hypergraph

Complex character

Granted, it is probably impossible to find a single perfect organization for a
scene graph that simultaneously optimizes for spatial, state, semantic,
and CPU considerations. Some people try to hand
-
design theirs to
straddle the fence and make the best of what they have. But a better idea
is to remove one of the fundamental constraints: that there need be a
single scene graph organization for a given visual database.

Bar
-
Zeev, Avi.
Scene Graphs: Past, Present and Future
, 2007

Game Engines

Most use a
transformation graph
, since mostly concerned with animation.

Rendering

Rendering systems use a
, since mostly concerned

with visual appearance.

Houdini

Procedural systems use a
functional graph
, since they are mostly concerned

with complex, dynamic geometry and motion.

Lab #9:

Animate a
moving car
in OpenGL.

1) Draw the body and wheels with glutSolidCube and glutSolidCylinder.

2) Use glTranslatef to position the body of the car.

3) Use glRotatef to orient the wheels of the car.

4) See if you can get the wheels to
stay attached
to the car.

Ideally: Car moves forward.

Wheels rotate over time.

User can control
steering
of the car.