MLM Veraart (Veraart++at++fel.tno.nl)
Tue, 30 Mar 1999 20:04:06 +0200
I think you can find the solution in the sample program
/usr/share/Performer/src/pguide/libpf/C/texture.c
You have to set the PFGS_TEXCOORD2 attribute of the geoset.
Don't use TEXGEN, just specify the (u,v) coordinates that you want
for each vertex.
Mario
>
> Here is the relevant code:
>
> void sgManager::textureNode(char* name,char* filename,int nodeNumber){
> // -1 means texture this node, 0 means texture 0th child
> // 1 means texture 1st child,2 means texture 2nd child ect
>
> //This is a hack because ->find() doesn't work on pfNode unless it
> inherits from pfGroup.
> // So I cheated and textured something I "knew" was a Geode. Will have
> to fix later.
> pfNode* thisNode = scene->find(name,pfGeode::getClassType());
> if(thisNode==NULL){
> cout<<" Node named "<<name<<" not found. sgManager::textureNode\n";
> return;
> }
> pfTexture* texture = new pfTexture;
> pfTexEnv* tev = new pfTexEnv;
> if (texture == NULL || tev == NULL){
> pfDelete(texture);
> pfDelete(tev);
> cout<<"Out of performer memory in sgManager::textureNode\n";
> return;
> }
> if(!texture->loadFile(filename)){
> cout<<"File load failed, "<<filename<<" in sgManager::textureNode\n";
> pfDelete(texture);
> return;
> }
>
> pfGeode* textureNode=NULL;
> if (nodeNumber == -1) textureNode = (pfGeode*)thisNode;
> else {
> pfGroup* thisGroup = (pfGroup*) thisNode;
> textureNode = (pfGeode*) thisGroup->getChild(nodeNumber);
> }
> if(!textureNode){
> cout<<"Can't find Child # "<<nodeNumber<<" of Node "<<name<<"\n";
> pfDelete(texture);
> return;
> }
>
> tev->setMode(PFTE_DECAL);
>
> pfEnable(PFEN_TEXGEN);
> pfGeoSet* gSet=NULL;
> // C5D makes an assumtion here that we should texture the first GeoSet.
> // This may need to change later. LER
> gSet=textureNode->getGSet(0);
> pfGeoState* gState=NULL;
> gState = gSet->getGState();
> if (!gState) gState = new pfGeoState;
> gState->setAttr(PFSTATE_TEXTURE,texture);
> gState->setMode(PFSTATE_ENTEXTURE,PF_ON);
> gState->setAttr(PFSTATE_TEXENV, tev);
>
> pfTexGen* texGen = new pfTexGen;
> gState->setMode(PFSTATE_ENTEXGEN,PF_ON);
> gState->setAttr(PFSTATE_TEXGEN,texGen);
> texGen->setMode(PF_S, PFTG_OBJECT_LINEAR);
> texGen->setMode(PF_T, PFTG_OBJECT_LINEAR);
> texGen->setMode(PF_R, PFTG_OFF);
> texGen->setMode(PF_Q, PFTG_OFF);
>
> gSet->setGState(gState);
> }
>
>
>
>
> ---------------------------------------------------------------
> Larry E. Ramey ramey++at++ccpo.odu.edu
> 757-683-6276(office) 757-683-5335 (CAVE)
> "Count the heads man." - Zaphod Bebblebrox
> "Won't weigh you down, with good intentions" -Sarah McLachlan
This archive was generated by hypermail 2.0b2 on Tue Mar 30 1999 - 10:04:14 PST