Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 15 Creating 3D Models.

Similar presentations


Presentation on theme: "1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 15 Creating 3D Models."— Presentation transcript:

1 1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 15 Creating 3D Models

2 2 Creating Graphics for VR The synthetic camera model: 1) Define the 3D object(s) in space. 2) Specify lighting, shading and material properties 3) Specify camera properties (position, orientation, projection system, etc). 4) Imaging process: i) Transformation: Put the object in the camera's coordinate system. ii)Clipping: Eliminate points outside the camera's field of view. iii)Projection: Convert from 3D to 2D coordinates. iv)Rasterization: Projected objects represented as pixels in the frame buffer.

3 3 Building 3D models Objects in the computer graphics world are specified by the 3D positions of corners (called vertices). All curves are made up of line segments. All Surfaces are made up of polygons (e.g. triangles).

4 4 Lighting and Shading The physics of light is too complex to compute in real time. Simplified models of lighting and shading are used to make objects appear realistically shaded. Position, color and type of light sources are specified. Material properties indicate color and shininess of the material.

5 5 Specifying Camera and Object Positions Specifying the camera position: The position of the simulated camera relative to the objects in the scene determine what will appear on the screen. Changing the simulated camera position over time gives the appearance of moving around within the scene. Specifying the object position: Objects can be positioned in the 3D world using transformations. The object can be translated, rotated, or scaled.

6 6 Clipping The simulated camera in a graphics system cannot see everything, but has a limited field of view. The region of the synthetic world that the camera can see is specified by the clipping volume. Objects (or parts of objects) that are outside the clipping volume are not rendered in the image. Camera position Clipping Volume Rendered Not Rendered

7 7 Projection and Rasterization The projection converts the 3D model of the world to a 2D image. Different types of projection can be used: Perspective projection: Uses the pinhole camera model to project onto the image plane Orthographic projection: Simply sets the Z value to zero. The lines of projection are perpendicular to the image plane. Rasterization converts the 2D image into a pixelated image stored in the frame buffer. Problems: How do you draw a straight line on a pixelated monitor? How do you fill the inside of a polygon? (What's inside?) How do you keep track of which object is in front of other objects (so you only render the nearest object)?

8 8 Computer Programs and Functions A computer program is a set of step-by-step instructions that tell the computer how to solve a problem or accomplish a task. It is like a recipe. E.g. a recipe to make a cake. A function within a computer program is a named set of instructions to accomplish some piece of the program. The program can simply reference the function name to tell the computer to run all the instructions given in the function. Example: An icing recipe that is referenced by the cake recipe.

9 9 Function Parameters A parameter is a piece of information that the function needs to perform its task. Recipe example: The icing recipe may need to know if its chocolate or vanilla icing. Parameters have types, that tell the computer what kind of information it is. Examples: floatA real number in decimal form, e.g. 1.32 intAn integer, e.g. 14 charAn alpha-numeric character, e.g. 'b'

10 10 OpenGL vertices OpenGL (open graphics language) is a library of functions that perform the tasks required by computer graphics applications. OpenGL defines all objects in terms of vertices (points). 2D shapes are polygons defined by vertices. 3D shapes are groups of polygons. Example: OpenGL commands to draw two 2D points. glBegin(GL_POINTS); glVertex2f(3.0, 2.0); glVertex2f(5.0, 6.0); glEnd(); (3, 2) (5, 6) 2D image plane

11 11 Defining a Vertex A 2D vertex: glVertex2f(GLfloat x, GLfloat y); 2D vertexfloating pointopenGL parameter type (like floating point) A 3D vertex: glVertex3f(GLfloat x, GLfloat y, GLfloat z); Example: A 3D vertex using integer values: glVertex3i(4, 5, 2);

12 12 Connecting the Dots glBegin(GL_LINES); GL_LINES connects pairs of points. (x1, y1) (x2, y2) (x3, y3) (x4, y4) glVertex2f(x1, y1); glVertex2f(x2, y2); glVertex2f(x3, y3); glVertex2f(x4, y4); glEnd();

13 13 Other Drawing functions GL_LINE_STRIP: Connect each consecutive point with previous one. p1 p2 p3 p4 p5 p6 p1 p2 p3 p4 p1p2 p3p4 GL_LINE_LOOP: Same as line strip, except also connects last point with first point. GL_POLYGON: Vertices define the vertices of a polygon. Polygons have special properties that differ from line loops (e.g. you can fill in a polygon).

14 14 Examples Example 1: Draw a connected set of lines. glBegin(GL_LINE_STRIP); glVertex2f(3.0, 2.0); glVertex2f(5.0, 2.0); glVertex2f(5.0, 5.0); glVertex2f(4.0, 5.0); glEnd(); Example 2: Draw a connected line loop. glBegin(GL_LINE_LOOP); glVertex2f(3.0, 2.0); glVertex2f(5.0, 2.0); glVertex2f(5.0, 5.0); glVertex2f(4.0, 5.0); glEnd();

15 15 More Examples Example 3: Draw a polygon glBegin(GL_POLYGON); glVertex2f(3.0, 2.0); glVertex2f(5.0, 2.0); glVertex2f(5.0, 5.0); glVertex2f(4.0, 5.0); glEnd(); Other things that OpenGL can draw are: GL_TRIANGLES (connect groups of 3 points into triangles) GL_TRIANGLE_STRIP GL_QUADS GL_QUAD_STRIP


Download ppt "1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 15 Creating 3D Models."

Similar presentations


Ads by Google