View
220
Download
3
Embed Size (px)
Citation preview
Wire-frame Modeling
An application of Bresenham’s line-drawing algorithm
3D models
• Simple objects from the world around us can be depicted as “wire-frame models”
• We make a list of the “key” points (usually corners) on the object’s outer surface and a list of all the lines that connect them
• The “key” points are called “vertices”
• The connecting lines are called “edges”
• We create a file that contains this “data”
Example: the basic barn
10 corner-points (“vertices”) 15 line-segments (“edges”)
3D-coordinates
Front vertices Back vertices
V0=( 0.5, 0.5, 0.5 ) V1=( 0.5, 0.5, -0.5 )
V2=( 0.5, -0.5, 0.5 ) V3=( 0.5, -0.5, -0.5 )
V4=( -0.5, -0.5, 0.5 ) V5=( -0.5, -0.5, -0.5 )
V6=( -0.5, 0.5, 0.5 ) V7=( -0.5, 0.5, -0.5 )
V8=( 0.0, 1.0, 0.5 ) V9=( 0.0, 1.0, -0.5 )
Perspective Projection
• We imagine the computer display screen is located between the wireframe model and the eye of someone who’s viewing it
• Each vertex is “projected” onto the screen
• We use Bresenham’s algorithm to draw line-segments that connect the projections
• A “demo program” will show this effect
The projection
P(x,y,z)
P*(x*,y*,0)
X-axis
Y-axis
Z-axis
Eye of viewer (0,0,D)
View-plane
D = distance of eye from view-plane
Similar Triangles
a
b
c A
B
C
Corresponding sides have proportional lengths
a / A = b / B = c / C
Projection: side-view
P(x,y,z)
P*(x*,y*,0)
View-plane
Z-axisD z
y
y*
By similar triangles:y* / y = D / (D – z)
So y* = y / ( 1 – z / D )
Eye
Projection: top-view
Z-axis
x
x*
D z
P( x, y, z )
P*( x*, y*, 0 ) By similar triangles:x* / x = D / ( D – z )
So: x* = x / ( 1 – z / D )
The projection equations
• Point P( x, y, z ) in 3D-world is “mapped” to pixel P*( x*, y* ) in the 2D-viewplane:
x* = x / ( 1 – z / D )y* = y / ( 1 – z / D )
• Here D is distance of eye from viewplane
Any fixups needed?
• If the projected image is too small or too big, it can be “rescaled”: x’ = x*(scaleX); y’ = y*(scaleY);
• If the projected image is “off-center”, it can be “shifted” (left or right, up or down):
x” = x’+shiftX; y” = y’+shiftY;
animation
• The wire-frame model can be moved (or the viewer’s eye can be moved) to show an object from different viewing angles
• By redrawing a series of different views in rapid succession, the illusion of animation can be achieved
• But erasing and then redrawing a complex object can produce “flickering” that spoils the impression of smooth movements
smooth wire-frame animations
• Advanced hardware techniques can be employed to eliminate any “flickering”
• One such technique is “page-flipping”
• It makes use of the extra graphics VRAM
• But it may require us to learn more about the Super VGA hardware designs
• And here we must confront the issue of graphics “standards” (or the lack thereof)
SuperVGA
The problem of “standards” for enhanced PC graphics hardware
Limitations of VGA
• VGA’s architecture was designed by IBM• It was targeted for IBM’s PC/AT machines• These used Intel’s 8086/8088/80286 cpus• Operating system was PC-DOS/MS-DOS• DOS was built to execute in “real-mode”• So address-space was limited to 1MB• VRAM was confined to 0xA0000-0xBFFFF• Graphics-mode VRAM was only 64KB
VGA Modes 18 and 19
• Design-goals of VGA mode 18: higher screen-resolution (640x480, 4bpp)and “square” pixels (16 colors)
• Design-goals of VGA mode 19: higher color-depth (320x200, 8bpp)and “linear” addressing (256 colors)
• Also “backward compatibility” with CGA/EGA:– CGA mode 6: 640x200, 1bpp (2-colors)– CGA mode 5: 320x200, 2bpp (4-colors)– EGA mode 16: 640x350, 4bpp (16-colors0
IBM competitors
• Others sought a marketing advantage• Their engineers devised ways to get more
colors and/or higher screen-resolutions• Example: 800x600 with 4bpp (16-colors)• Offers “square” pixels and 64K addressing• 800x600=480000 pixels (“planar” memory)• But every competitor did it their own way!• So PC graphics software wasn’t “portable”
VESA
• Video Electronics Standards Association
• An industry consortium to setup standards
• Their idea: provide a uniform programming interface for Super VGAs via the firmware
• Applications would not directly program the incompatible graphics hardware, but would call standard ROM-BIOS functions supplied in firmware by each manufacturer
VESA Bios Extensions v3.0
• Copy of the standards document is online
• It defines a programming interface for the essential and the most-needed functions
• Examples: setting various display-modes, querying the hardware’s capabilities,and enabling SuperVGA
functionalities
• Reading assignment: study ‘vbe3.pdf’