0% found this document useful (0 votes)
26 views

Chapter - TwoPartTwo

This document discusses polygons and polygon rendering in computer graphics. It describes polygons as fill-area primitives that are used to represent 2D shapes with boundaries formed by connected line segments. It discusses different types of polygons including simple, convex, concave, and degenerate polygons. It also describes how polygons are represented and rendered in OpenGL using functions like glBegin and glEnd along with constants that specify drawing modes like GL_POLYGON, GL_TRIANGLES, and GL_QUADS. Normal vectors are also discussed as important for determining polygon front and back faces.

Uploaded by

Abdurezak Ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Chapter - TwoPartTwo

This document discusses polygons and polygon rendering in computer graphics. It describes polygons as fill-area primitives that are used to represent 2D shapes with boundaries formed by connected line segments. It discusses different types of polygons including simple, convex, concave, and degenerate polygons. It also describes how polygons are represented and rendered in OpenGL using functions like glBegin and glEnd along with constants that specify drawing modes like GL_POLYGON, GL_TRIANGLES, and GL_QUADS. Normal vectors are also discussed as important for determining polygon front and back faces.

Uploaded by

Abdurezak Ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 18

Computer Graphics

DEPARTMENT OF COMPUTER SCIENCE

CHAPTER TWO – PART TWO


GRAPHICS PRIMITIVES
Computer Graphics Chapter Two, Part Two
2

Polygons

Polygon
Representation

Polygon Faces

OpenGL Fill-Area
Functions
3
Polygons
 Fill-area primitives (Polygons):
 Any enclosed boundary
 Filled by solid color or
Polygons
pattern
 2D shapes with boundary
Polygon formed by connected
Representation straight line segments
 Need ≥3 coplanar points

Polygon Faces  Coplanar points:


 Points placed in the same

OpenGL Fill-Area plain


Functions  Simple or Standard Polygons:
 Polygons with no edge
crossing
 Polygonal Meshes:
 Approximate curved
surfaces by forming a
network of polygons
4
Convex Polygons
 All interior angle <= 180o
 Used by many graphics

Polygons package
 More efficient to fill a polygon
 Convex?
Polygon
Representation
 Check interior angles
 
 Check the infinitely extended edge
N  u E1 E2 sin 
 Check the cross product of pair of
Polygon Faces adjacent edge.

Concave Polygons
OpenGL Fill-Area  At least 1 interior angle>180o
Functions

Degenerate Polygon
The polygon has less than 3 vertices; or
The polygon has collinear vertices; or
The polygon has non-coplanar vertices; or
The polygon has repeated vertices.
5
Splitting Concave Polygons-Vector
Technique
Compute the cross product of the
Polygons edges
Polygon
If it has different sign
Representation  Extend the first edge of the pair till it
intersect to one of the other edges
Polygon Faces  Split the polygon in to two
 From the intersecting point
OpenGL Fill-Area
Functions
6
Polygon Representations

Polygons

Polygon
Representation

Polygon Faces
Using two types of table of data
OpenGL Fill-Area  Geometric tables
Functions  Store geometric information
 like shapes and positions of the polygons
 Attribute tables
 Stores appearance information
 like color and opacity
7
Polygon Front and Back Faces
 Polygons as a part of 3D polygonal meshes
 Front face: points outward from the object
Polygons
 Back face: points twards the object interior

Polygon
Representation

Polygon Faces

OpenGL Fill-Area
Functions
8
Polygon Front and Back Faces
 Polygons Normal vector :
 A vector perpendicular to the plane of the
Polygons
polygon
 Points away from the front face of the
Polygon
polygon
Representation

Polygon Faces

OpenGL Fill-Area
Functions
9
Computing Normal Vectors
 Graphics packages compute the Normal Vector
automatically
 By computing cross product of adjacent edges
Polygons  Cross product is a vector perpendicular to the
two vectors
Polygon  Considering the vertices
Representation  anti-clockwise : normal vector points towards
us
Polygon Faces  Clockwise: normal vector points away from us
E1 = (1,0,0)
E2 = (0,1,0)
 
OpenGL Fill-Area 
N  (0,0,1) N  u E1 E2 sin 
Functions
0 ≤ θ ≤ 180o
direction of the unit vectoru is
determined by the right-hand
rule
10
OpenGL Fill-Area Functions
All polygons must be convex
Polygons Vertices should be given in anti-

Polygon
clockwise direction
Representation  We are watching it from outside of the
object
Polygon Normal
Vectors Default fill style is solid
 By the given color settings
OpenGL Fill-Area
Functions 7 ways of drawing polygons
 Using glRect* function
 Using 6 different symbolic constants
with glBegin .... glEnd
11
OpenGL Fill-Area Functions 1.

Polygons

Polygon
Representation

Polygon Normal
Vectors

OpenGL Fill-Area
Functions glRecti(200,100,50,250);

Front face is away from


the camera
12
OpenGL Fill-Area Functions 2.
glBegin(GL_POLYGON);
glVertex2iv(p1);
Polygons glVertex2iv(p2); Front face is towards the
glVertex2iv(p3); camera . The points are
Polygon glVertex2iv(p4); given in anti-clockwise
Representation glVertex2iv(p5);
glVertex2iv(p6);
Polygon Normal glEnd();
Vectors

OpenGL Fill-Area
Functions
13
OpenGL Fill-Area Functions 3.
glBegin(GL_TRIANGLES);
glVertex2iv(p1);
Polygons Front face is towards the
glVertex2iv(p2);
glVertex2iv(p6); camera . The points are
Polygon glVertex2iv(p3); given in anti-clockwise
Representation glVertex2iv(p4);
glVertex2iv(p5);
Polygon Normal glEnd();
Vectors

OpenGL Fill-Area
Functions
14
OpenGL Fill-Area Functions 4.
glBegin(GL_TRIANGLE_STRIP);
glVertex2iv(p1);
Polygons
glVertex2iv(p2);
glVertex2iv(p6);
Polygon glVertex2iv(p3);
Representation glVertex2iv(p5); The points for only first
glVertex2iv(p4); triangle are given in anti-
Polygon Normal glEnd(); clockwise
Vectors

OpenGL Fill-Area
Functions
15
OpenGL Fill-Area Functions 5.

glBegin(GL_TRIANGLE_FAN);
Polygons glVertex2iv(p1);
glVertex2iv(p2);
glVertex2iv(p3); The first point of the first
Polygon
glVertex2iv(p4); triangle is the beginning
Representation
glVertex2iv(p5); of the fan. points are
glVertex2iv(p6); given in anti-clockwise
Polygon Normal glEnd();
Vectors

OpenGL Fill-Area
Functions
16
OpenGL Fill-Area Functions 6.
glBegin(GL_QUADS);
glVertex2iv(p1);
Polygons
glVertex2iv(p2);
glVertex2iv(p3);
Polygon The quadrilateral points
glVertex2iv(p4);
Representation are given in anti-clockwise
glVertex2iv(p5);
glVertex2iv(p6);
Polygon Normal glVertex2iv(p7);
Vectors glVertex2iv(p8);
glEnd();
OpenGL Fill-Area
Functions
17
OpenGL Fill-Area Functions 7.

glBegin(GL_QUAD_STRIP);
Polygons glVertex2iv(p1);
glVertex2iv(p2);
glVertex2iv(p3); The first quadrilateral
Polygon glVertex2iv(p4);
Representation points are given in anti-
glVertex2iv(p5); clockwise
glVertex2iv(p6);
Polygon Normal glVertex2iv(p7);
Vectors glVertex2iv(p8);
glEnd();
OpenGL Fill-Area
Functions
Any Question?

You might also like