Module 3
Module 3
3.1 Clipping:
3.1.1Clipping window,
3.1.2 Normalization and Viewport transformations,
3.1.3 Clipping algorithms:
2D point clipping
2D line clipping algorithms:
Cohen-sutherland line clipping
Polygon fill area clipping:
Sutherland Hodgeman polygon clipping algorithm
Where,
T is the translation matrix,
R is the rotation matrix
(a)applying a translation matrix T to move the viewing origin to the world origin, then
(b)applying a rotation matrix R to align the axes of the two systems.
0 1
• Solving these expressions for the viewport position (xv, yv), we have xv = sxxw +
tx, yv = syyw + ty
Scaling: Translation:
P = (x, y)
(50,50)
xmin=50,ymin=50
(50,50)
xmin=50,ymin=50
Left Right
0001 0000 0010
if (!(outcode0 | outcode1))
//logical or is 0 Trivially accept & exit
{
accept = true;
done = true;
}
else if (outcode0 & outcode1)
//logical and is not 0. Trivially reject and exit
done = true;
if (outcodeOut == outcode0)
{
x0 = x;
y0 = y;
outcode0 = ComputeOutCode (x0, y0);
}
else
{
x1 = x;
y1 = y;
outcode1 = ComputeOutCode (x1, y1);
}
intersection point of the polygon edge with the window CASE 1 OUT->IN V1’,V2
border and the second vertex are sent to the next clipper.
CASE 2 IN->IN V2
2. If both input vertices are inside this clipping-window
border, only the second vertex is sent to the next clipper. CASE 3 IN->OUT V1’
CASE 2 IN->IN V2
3’ 2” 1’
CASE 3 IN->OUT V1’
Along y axis
Along z axis Along x axis
A suffix code of i or f is appended to the function name, depending on the data type of the property value
lightName: GL_LIGHT0, GL_LIGHT1, GL_LIGHT2, . . . , GL_LIGHT7
lightProperty: must be assigned one of the OpenGL symbolic property constants
this symbolic constant is used to set two light-source properties at the same time: the light-source
position and the light-source type
Example:
GLfloat light1PosType [ ] = {2.0, 0.0, 3.0, 1.0};
GLfloat light2PosType [ ] = {0.0, 1.0, 0.0, 0.0};
Parameter paramName is assigned an OpenGL symbolic constant that identifies the global property to be set,
and parameter paramValue is assigned a single value or set of values.
globalAmbient [ ] = {0.0, 0.0, 0.3, 1.0);
glLightModelfv (GL_LIGHT_MODEL_AMBIENT, globalAmbient);
turn off this default and use the actual viewing position (which is the viewing-coordinate origin) to calculate
V
18CS62 – Computer Graphics and Visualization. Dr. V 64
.N. Manju, Dept. of CSE, CMRIT, Bangalore.
Texture
patterns are combined only with the nonspecular color, and then the two colors are combined.
We select this two-color option with
glLightModeli (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR);