Escolar Documentos
Profissional Documentos
Cultura Documentos
3.1
3.2
3.3
3.4
3.5
3.6
3.7
3.8
3D Shape Representations
Modelling and Animation Tools
Blender An Open Source Modelling and Animation Tool
Rendering 3D objects using OpenGL
Computing occlusion of 3D objects: The Depth Buffer
Colouring 3D objects: Vertex Colours
Shading 3D objects: Shading with OpenGL
Backface Culling
Polygonmesh
Parametric Surface
Subdivison Surface
Implicit Surface
Advantages
Disadvantages
Defined as function
p(s,t)=(x(s,t), y(s,t), z(s,t))
Direct definition is difficult, so in
general surfaces are defined using
control points, e.g. Bezier Surfaces,
NURBS (Non-Uniform Rational BSpline) surfaces.
Advantages
Disadvantages
Advantages
Disadvantages
http://www.uvmapper.com/sds.gif
2014 Burkhard Wuensche
Advantages
Disadvantages
http://de.wikipedia.org/wiki/
Constructive_Solid_Geometry
and animated.
A variety of rendering tools to create fast previews and
photorealistic images (movies) of a scene.
2014 Burkhard Wuensche
10
Maya (Autodesk)
3D Studio Max (Autodesk)
Houdini (Side Effects Software)
LightWave 3D (NewTek)
Softimage (Autodesk)
Applications in engineering and architecture use
specialised tools (e.g. AutoCAD, SolidWorks)
11
Storyboard
Modelling
Animation
Keyframing (motion capture and/or human
animator)
Physically-based animations
Post-Production
Special effects, sound,
12
http://www.cs.auckland.ac.nz/~jli023/opengl/blender3dtutorial.htm
We will use Blender for assignment 2
Experimenting with Blender will improve
your 3D perception and your understanding of
modelling and rendering techniques and 3D
transformations.
In this lecture we learn many of the
techniques implemented in Blender (e.g.
polygon rendering, ray tracing, Bezier curves,
lighting and materials, 3D transformations, )
13
14
15
3
7
0
Note: all face
vertices are defined
anti-clockwise
16
17
void init(void)
{
// select clearing color (for glClear)
glClearColor (1,1,1,1);
// RGB-value for white
// enable depth buffering
glEnable(GL_DEPTH_TEST);
// initialize view (simple orthographic projection)
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(33,1,2,8);
trackball.tbInit(GLUT_LEFT_BUTTON);
}
void reshape(int width, int height ) {
// Called at start, and whenever user resizes component
int size = min(width, height);
glViewport(0, 0, size, size);
// Largest possible square
trackball.tbReshape(width, height);
}
2014 Burkhard Wuensche
18
19
20
21
z far
z near
v
n
x
u
22
23
Rather than having each face a fixed colour, we can set each
vertex to a different colour.
If we set the (R,G,B) colour of each vertex of the unit cube to
equal its spatial coordinates, we draw the RGB Colour Cube
Main output loop in display becomes:
for (int i=0; i < numFaces; i++) {
const int* face = faces[i];
glBegin(GL_POLYGON);
for (int vIndex=0; vIndex<numFaceVertices; vIndex++)
{
glColor3fv(vertices[face[vIndex]]);
glVertex3fv(vertices[face[vIndex]]);
}
glEnd();
}
24
each colour
yellow
(1,1,0)
green
(0,1,0)
cyan
(0,1,1)
black
(0,0,0)
blue
(0,0,1)
white
(1,1,1)
red
(1,0,0)
magenta
(1,0,1)
VISIBLE colours
2014 Burkhard Wuensche
25
C p C A C B CC
B
2014 Burkhard Wuensche
area ( p BC )
area ( ABC )
area ( p CA )
area ( ABC )
area ( p AB )
area ( ABC )
26
1 unit
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
z
float x,z,theta;
x
glBegin(GL_QUAD_STRIP);
for (int segment=0; segment <= NUM_SEGMENTS; segment++){
theta=2.0f*Pi*(float) segment/(float) NUM_SEGMENTS;
x = (float) cos(theta);
// x = r cos(theta), and r = 1
z = (float) sin(theta);
// z = r sin(theta)
N=(x,0,z)
glVertex3f(x,-1, z); glVertex3f(x,1,z);
}
Note: The figure shows an example with 5 segment.
glEnd();
glFlush (); glutSwapBuffers();
27
surface
element
28
glShadeModel(GL_FLAT);
glBegin(GL_QUAD_STRIP);
for (int segment=0; segment <= NUM_SEGMENTS; segment++)
{
theta=2.0f*Pi*(float) segment/(float) NUM_SEGMENTS;
x = (float) cos(theta); // x = r cos(theta), and r = 1
z = (float) sin(theta); // z = r sin(theta)
glVertex3f(x,-1, z);
glVertex3f(x,1,z);
theta=2.0f*Pi*((float) segment+0.5f)/(float) NUM_SEGMENTS;
x = (float) cos(theta);
z = (float) sin(theta); // if defining individual polygons specify
glNormal3f(x,0,z);
// one normal for each polygon
}
glEnd();
2014 Burkhard Wuensche
29
glShadeModel(GL_SMOOTH);
glBegin(GL_QUAD_STRIP);
for (int segment=0; segment <= NUM_SEGMENTS; segment++)
{
theta=2.0f*Pi*(float) segment/(float) NUM_SEGMENTS;
x = (float) cos(theta); // x = r cos(theta), and r = 1
z = (float) sin(theta); // z = r sin(theta)
glNormal3f(x,0,z);
// Usually define one normal for each vertex. Here the
// Here the same normal is used for both
glVertex3f(x,-1, z);
// the top vertex and
glVertex3f(x,1,z);
// the bottom vertex
}
glEnd();
30
31