Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
(EOD).Software topics.pdf
Скачиваний:
18
Добавлен:
23.08.2013
Размер:
1.55 Mб
Скачать

page 132

12.4 POLYGON DRAWING

This method bears similarities to the hidden line method. The polygons are still depth sorted, but now polygons are filled, and back facing polygons are removed.

The basic method is as shown below,

Polygons with

 

 

Perform Polygon

 

 

Sort Polygons

 

Outside and

 

 

Transform with

 

 

by Depth

 

 

 

 

 

 

 

 

Color

 

 

Perspective

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Transform

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Remove

Clip

Draw, and fill

overlapping

polygons from

Back Facing

polygons

back to front

Polygons

 

 

• Sorting polygons by depth is basically a function of finding the general center, and then drawing the rear most polygons first.

nj

 

Sj, iz

where,

 

 

 

depthj

= depth of center of polygon j

depthj =

i = 1

 

 

 

------------------

nj =

number of vertices inpolygonj

 

nj

 

 

Sj, iz

=

Screen depth of vertex i in polygonj

• A backfacing polygon can be eliminated by calculating its surface normal. The normal is then compared to the viewing axis. If there is more than 90deg between them the polygon doesn’t need to be drawn. (Note: this method assumes that vertices are defined in a counter clockwise order for the outside surface).

page 133

Nj = ( V2, j V1, j) × ( V0, j V1, j) view = P VRP

projj = Nj view where,

Nj = Normal to outside face of polygon view = view direction vector

projj = The projection of the two vectors

Note: when the proj value is negative, the polygon is back facing and doesn’t need to be drawn.

• The above diagram only talks about overlapping polygons, but penetration is an equivalent problem.

Penetrating

Overlapping

Advantages,

-with color added, objects look more real.

-still relatively easy to implement, and run quickly.

Disadvantages,

-doesn’t suit all computer equipment (eg. laser printers).

-surfaces must have outside defined and surfaces must be closed.

Fill Algorithms generally look at a polygon on the screen, and fill the inside with pixels of a specific color.

Clipping can also be done by a technique called Z-Buffering, using extra graphics memory. An extra byte is used to store the depth of a pixel when it is calculated. If a new pixel is chosen, it

page 134

overwrites the last.

******** Include figure for inside/outside test

12.5 SHADED POLYGONS

This method is identical to the previous method, except a polygon will be filled with pixels of varying color, which makes the object appear more real.

A Light Source(s) is defined for a picture. The light has a specific color, direction, distance, etc.

Ambient light (background, non-direct) also plays a part.

Raster Scan Lines

Light

Ambient

Light

Viewplane

The Light Ray

corresponds with Polygon a pixel on the screen

The color of a pixel will change with the angle of the polygon to the light, the distance from the light, the color of the light, etc.

Advantages,

-the solid begins to look like cartoons, or paintings

-still simple to understand and implement

Disadvantages,

-can be slow

-requires shaded image display capabilities

Many Shading methods can be used to give different approximations of light,

-Goroud shading

-Phong shading

Соседние файлы в предмете Электротехника