Computer Graphics Assignment 2- Obj Viewer Solved

35.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

Rate this product

 

  • Only accept answers submitted via git push to this course project for you at https://hconnect.hanyang.ac.kr (<Year>_<Course no.>_<Class code>/<Year>_<Course

no.>_<Student ID>.git).

  • Place your files under the directory structure <Assignment name>/<your files> just like

the following example.

+ 2020_ITE0000_2019000001

+ ClassAssignment1/

–  main.py

–  report.docx

  • The submission time is determined not when the commit is made but when the git push

is made.

 

  1. Implement your own obj file viewer. The loaded mesh should be rendered with multiple light sources.
    1. You have to implement all requirements in a single program. This assignment DOES NOT require each requirement to be a separate program
    2. The window size doesn’t need to be (480, 480). Use the larger window that is enough to

see the details of the viewer.

 

  1. Requirements
  2. Manipulate the camera in the same way as in ClassAssignment1 using your

ClassAssignment1 code (10 pts).

  1. Also draw the reference grid plane.

 

  1. Load an obj file and render it (70 pts)
    1. Open an obj file by drag-and-drop to your obj viewer window (10 pts)
      1. Google glfwSetDropCallback to see how to do it
      2. The viewer should render only one obj file at a time. If an obj file B is drag-anddropped to the viewer while it is rendering another obj file A, the viewer should

only render the new obj file B.

  1. This feature is essential for scoring your assignment, so if not implemented,

you won’t get any score for “Load an obj file and render it (70 pts)”

  1. Read the obj file and display the mesh only using vertex positions, vertex normals, faces information (40 pts)
    1. Ignore texture coordinate, material, group, shading information. In other words,

ignore vt, mtllib, usemtl, o, s tags.

  1. Use glDrawArrays() or glDrawElements() to render triangle meshes.
  2. DO NOT use glVertex*() & glNormal*(). If you draw meshes using glVertex*()

& glNormal*(), you’ll get only 10 pts out of 40 pts.

  • Toggle wireframe / solid mode by pressing Z key (similar to pressing Z key in Blender)

(10 pts)

  1. When open an obj file, print out the following information of the obj file to stdout (console) (10 pts)
    1. File name
    2. Total number of faces
    3. Number of faces with 3 vertices
    4. Number of faces with 4 vertices
    5. Number of faces with more than 4 vertices

 

  1. Lighting (10 pts)
  1. Use multiple light sources (not a single light) to better visualize the mesh (10 pts)
  2. Choose the number of light sources, light source types, light colors, material colors as you want.

 

  1. Report (10 pts)
    1. Submit a report of at most 2 pages in docx file format (MS Word). Do not exceed the

limit.

  1. The report should include:
    1. Which requirements you implemented (5 pts) ii.A few screenshot images of your program with downloaded obj files (5pts)
      1. Download cool obj files from the Internet and open them with your viewer. You may download obj files from
        1. https://free3d.com/
        2. https://www.cgtrader.com/free3dmodels
      2. Choose some of the best looking screenshot images of your viewer.
      3. Do not use the sample obj files for this requirement. You must use other obj files

downloaded from internet to get score for this requirement.

iii.       Lighting configuration:

  1. How many light sources?
  2. Where do you put the light sources?
  3. What is the type of each light source (point light or directional light)?
  1. You do not need to try to write a long report. Just write down the required information.

Use either English or Korean.

 

  1. Extra credits
    1. Toggle [shading using normal data in obj file] / [forced smooth shading] by pressing S key

(+10 pts)

  1. In [forced smooth shading] mode, do not use vertex normal in obj. Instead, you have to compute the averaged vertex normal for each vertex as described in the lecture

slide and use them for shading.

  1. Load & render a mesh that does not have the same number of vertices of all polygons using glDrawArrays() or glDrawElements() (+10 pts)
    1. For example, some polygons in the mesh are triangles and the rest are quads or

polygons with more vertices

  1. To render this kind of mesh using a vertex array, you might need to render a quad or a n-polygon as a set of triangles. So you may need some kind of “triangulation”

algorithm.

 

  1. Runtime Environment
    1. Your program should be able to run on systems only with Python 3.7 or later, NumPy,

PyOpenGL, glfw. Do not use any other additional python modules.

  1. Only glfw is allowed for event processing and window & OpenGL context management. Do not use glut functions for this purpose.
  2. If your program does not meet this requirement, it will not run on TA’s computer so

you will not get any score for this assignment (except report).

 

  1. Test your viewer with sample obj files. cube-tri.obj: A cube with triangles only
    1. cube-tri-quad.obj: A cube with triangles and quads
    2. sphere-tri.obj: A sphere with triangles only
    3. sphere-tri-quad.obj: A sphere with triangles and quads
    4. cylinder-tri.obj: A cylinder with triangles only
    5. cylinder-tri-quad-n.obj: A cylinder with triangles, quads and polygons with more vertices
    6. Basically, your viewer should be able to render cube-tri.obj, sphere-tri.obj, cylinder-

tri.obj properly.

  1. To meet extra credit requirement B, your viewer should be able to render all above

sample obj files properly.

 

  1. What you have to submit:
    1. .py files
      1. You can use multiple .py files for this assignment. In this case, explain how to run the

program in the report.

  1. .docx report file

 

  1. Additional information
    1. drop_callback in glfw python binding is slightly different from that of original glfw written in C. drop_callback in python takes only two parameters, window and paths. paths is a list

of dropped file paths.

  1. obj file format reference: https://en.wikipedia.org/wiki/Wavefront_.obj_file
  2. Python provides powerful string methods helpful for parsing an obj file. Among them, split() will be most useful.
  • ClassAssignment3-qocyak.zip