Torsten Moeller (tmoeller++at++cgrg.ohio-state.edu)
Thu, 18 May 1995 21:05:20 -0400 (EDT)
----------------------------------------------------------------------
pfGroup* objectRead(FILE *stream, pfMaterial **mtl)
{
char command[200]; /* Input buffer to hold each command */
char *obj_name; /* the name of the object */
pfGroup *root; /* hold the actual object */
short material = -1; /* store the material index */
pfGeoState* gstate; /* to store info on material */
/**************************************************************************/
/* Parse input stream and pull out data for this object */
fscanf(stream, " %s", command);
while((strcmp(command, objectEND_TAG) != 0) && !feof(stream)) {
if(strcmp(command, "file:") == 0) {
fscanf(stream, " %s", command);
obj_name = strdup(command);
printf("Test 1 = %s\n", command);
printf("1:Name = %s\n", obj_name);
}
else if(strcmp(command, "material:") == 0) {
fscanf(stream, " %hd", &material);
}
else { /* Else what is it? */
pfNotify(PFNFY_NOTICE, PFNFY_PRINT,
"WARNING: Don't recognize command: \"%s\"", command);
}
fscanf(stream, " %s", command);
}
printf("2:Name = %s\n", obj_name);
/* Check whether material was defined */
if ((material == -1) || (mtl[material] == NULL)) {
pfNotify(PFNFY_NOTICE, PFNFY_PRINT,
"WARNING: no material specified or specified material not\
defined yet.");
}
else {
/* Apply Material to this object*/
gstate = pfNewGState(NULL);
pfGStateMode(gstate, PFSTATE_ENLIGHTING, PF_ON);
pfGStateMode(gstate, PFSTATE_TRANSPARENCY, PFTR_ON);
pfGStateAttr(gstate, PFSTATE_FRONTMTL, mtl[material]);
}
printf("3:Name = %s\n", obj_name);
/* Load the database. create a hierarchy under node "root" */
root = (pfGroup *)LoadObj(obj_name, gstate);
printf("4:Name = %s\n", obj_name);
free(obj_name); obj_name = NULL;
pfDelete(gstate); gstate = NULL;
return root;
}
----------------------------------------------------------------------
The output is the following:
Test 1 = /nfs/stegosaur/research/NIDRR/tmoeller/Wheelchair/Neue_Version/Data/Wavefront/Store-Textured3//retailclg.obj
1:Name = /nfs/stegosaur/research/NIDRR/tmoeller/Wheelchair/Neue_Version/Data/Wavefront/Store-Textured3//retailclg.obj
2:Name = /nfs/stegosaur/research/NIDRR/tmoeller/Wheelchair/Neue_Version/Data/Wavefront/Store-Textured3//retailclg.obj
3:Name = /nfs/stegosaur/research/NIDRR/tm
Performer Warning (2): openFile: Could not find file "/nfs/stegosaur/research/NIDRR/tm"
4:Name = /nfs/stegosaur/research/NIDRR/tm
meaning that in the middle of the program (when I apply some routines to
gstate) some memory gets overridden.
That's why I am assuming, that there is something wrong within the Performer
libraries?!
I am kindly asking, whether anybody could give me some suggestions,
whether there might be something in my program, I have overlooked, or
whether there are other people who had similar problems.
In the end my program returns with a Segmentation fault while calling
'pfFrame'.
Torsten Moeller.
-- Research Assistant ACCAD tmoeller++at++cgrg.ohio-state.edu Ohio State University
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:51:30 PDT