/** loadPlane **/ void loadPlane(FILE *inFP, entity_t *ent, char *attribute) { char *attributes[] = {"point", "orient1", "orient2", NULL}; int ndx; assert(ent->magic == ENTITY_T); sobj_t *sobj = ent->entDerived; assert(sobj->magic == SCENEOBJ_T); plane_t *plane = sobj->sobjDerived; assert(plane->magic == PLANE_T); ndx = getindex(attribute, attributes); switch (ndx) { case 0: /* point */ plane->point = readTuple(inFP, "Could not read plane point"); break; case 1: /* orient1 */ plane->orient1 = readTuple(inFP, "Could not read plane orient1"); break; case 2: /* orient1 */ plane->orient2 = readTuple(inFP, "Could not read plane orient2"); break; default: loadSceneObj(inFP, ent, attribute); } }
/** newSceneObj **/ entity_t *createSceneObj(FILE *inFP, scene_t *scene, char *type, int code) { entity_t *ent; /* Pointer to new entity_t */ sobj_t *sobj; /* Pointer to new sobj_t */ pixel_t white = {255, 255, 255}; /* Default color */ intensity_t zero = {0, 0, 0}; /* Default diffuse/reflect values */ /* create new sceneObject structure */ ent = createEntity(inFP, type, code); sobj = (sobj_t *) malloc(sizeof(sobj_t)); assert(sobj != NULL); ent->entDerived = sobj; /* Set default values for a shape */ sobj->color = white; sobj->diffuse = zero; sobj->reflective = zero; sobj->magic = SCENEOBJ_T; loadSceneObj(inFP, ent); completeSceneObj(scene, ent); return(ent); }