Model Class Summary Class model reads and writes OBJ-like files, and provides methods used to display models. State char *filename path to the OBJ-like file the model was read from char *name name of the model, either from the filename or as specified within the file model *parent pointer to the parent model, or NULL if it has no parent model *instanceof pointer to the model that the current model is an instance of, or NULL if the current model is not an instance sllist *children pointer to a list of children models, or NULL if the current model has no children bool smooth true if the model has smooth-shaded normals(one normal per vertex), or false if the model has flat-shaded normals(one normal per face). Default: false bool forcedisplay true if the object should always be displayed, ignoring the visible flag Default: false bool visible true if the object is visible and should therefore be displayed Default: true vectd position position(X, Y, Z) of the object Default [0, 0, 0] vectd rotation Euler rotation angles(X, Y, Z), in degrees Default [0, 0, 0] scalar scale uniform scale Default: 1 vectd *verts pointer vertex coordinates vectd *norms pointer normals texture *colormap color texture map pointer texture *reflectmap reflection map pointer texture *bumpmap bump map pointer Bump mapping is not currently implemented. uint displaylist integer name of the OpenGL display list Default: 0 uint **lines pointer to indices for lines uint **tris pointer to indices for triangles uint **quads pointer to indices for quad faces uint **polys pointer to indices for polygon faces uint nverts number of vertices uint nlines number of lines uint ntris number of triangles uint nquads number of quad faces uint npolys number of polygon faces float **texcoords pointer to texture coordinates byte *npolyverts array of numbers of polygon vertices, one for each polygon byte **colors pointer to bytes representing RGBA colors for each vertex byte displaymask bit mask specifying how to interpret the display list. The display mask indicates what sorts of commands a display list contains, and may be a bitwise combination of the following bit masks: TRANSFORM_LIST linear transform commands MATERIAL_LIST material state settings TEXTURE_LIST texture state settings DRAW_LIST drawing commands or FULL_LIST all of the above Default: 0 Color ambient ambient RGBA reflectance of the material Default [1, 1, 1, 1] (white) Color diffuse diffuse RGBA reflectance of the material Default [1, 1, 1, 1] (white) Color specular specular RGBA reflectance of the material Default [1, 1, 1, 1] (white) Color emission emissive RGBA reflectance of the material Default [1, 1, 1, 1] (white) float shininess specular falloff of the material Default: 0 Methods model() Set default values as listed above. Pointers are set to NULL. Unless specified above, numbers are set to zero. void dump(char *str="") Dump various information from the model's state. int read(char *pathname, sllist *modellist=NULL, sllist *texturelist=NULL) Read a model(.obj) file, add it to 'modellist' if given, and add its texture(s) to 'texturelist' if given. Return zero upon success, less-than-zero upon failure. int write(char *pathname) Write a model(.obj) file. Return zero upon success, less-than-zero upon failure. void material_settings() Set the OpenGL state according to the material properties of the model. void texture_settings(GLint color=GL_MODULATE, GLint reflection=GL_DECAL, GLint bump=GL_MODULATE) Set the OpenGL state according to the texture properties of the model, and specify how textures are to be used via three texture function parameters. For more information on the available texture functions, see the OpenGL function glTexEnv. void transforms() Translate, rotate, and scale. void draw_elements() Draw elements(lines, trianges, quads, polys) of a model. void draw_norms(float normsize) Draw normals of a model, and recursively draw normals of its children. void set_array_states() Set states of vertex arrays prior to drawing a model. Possible arrays to set are the vertex array, normal array(if smooth shaded), texture coordinate array(if color texture mapped), and color array(if model has vertex colors). void display() Display a model, and recursively display its children. display() calls transforms(), texture_settings(), material_settings(), and draw_elements(). void displaylist_setup(GLenum listmode=GL_COMPILE) Set up a display list for a model, depending on the model's displaymask. ~model() free all dynamically allocated memory