1 / 16

# Assignment 2 Phase 1 - PowerPoint PPT Presentation

Assignment 2 Phase 1. Transformation Back-face culling View frustum culling. Outline. Implement the transformation. Modelview transformation Projection transformation Perspective division Viewport transformation Implement back-face culling. Bonus: Implement view frustum culling.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about ' Assignment 2 Phase 1' - chaela

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Assignment 2 Phase 1

Transformation

Back-face culling

View frustum culling

• Implement the transformation.

• Modelview transformation

• Projection transformation

• Perspective division

• Viewport transformation

• Implement back-face culling.

• Bonus: Implement view frustum culling.

• Input: *.view *.obj *.mtl

• Same as assignment 1

• Output: Wireframe of the obj with back-face culling

Modelview

Matrix

Projection

Matrix

Viewport

Transformation

Perspective

Division

Vertex

Vertex = Projection * Modelview * Vertex ;

Vertex.xyzw /= Vertex.w;

Vertex = Viewport * Vertex;

gluLookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,

GLdouble atx, GLdouble aty, GLdouble atz,

GLdouble upx, GLdouble upy, GLdoubpe upz );

N = (eye - at)/|eye - at|; V = up – (N•up)N; |up| = 1.0

U = V x N ;

• Modelview = BT

• gluPerspective( GLdouble fovy, GLdouble aspect, GLdouble near, GLdouble far );

• n=near;

• f=far;

• t=n*tan( fovy *PI / 180.0 /2);

• b= -t;

• r= t* aspect;

• l= -r;

• Projection = NSH =

• x /= w;

• y /= w;

• z /= w;

• w /= w;

• Viewport = TS

• From [-1 , 1 ] to [0 , width (or height) ]

• You can perform back-face culling in

• World cord.

• View cord.

• ZN < 0

• Window cord.

• Clock wise

1

Back face

3

2

• eliminate the polygon that complete outside the view frustum.

• Bonus: view frustum clipping

• Remove the part of polygon that outside the view frustum.

• Render the image using

glBegin(GL_LINE_LOOP);

glVertex2i(x,y);

glEnd();

void GL_reshape(GLsizei w, GLsizei h){

glViewport(viewport->x, viewport->y,

viewport->width, viewport->height);

glMatrixMode(GL_PROJECTION);

gluOrtho2D(viewport->x, viewport->width,

viewport->y, viewport->height);

glMatrixMode(GL_MODELVIEW);