Program Description


You are required to implement an OpenGL program that can read object files and display 3D models correctly on the screen.
You also need to implement keyboard and mouse motion functions to control the camera.

Due Day


2017/11/20 23:59
Please upload your entire files as a zip file to e3.

Please upload entire solution, project, source code, and objects!
And please use your school id as your file name.
For example:

Since you can't delete the uploaded files, you can just upload a new one.



The object files, material files, viewing files, light files, and scene files would be given.

    • Object files (*.obj) : describe the coordinate of the vertices and the normal vectors of a 3D model.
    • Material files (*.mtl) : describe the material attribution of the 3D model.
    • Viewing files (*.view) : describe the camera, the view frustum and viewport.
    • Light files (*.light) : describe the lights and the ambient color.
    • Scene files (*.scene) : a list of 3D models, also describe the translation vector of each model.

The source code of object file loader is already given. You can use it to read the object and material files.
You need implement the scene, view, and light file loader.
You need to use OpenGL functions to setup 
the camera, view frustum, light source, vertex coordinate, normal, and material.
Then display the model correctly on the screen. All information you need is described in the files above.
PS: Do not implement your loader in OpenGL's main loop!

The scene file describes the scaling, rotation, and translation of each model.
First, you should scale the object.
Next, you should rotate it to the right direction.
Finally, you should move each of model to the correct position.
Highly recommend to write the camera control and scene manager as c++ class

UI control:

    • Keyboard : Move the camera.
      • 'w' : zoom in
      • 'a' : move left (circle the center)
      • 's' : zoom out
      • 'd' : move right (circle the center)
      • '1'~'9' : select n-th object
    • Mouse : Drag the selected object.
      • Right : Increase x
      • Left : Decrease x
      • Up : Increase y
      • Down : Decrease y




Mesh Loader

Viewing File

Light File

Scene File

Implementation Steps


    1. Write a program to load scene files, viewing and light files.
      Then use the given mesh loader to load object files and material files.
      Get the geometry and material datas from files loaded and draw the model on the screen.
    2. Translate models to correct position. Also implement keyboard and mouse motion call back funcitons to control camera or objects.

Hints of Functions in C:
You may need these following function for processing text files.

    • fscanf
    • fgets
    • strtok
    • strcmp
    • atoi, atof

Test Scenes


Test Scene 1(Click to download!)


Test Scene 2(Click to download!)

Go to top