From: Terry Welsh (mogumbo++at++totalmail.com)
Date: 10/16/2003 09:23:23
Hi Francis,
The standard example for cliptexturing is at
/usr/share/Performer/src/pguide/libpf/C/cliptex.c, but it's more complicated than it needs to be. Here's some bare-bones sample code you can probably plug into your app pretty easily:
float ctXSize, ctYSize;
ct = pfdLoadClipTexture(ct_filename);
ct->getVirtualSize(&ctXSize, &ctYSize, NULL);
mpct = new pfMPClipTexture;
mpct->setClipTexture(ct);
pfuAddMPClipTextureToPipes(mpct, pfGetPipe(0), NULL);
// prepare geostate that uses this cliptexture
gstate = new pfGeoState;
gstate->setAttr(PFSTATE_TEXTURE, ct);
gstate->setMode(PFSTATE_ENTEXTURE, PF_ON);
gstate->setMode(PFSTATE_ENLIGHTING, PF_ON);
// attach gstate to .flt model
setAllGeoStates((pfGroup*)node, gstate);
void setAllGeoStates(pfGroup* group, pfGeoState* gstate){
pfGeoSet* gset;
if(group->isOfType(geode->getType())){
for(int i=0; i<((pfGeode*)group)->getNumGSets(); i++){
gset = ((pfGeode*)group)->getGSet(i);
gset->setGState(gstate);
}
}
else{
for(int i=0; i<group->getNumChildren(); i++)
setAllGeoStates((pfGroup*)(group->getChild(i)), gstate);
}
}
Then somewhere in your main loop you need to set your clipcenter like this:
mpct->setCenter(int(x * ctXSize),
int(y * ctYSize),
0);
where x and y are floats from 0.0 to 1.0, I think
Terry Welsh
_____________________________________________________________
Get Your Free Email at http://www.totalmail.com
This archive was generated by hypermail 2b29 : Thu Oct 16 2003 - 09:26:44 PDT