Address 5.


85 views
Uploaded on:
Category: Food / Beverages
Description
Address 5 Rendering 3D graphical primitives 3D Rendering Case: 3D Rendering Pipeline 3D Rendering Pipeline Rendering How to render in various modes to get either a strong or a laid out article? OpenGL permits both sides of an article to be rendered in an alternate mode.
Transcripts
Slide 1

Address 5 Rendering 3D graphical primitives

Slide 2

3D Rendering Example:

Slide 3

3D Rendering Pipeline

Slide 4

3D Rendering Pipeline

Slide 5

Rendering How to render in distinctive modes to get either a strong or an illustrated article? OpenGL permits both sides of an article to be rendered in an alternate mode. Sample: render a square strong on the front, and delineated on the back. An inquiry shows up: “How does OpenGL know which side of an article is the front?” Rule: OpenGL expect that anything attracted counter-clock-wise heading is the front side as a matter of course.

Slide 6

Example: project section drawing a red square with front strong and back delineated glPolygonMode( GL_FRONT, GL_FILL ); //Front filled glPolygonMode( GL_BACK, GL_LINE ); //Back Outlined glColor3f( 1.0, 0.0, 0.0 ); glBegin( GL_QUAD ); /Square drawn counter clockwise glVertex2d( - 1.0, - 1.0 ); glVertex2d( 1.0, - 1.0 ); glVertex2d( 1.0, 1.0 ); glVertex2d( - 1.0, 1.0 ); glEnd(); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );/return the drawing mode

Slide 7

Example: system piece drawing a red square with front strong and back laid out Notice that the focuses are requested from the base left to the upper left in a counter-clock-wise bearing. This implies that we will never see the layout back unless we turn the camera.

Slide 8

GLFrontFace(): changes the default run A call to glFrontFace( enum Mode ) can change the default counter-clock-wise front confronting polygons to back confronting. The acknowledged Modes are GL_CCW for counter-clock-wise, and GL_CW for clock-wise front confronting polygons. This capacity is once in a while utilized, however may be helpful for porting applications from diverse realistic situations. For instance, Microsoft’s DirectX uses clock-wise as front confronting. For this situation, making a call to this capacity may be less demanding than reordering the vertices\' position.

Slide 9

void glCullFace (enum Mode); Culling is a term in three-dimensional representation that implies not drawing. At the point when an item is attracted to the screen, all vertices are mapped to where they would be on the screen regardless of the fact that they are not going to be seen. On the off chance that it is not important to draw a face of an item, calling the glCullFace capacity will spare rendering in the event that you realize that a face won\'t be seen. The conceivable Modes connect to the object\'s characteristics. They are GL_FRONT, GL_BACK, and GL_FRONT_AND_BACK. Keeping in mind the end goal to utilize this capacity, you must empower the separating with a call to glEnable( GL_CULL_FACE ).

Slide 10

Hidden Surface Removal How does OpenGL know what items are before different articles? Accept, two articles are rendered. Object 1 is behind article 2 and item 2 is somewhat clouding item 1. The presentation capacity would draw the item 1 first and after that protest 2. Suppose it is possible that the camera pivoted 180 degrees behind item 1. Presently the tables are turned, and object 1 is in front with the regards to the camera. In the event that the items are attracted the same request, object 2 will dependably appear as though it is before article 1 regardless of what the camera area is.

Slide 11

Hidden Surface Removal OpenGL utilizes Z-buffering to take care of this issue of shrouded surface evacuation. Z-Buffering is a strategy in which each pixel’s z-direction is contrasted with each different pixel’s z-coordinate on a line from the camera. Just the pixel that is not secured by some other pixel is really attracted to the screen.

Slide 12

Hidden Surface Removal To empower this effective element: First , in your setup capacity call to glClear ought to additionally contain GL_DEPTH_BUFFER_BIT alongside whatever other support bit you wish to clear. glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); Second , your application ought to incorporate GLUT_DEPTH in the fundamental function’s glutInitDisplayMode . This would look something like this: glutInitDisplayMode( GLUT_DEPTH | … ); Third , a call to glEnable( GL_DEPTH_TEST ) to advise the API to utilize profundity testing.

Slide 13

3D GLUT predefined shapes void glutSolidSphere ( twofold span , int cuts , int stacks ); void glutWireSphere ( twofold range , int cuts , int stacks ); Radius is the circle\'s sweep. Cuts are the quantity of subdivisions around the z-pivot. Stacks are the quantity of subdivisions along the z-pivot.

Slide 14

3D GLUT predefined shapes

Slide 15

3D GLUT predefined shapes

Slide 16

3D GLUT predefined shapes void glutSolidCube ( twofold size ); void glutWireCube ( twofold size ); Size is the length of every side

Slide 17

3D GLUT predefined shapes void glutSolidCone (twofold base ,twofold stature ,int cuts , int stacks ); void glutWireCone ( twofold base ,twofold tallness ,int cuts ,int stacks ); Radius is the cone\'s sweep. Cuts are the quantity of subdivisions around the z-pivot. Stacks are the quantity of subdivisions along the z-pivot.

Slide 18

3D GLUT predefined shapes void glutSolidTorus ( twofold InnerRadius , twofold OuterRadius , int sides , int rings ); void glutWireTorus ( twofold InnerRadius , twofold OuterRadius , int sides , int rings ); InnerRadius is the inward range of the torus. OuterRadius is the external range of the torus. Sides is the quantity of sides for every outspread area. Rings are the quantity of outspread divisions for the torus .

Slide 19

3D GLUT predefined shapes void glutSolidTeapot ( twofold size ); void glutWireTeapot ( twofold size ); Size is the relative size of the teapot.

Slide 20

3D GLUT predefined shapes The model for four more shapes are demonstrated as follows. void glutSolidIcosahedron (); void glutWireIcosahedron (); void glutSolidOctahedron (); void glutWireOctahedron (); void glutSolidTetrahedron (); void glutWireTetrahedron (); void glutSolidDodecahedron (); void glutWireDodecahedron ();

Slide 21

3D GLUT predefined shapes By changing the Display capacity of the triangle program, we can get some great three-dimensional design. Illustration: a project section that attracts a yellow teapot to the screen:

Slide 22

3D GLUT predefined shapes void Display() { //Clear pixels in cushion glClear( GL_COLOR_BUFFER_BIT ); glColor3f( 1.0, 1.0, 0.0 ); glutSolidTeapot( 0.5 ); glFlush(); //Draw to the screen } .:tsli

Recommended
View more...