0% found this document useful (0 votes)
56 views19 pages

CG Chapter 3 2

This document discusses computer graphics primitives like polygons. It covers polygon representation, front and back faces, and OpenGL functions for filling polygons. Polygon representations include geometric tables for shape/position data and attribute tables for appearance data like color. Front faces are identified as pointing outward from an object, while back faces point inward. OpenGL uses functions like glBegin and glEnd along with constants to define polygons and fill them with color.

Uploaded by

sefefe hunegnaw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views19 pages

CG Chapter 3 2

This document discusses computer graphics primitives like polygons. It covers polygon representation, front and back faces, and OpenGL functions for filling polygons. Polygon representations include geometric tables for shape/position data and attribute tables for appearance data like color. Front faces are identified as pointing outward from an object, while back faces point inward. OpenGL uses functions like glBegin and glEnd along with constants to define polygons and fill them with color.

Uploaded by

sefefe hunegnaw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 19

Computer Graphics

LECTURE 3

COORDINATE SYSTEMS AND


GRAPHICS PRIMITIVES
Computer Graphics Chapter 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
Polygon Front and Back Faces
 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  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
18

Attributes of Graphics Primitives

Color Attributes
Reading Assignment
Point and Line
Attributes
•Each Group should prepare 20
minutes presentation
Fill area Attribute •Each group member should have a
task to present
Character •I will ask question
Attributes
•It will be out of 10 marks

Aliasing
19

Thank You

You might also like