AW
object to hold the points
and faces
listsaw.py
module,
set up a AW
object (class) that contains the object's data:
points
(list of points, empty at initialization),
faces
(list of indeces to point list, empty at init), and
group
(string, emtpy at init, i.e., ""
),
read(self,filename)
,
write(self,filename)
,
and
draw(self)
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:]
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")
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
.
AW
object can be made global, e.g., declared as
global aw
at the top of gldraw.py
just like global camera
.
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 *
def main():
),
write out the object to a "test.obj"
.
tar.gz
archive of your asg##/ directory, including:
README
file containing
.py
source)
handin
web page