440 likes | 590 Views
CSCI 346. Chapter 1 and Chapter 2 Graphics Systems and Models And Graphics Programming. Agenda. Homework - assignment 2 is due Friday 02/01/2002 Finish chapter 1 and start chapter 2. Homework 2. Convert your 2D object from program 1 to a 3D object. Center it well in your 3D window.
E N D
CSCI 346 Chapter 1 and Chapter 2 Graphics Systems and Models And Graphics Programming
Agenda • Homework - assignment 2 is due Friday 02/01/2002 • Finish chapter 1 and start chapter 2
Homework 2 • Convert your 2D object from program 1 to a 3D object. • Center it well in your 3D window. • Use a meaningful window name (not "Susan's picture"). • Remember to document your code. • Movement is not required for this assignment. • Review your code before you submit it. If you see repeated chunks of code, create a function and use it. • Display it using an orthographic projection. • Use my program named 3D picture linked from the bottom of the syllabus as a guide. • This program’s source code is due before next week’s class 02/01/2002.
glOrtho (GLdouble left, GLdouble right, GLdouble, bottom, GLdouble top, GLdouble near, GLdouble far) • Creates a viewing volume with a box shape. • Direction of projection is parallel to z axis. • Viewpoint faces -z axis. • glOrtho (0.0, (GLdouble) w, 0.0, (GLdouble) h, -500.0, 500.0);
Imaging Systems • The human vision system • Pinhole camera • Synthetic camera model
The Human Vision System • Very complex • Light enters the eye through the lens and the cornea • Iris opens and closes to regulate amount of light • Lens forms an image on the retina • Rods and cones are on the retina and are the light sensors and excitable by the visible light spectrum
Color • Color results from the interaction of light with the nervous system • Lens • Retina • Color processing unit along the optic nerve
Lens • Focus the incoming light on the retina, which contains the photo receptors • Lens must adjust to the focal length of the wavelength • Red has the longest focal length • Blue has the shortest focal length
Lens • Focus the incoming light on the retina, which contains the photo receptors • Chromostereopsis • Lens absorbs light, (blue = 2x red) • Fluid between the lens and the retina also absorb light
Retina • Photo receptors that absorb photons and transmit chemical signals to the brain. • Rods. • Night-vision receptors. • No color dependency. • Cones. • Color senstitivity. • Require a higher level of light intensity than the rods. • Clustered in the center of retina,
Retina • We see objects by edge detection, where an edge can be created by a difference in color or brightness or both. • Photoreceptors adjust their sensitivity to the overall light level. • There is also a required minimum intensity level for the photoreceptors to respond.
The Human Vision System • Resolution • The measure of what size objects we can see • How close we can place two points and they remain distinct • Intensity • Physical measure of light energy • Brightness • Measure of how intense we perceive the light to be
The Human Vision System • VERY complex • Automatic and instantaneous • Pattern recognition • Depth perception
Pinhole Camera • Simple model • Box • Small pin hole at one side • Film at the opposite side
Pinhole Camera • Field or angle of view of the camera is the angle made by the largest object that our camera can image on its film plane • Ideal pinhole camera has an infinite depth of view -- every point in the field of view is in focus
Pinhole Camera • Problems with pinhole camerathe pinhole • The pinhole • Cannot adjust field of view
Sophisticated Cameras • Lens replaces a pinhole • Larger lenses admit more light • Choosing a lens with the proper focal length • Equiv to choosing d for the pinhole camera • The angle of view can vary up to 180 degrees • Objects in the field of view may or may not be in focus
The Synthetic Camera Model • Equivalent views of image formation
The Synthetic Camera Model • Imaging system in figure 1.17bellows camera • Object and viewer are specified separately
The Synthetic Camera Model • Image or projection plane in front of the lens • Image of the point on the object is located where the projector passes through the projection plane • Limited size of the image • Angle of view describes the limitation • A clipping rectangle placed in the image plane to limit the size of the image • Blinders on a horse • Underwater goggles • Window into the world
Computer Graphics Programmer’s Interface • Paint program • User friendly interface • Point and click, no programming • Application programmers interface (API) • Interface between an application program and a graphics system can be specified by graphics functions that reside in a graphics library. Specs called API
Computer Graphics API - Specify • Objects • Vertices • Set of primitives • Viewer position • Center of projection (center of the lens) • Orientation -- may be rotated about the origin (center of projection or center of the lens) • Focal length - the size of the image on the film plane • Film plane -- back of the camera has a height and width
A Sequence of Images • Line drawing of a scene • wireframe • Flat shading • One light source & flat shading • One light source & smooth shading • Texture
Modeling and Rendering • Modeling • Rendering • Sometimes it is good to separate the modeling of a scene from the production of the file (example : ray tracing)
Pipeline Architectures • Pipeline architectures • Benefit • Translates well to computer graphics • Four steps to producing an image • Transformer • Clipper • Projector • rasterizer
Chapter 2 • Graphics Programming
Sierpinski Gasket • Pre-Mandelbrot classic • Found by W. Sierpinski around world war I • Generated by recursively dividing a triangle into four congruent smaller triangles • Think of the interior triangles as "holes” • They occupy more and more of the total area, while the "solid" portion becomes as hopelessly fragile
Pseudocode 1. Pick a point at random inside the triangle 2. Select one of the three vertices at random 3. Find a point halfway between the initial point and the randomly selected vertex 4. Display this new point by putting some sort of marker, such as a small circle, at its location 5. Replace the initial point with this new point 6. Return to step 2
Pen Plotter • moveto(x,y) • lineto(x,y)
Problems With Pen-plotter Model • 3D difficult • Must convert 3d world to 2d projection explicitly • OpenGL allows us to focus on building 3D world and let computer handle projections
Display Funtion void display( void ){ typedef GLfloat point2[2]; /* define a point data type */ point2 vertices[3]={{0.0,0.0},{250.0,500.0},{500.0,0.0}}; /* A triangle */ int i, j, k; long rand(); /* standard random number generator */ point2 p ={75.0,50.0}; /* An arbitrary initial point */ glClear(GL_COLOR_BUFFER_BIT); /*clear the window */ /* computes and plots 5000 new points */ for( k=0; k<5000; k++) { j=rand()%3; /* pick a vertex at random */ /* Compute pt halfway between vertex and old point */ p[0] = (p[0]+vertices[j][0])/2.0; p[1] = (p[1]+vertices[j][1])/2.0; /* plot new point */ glBegin(GL_POINTS); glVertex2fv(p); glEnd(); } glFlush(); /* clear buffers */ }
Coordinate System 3D COORDINATE SYSTEMS Y Y Z X X LEFT HANDED RIGHT HANDED Z
Coordinate System in OpenGL • What units are x, y, and z? • Your choice • Device independent • World coordinate system • Before displaying on output device, world coordinates must be converted to device or raster or screen coordinates
Point To Remember • We are studying computer graphics • We are not studying OpenGL • Won’t cover all functions in OpenGL
Graphics System As a Black Box Function Calls Output User Program Graphics System Input/Output Devices Data Input
API Functions • Primitive functions • Attribute functions • Viewing functions • Transformation functions • Input functions • Control functions
3 D Gasket • Use tetrahedons
OpenGL - What Is It? • A graphics rendering library • API to produce high-quality, color images from geometric and raster primitives • Window system and operating system independent • OpenGL “doesn’t do windows”
OpenGL • Most widely adopted graphics standard • Introduced in 1992 • High visual quality and performance • Industry standard • Stable • Reliable and portable • Evolving • Scalable • Easy to use • Well-documented
Related APIs • GLU (OpenGL utility library) • Guaranteed to be available • tesselators • Quadrics • NURBs, etc • Some surprisingly common operations, such as projection transformations (such as gluPerspective)
Related APIs • GLX or WGL • Bridge between window system and OpenGL • Glut • Portable bridge between window system and OpenGL • Not “standard”, but uniformly popular
Homework • Finish reading chapter 2 - ICG • Graphics programming • Assignment 2 - program due 02/01/2002