# 3D openGL

3D OpenGL

Introduction

Topics
:

3D graphic modeling approach

1.

Hierarchical approach

2.

Drawing 3D models
using
:

2
D

surface

Volume

Function

approximations

3.

Matrix approach
:

3D points

Homogenous
coordinates

Matrix Multiplication

Affecting models

Communicating

with hardware
by
using a state machine:

1.
The sequence of displaying
a 3D point
.

2.
Projection mod
e

view port definition
.

3.
View mod
e

placing world
models
.

OpenGL drawing tools

1.
Drawing 3D models

2.
3D realization tools

3D drawing graphic
-

3D graphic
:

M
odeling approach

1.

Hierarchical approach

In order to

handle

complex model
we will split
it in
to
small

and

basic
models
.

Each

of these models
is
drawn with
respect to the origin
(0,0,0)
.

Using the basic models, we
will
compose

the required complex
model
by positioning the basic
models with respect to the center of
the final model.

2.
Common methods for 3D
modeling
:

Basic
3D models
approximations

sphere, to
r
us

2
D

surface

way
meshes

dragon
statue
surface

Volume

human
brain

MRI

un
pre
pared
cut

Function
approximations

waving flag

animation

3.
Positioning by m
atrix
approach:

3D points

As
vectors (x,y,z).

Homogenous
coordinates

3D
points with a forth
coordinate of which
value is equal to 1.

Matrix Multiplication

Using
homogenous coo
rdinates, each
composition of

geometrical
function
s
, such as

rotate

,
“scale”

and

translate

, is
expressible as a
multiplication of

the function’s corresponding
matrices.

Affecting models

If a complex
model is represented by a
composition of basic m
odels and
their respected matrices, and we
want to apply geometrical
functions to that model, we may
manipulate the complex model by
apply
ing

a single matrix to all of
the basic models of which th
e
complex model is comprised.

Communicating
with hardware b
y
using a state
machine:

1.
The sequence of displayin
g a
3D point

A point undergoes
two major stages before
presented on the screen: The
modeling stage, in which it is
applied by the current
modeling matrix.

In the
second stage, the Projection
stage, the mo
dified point is
projected to the screen by the
current projection matrix.

2.
Project
ion mode

view port
definition

The graphic
hardware contains a matrix
which is used to project 3D
points onto the screen.

We
can modify this matrix while
in the “Projection
” state.

In
or
der to enter this state, we
use the
glMatrixMode
(
GL_PROJECTION)

command in the draw
function. In this state, we can
use the following commands:

Initiate the
current state

matrix into the
identity matrix.

glFrustum(…)

mult
iplies
the current projection matrix
with a
perspective

matrix
built according to the
parameters given.

glOrthogonal(…)
-

multiplies
the current projection matrix
with an orthogonal

projection

matrix built according to the
parameters given.

3.
Vi
ew mode

pla
cing world
models
-

The graphic
hardware contains a matrix
which is used to position 3D
points before the use of
projection. We can modify
this matrix while in the

Model View
” state. In order
to enter this state, we use the
glMatrixMode
(
GL_MODELVIEW
)

comm
and in the draw
function. In this state, we can
use the following commands:

Same as
before.

glRotate, glTranslate, glScale

fun
ctions for modifying the
current state matrix a
ccording
to the given operation and
parameters.

NOTE: Using
th
ese functions in projection
mode is for manipulating the
camera position, while using
them in Model View mode is
for manipulating the model
itself.

glVertex3f

send a point to
the hardware.

This command
should be inside the glBegin
hierarchy, as studied.

glPushMatrix(),glPopMatrix()

the
hardware holds a stack, you may use it
to save an achieved matrix you
will
use
in the future. (
F
or example
save the
matrix that represents

the complex
model
center
position
.

Use it to return
the start position before you
multiply
the
each

simple part matrix)

OpenGL drawing
tools
:

Drawing 3D models

Depth
test

depth buffer

Coloring

color buffer

Polygon face

left hand basic rule

3D realization tools

Light

o

o

Normal

o

Material properties

o

Ray tracing

Image reflecting

3D drawing
graphic
-

Textures

Project texture to model

Project model to texture

Bump map

Polygons normal
randomization

Bump map & Texture

Animating

Parametric surface

Geometrical error functions

Level of De
tail approach

Occlusion Culling

Hardware occlusion culling

LOD & occlusion culling