#include #include #include #include pfNode* CreateTruc(void) { void *arena = pfGetSharedArena(); pfGeoState *gstate = new(arena) pfGeoState; gstate->setMode(PFSTATE_ENLIGHTING, PF_OFF); gstate->setMode(PFSTATE_TRANSPARENCY, PFTR_OFF); lineColor = (pfVec4*)new(sizeof(pfVec4), arena)pfMemory; lineColor->set(1.0f, 0.0f, 0.0f, 1.0f); // rouge pointColor = (pfVec4*)new(sizeof(pfVec4), arena)pfMemory; pointColor->set(1.0f, 1.0f, 1.0f, 1.0f); // blanc crdlist = (pfVec3*)new(128 * sizeof(pfVec3), arena) pfMemory; ilist = (ushort*)new(128 * sizeof(ushort), arena) pfMemory; len = (int*)new(sizeof(int), arena) pfMemory; len[0] = 0; for(int i = 0; i < 128; i++) { ilist[i] = i; crdlist[i] = ...; // read coords from file... } pfGeoSet *lineGSet = new(arena) pfGeoSet; pfGeoSet *pointGSet = new(arena) pfGeoSet; // one lineset and one pointset for the same coords set lineGSet->setPrimType(PFGS_LINESTRIPS); lineGSet->setNumPrims(1); lineGSet->setPrimLengths(len); lineGSet->setAttr(PFGS_COORD3, PFGS_PER_VERTEX, crdlist, ilist); lineGSet->setAttr(PFGS_COLOR4, PFGS_OVERALL, lineColor, NULL); lineGSet->setGState(gstate); pointGSet->setPrimType(PFGS_POINTS); pointGSet->setNumPrims(len[0]); pointGSet->setAttr(PFGS_COORD3, PFGS_PER_VERTEX, crdlist, ilist); pointGSet->setAttr(PFGS_COLOR4, PFGS_OVERALL, pointColor, NULL); pointGSet->setGState(gstate); pfGeode *geode = new pfGeode; geode->addGSet(lineGSet); geode->addGSet(pointGSet); return geode; }