Asg 3: Create a AW object to hold the points and faces lists

Objectives

In its own aw.py module, set up a AW object (class) that contains the object's data: Provide object methods to the object.

Assignment

  1. Use the old readCube() function we used previously and copy the code into the AW's read(self,filename) function. Don't forget to identify the points and faces lists as self.points and self.faces.

    Instead of ignoring the g 'cube' line that the file contains, this time read it and store it in the AW object's group data member, i.e.,

          # if reading a group
          elif elements[0] == 'g':
            self.group = elements[1:]
    	
  2. Use the old dumpCube() function we used previously and copy the code into the AW's write(self,filename) function. Don't forget to identify the points and faces lists as self.points and self.faces.

    Instead of writing out g 'cube' this time, read in the group code that the file contains and store it in the AW object's group data member. Then use it to write it out, i.e.,

        # dump out 'group' info
        file.write("g ")
        str = "%s " % (self.group[0])
        file.write(str)
        file.write("\n")
    	
  3. Use the old drawCube() function we used previously and copy the code into the AW's draw(self) function. Don't forget to identify the points and faces lists as self.points and self.faces.

Details

  1. The AW object can be made global, e.g., declared as global aw at the top of gldraw.py just like global camera.
  2. In the aw.py module, you will need to import the OpenGL modules at the top of the file:
    from OpenGL.GL import *
    from OpenGL.GLUT import *
    from OpenGL.GLU import *
    	

Requirements

  1. When you read in the object (in def main():), write out the object to a "test.obj".

Turn in

Turn in all of your code, in one tar.gz archive of your asg##/ directory, including:
  1. A README file containing
    1. Course id--section no
    2. Name
    3. Brief solution description (e.g., program design, description of algorithm, etc., however appropriate).
    4. Lessons learned, identified interesting features of your program
    5. Any special usage instructions
  2. source code (.py source)

How to hand in

See handin web page

Grading scheme