icg2011 hwk2 - how to do?

14
ICG2011 Hwk2 - How to do?

Upload: giza

Post on 24-Feb-2016

33 views

Category:

Documents


0 download

DESCRIPTION

ICG2011 Hwk2 - How to do?. It’ll introduce. How to do Hwk2 step by step . No code. About Hwk2…. Texture Retargeting. Load an image as texture, and retargeting it over any surface/object file . Read hwk2 for more details. Step1:Texture. Read the example code , … - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: ICG2011 Hwk2 -  How to  do?

ICG2011 Hwk2- How to do?

Page 2: ICG2011 Hwk2 -  How to  do?

It’ll introduce How to do Hwk2 step by step.

No code.

Page 3: ICG2011 Hwk2 -  How to  do?

About Hwk2… Texture Retargeting.

Load an image as texture, and retargeting it over any surface/object file.

Read hwk2 for more details.

Page 4: ICG2011 Hwk2 -  How to  do?

Step1:Texture Read the example code, …

Draw a Quad with texture.

Page 5: ICG2011 Hwk2 -  How to  do?

Step2: GL_SELECT Set name/PickMatrix to the quad, thus

when user click on the polygon, program will return a signal.

You must use glSelect on the quad, or get no grade!

When click!!

Page 6: ICG2011 Hwk2 -  How to  do?

In pickSquares… (void) glRenderMode (GL_SELECT); glInitNames(); glPushName(0);

glMatrixMode (GL_PROJECTION); glPushMatrix (); glLoadIdentity (); gluPickMatrix ((GLdouble) x, (GLdouble) (viewport[3] - y), 20.0, 20.0, viewport); gluOrtho2D (0.0, 3.0, 0.0, 3.0); drawSquaresSelect();

glMatrixMode (GL_PROJECTION); glPopMatrix (); glFlush ();

hits = glRenderMode (GL_RENDER);

Define view volume

Draw selection BufferDraw your quad in this function again, and before drawing, use LoadName() and PushName() to assign a distinct name to the quad.

Page 7: ICG2011 Hwk2 -  How to  do?

Step3: Define texture coordinate

Calculate the texture coordinate of point user clicked.

(0,0)

(0,1)

(1,0)

(1,1)

This point’s coordinate is near (0.5,0.25)

Page 8: ICG2011 Hwk2 -  How to  do?

Step4: Retarget on other polygon (70%)

Click 3~4 times, and store the coordinate.

Draw a new polygon(triangle or quad, up to click times), and give each vertices the stored coordinate.

Page 9: ICG2011 Hwk2 -  How to  do?

Step5: GL_SELECT on mesh

Generate a mesh, and set each vertices a name.

Your program has to “pick” each vertices user clicked.

When click, program knows which vertex is clicked.

Page 10: ICG2011 Hwk2 -  How to  do?

Step6: Select vertices in region

After click 3 vertices (triangle is simpler), program give each vertices in the triangle region a distinct texture coordinate.

Program have to “scan” which vertices is in the region.

To each points(in screen) in the region, try pickMatrix() to select.

Page 11: ICG2011 Hwk2 -  How to  do?

Step7: Give each vertex a coordinate

Use interpolation to give each vertex a coordinate.

Interpolation from 3 boundary vertex (user select).

(0,0)

(0,1)

(1,0)

Texture (0,0)

(0,1)

(1,0)

0.3

0.7

(0,0.7) 0.3

0.7

(0.7,0.3)

=>(0.35,0.5)(0.35,0.5)

Mesh

Page 12: ICG2011 Hwk2 -  How to  do?

Step8: Display (85%) Only display when polygon’s 3 vertices

have assigned texture coordinate.

Page 13: ICG2011 Hwk2 -  How to  do?

Step9: Obj loader(100%+?)

Use mesh.h/mesh.cpp loading obj files.

You may use vertices’ sequence as name.

Same as step 5~9.

You may generate a simple obj file for debugging, like quadric mesh (as step 5). – lower grade, maybe 95?

For outlier, use face_list in mesh loader to select all outlier vertices.

Page 14: ICG2011 Hwk2 -  How to  do?

Due Day: 5/30 (Mon.) 23:59 pm