Assignment 05

Meggie Ladlow


Required Image 1: ./hms 2.36 0.0 1

1. To maintain the model of images that I wanted to draw, I used a linked list where the nodes were Element structs. Each Element struct had a void pointer to the next struct in the list, and a void pointer to the current Element. I used an enumerated ObjectType struct(I'm not sure exactly what this creation is called) to keep track of the type of the current Element.

The main body of the drawing function is a while loop that iterates through the linked list of Elements. Inside the while loop there is a switch statement that is based off of the type of Element as given by the enumerated type statement. For each case, the object to be drawn is xformed by the LTM, GTM, and VTM in that order. Then, each point in the Element is divided by the homogenous coordinate. Finally, there is a call to the object's draw function.

Matrices can be drawn one of two ways. To set the LTM back to the identity matrix, use the enumerated type ObjIdentity. Otherwise, just add the matrix to the linked list. It will be multiplied to the LTM inside of the while loop when the linked list comes to a Element with enumerated type ObjMatrix.

Color can be changed by adding an Element of enumerated type ObjColor. When there is an ObjModule, Module_draw calls itself recusively, passing the original VTM as the VTM and the product of the current LTM and the original GTM as the GTM.


2. This is the image I created for the lab. To create this image, I used many polygons comprised of various points. There is a scene comprised of various parts. And here is a graph thing. Because I don't want to talk about it.

Code

model.c
horse_model.c

Scene

SpecialHorse

BodySpecialBackLeg

Body

Neck

Head

UpperFrontLeg

SpecialFrontLeg

UpperBackLeg

SpecialBackLeg

BackwardsBackLeg

LowerLeg

Hoof

Tail