1 / 14

ICG2011 Hwk2 - How to do?

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 , …

giza
Download Presentation

ICG2011 Hwk2 - How to do?

An Image/Link below is provided (as is) to download presentation 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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ICG2011 Hwk2- How to do?

  2. It’ll introduce • How to do Hwk2 step by step. • No code.

  3. About Hwk2… • Texture Retargeting. • Load an image as texture, and retargeting it over any surface/object file. • Read hwk2 for more details.

  4. Step1: Texture • Read the example code, … • Draw a Quad with texture.

  5. 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!!

  6. 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 Buffer Draw your quad in this function again, and before drawing, use LoadName() and PushName() to assign a distinct name to the quad.

  7. Step3: Define texture coordinate • Calculate the texture coordinate of point user clicked. (1,0) (1,1) This point’s coordinate is near (0.5,0.25) (0,0) (0,1)

  8. 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.

  9. 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.

  10. 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.

  11. Step7: Give each vertex a coordinate • Use interpolation to give each vertex a coordinate. • Interpolation from 3 boundary vertex (user select). (1,0) (1,0) 0.7 0.3 (0.7,0.3) 0.3 (0,0.7) =>(0.35,0.5) (0,1) 0.7 (0.35,0.5) (0,0) (0,1) (0,0) Texture Mesh

  12. Step8: Display (85%) • Only display when polygon’s 3 vertices have assigned texture coordinate.

  13. 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.

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

More Related