Download from gintro examples directory
/* File: pfexLoadModel.c */ #include#include #include #include #include #include #include #include #include #include #include void pfexInitConverter(char *fname_model); pfScene *pfexInitScene(char *fname_model); void usage(void) { fprintf(stderr, "usage: pfexLoadModel fname_model\n"); fprintf(stderr, " pfexLoadModel [-usage|-help]\n"); exit(-1); } int main(int argc, char **argv) { pfScene *scene; if (argc != 2 || !strcmp(argv[1], "-usage") || !strcmp(argv[1], "-help")) usage(); pfInit(); pfexInitConverter(argv[1]); pfCAVEConfig(&argc, argv, NULL); pfConfig(); pfCAVEInitChannels(); scene = pfexInitScene(argv[1]); pfChanScene(pfCAVEMasterChan(), scene); while (!CAVEgetbutton(CAVE_ESCKEY)) { pfSync(); pfCAVEPreFrame(); pfFrame(); pfCAVEPostFrame(); } pfCAVEHalt(); pfExit(); } void pfexInitConverter(char *fname_model) { if (!pfdInitConverter(fname_model)) { fprintf(stderr, "Could not init converter for %s\n", fname_model); pfExit(); exit(-1); } } pfScene *pfexInitScene(char *fname_model) { pfScene *scene; pfNode *node; pfGeoState *gstate; pfLightSource *lightsource; scene = pfNewScene(); gstate = pfNewGState(pfGetSharedArena()); pfGStateMode(gstate, PFSTATE_ENLIGHTING, PF_ON); pfGStateMode(gstate, PFSTATE_CULLFACE, PFCF_OFF); pfSceneGState(scene, gstate); lightsource = pfNewLSource(); pfAddChild(scene, lightsource); if (node = pfdLoadFile(fname_model)) pfAddChild(scene, node); else { fprintf(stderr, "Could not open %s\n", fname_model); pfExit(); exit(-1); } return scene; }