Angus Dorbie (dorbie++at++multipass.engr.sgi.com)
Sun, 11 Jan 1998 21:14:20 -0800
Performer is getting confused w.r.t. the current state.
Here's my performer caustics stuff, you could improve it now
by traversing the scene graph and modifying the geostates to
texgen linear. Infact you could do the whole shooting match
with a single geostate and modifying the texture in that but
this version uses draw callbacks.
Call the initializing function and then add the caustics draw
callbacks on a node.
Cheers,Angus.
static void InitCaustAnim(void)
{
static first = 1;
char fname[80];
int i;
if(first)
{
first = 0;
for(i = 0; i < IMGCOUNT; i++)
{
if(i<10)
sprintf(fname, ANIMSTR1, i);
else
sprintf(fname, ANIMSTR2, i);
Shared->costy[i] = new pfTexture;
Shared->costy[i]->setFilter(PFTEX_MINFILTER, PFTEX_MIPMAP_TRILINEAR);
Shared->costy[i]->setFilter(PFTEX_MAGFILTER, PFTEX_BILINEAR);
Shared->costy[i]->loadFile(fname);
cout << "LOADING CAUSTIC FRAME "<< fname<< endl;
}
Shared->linear_gen = new pfTexGen;
Shared->linear_gen->setMode(PF_S, PFTG_OBJECT_LINEAR);
Shared->linear_gen->setMode(PF_T, PFTG_OBJECT_LINEAR);
Shared->linear_gen_static = new pfTexGen;
Shared->linear_gen_static->setMode(PF_S, PFTG_OBJECT_LINEAR);
Shared->linear_gen_static->setMode(PF_T, PFTG_OBJECT_LINEAR);
//Shared->linear_gen_static->setPlane(PF_S, 1.0f, 0.0f, 0.0f, 0.0f);
//Shared->linear_gen_static->setPlane(PF_T, 0.0f, 1.0f, 0.0f, 0.0f);
Shared->linear_gen_static->setPlane(PF_S, GENfac, 0.0f, -GENfac, 0.0f);
Shared->linear_gen_static->setPlane(PF_T, 0.0f, GENfac, -GENfac, 0.0f);
}
}
static int PreDrawCaustics(pfTraverser *, void *)
{
int framecount = 0;
glPolygonOffsetEXT(-0.5, -0.00000001);
glEnable(GL_POLYGON_OFFSET_EXT);
pfTransparency(PFTR_BLEND_ALPHA);
pfOverride(PFSTATE_TRANSPARENCY, PF_ON);
//glBlendFunc(GL_ONE, GL_ONE);
glBlendFunc(GL_ZERO, GL_SRC_COLOR);
glDepthMask(0);
framecount = *((int *)Shared->cbuf->getData());
pfEnable(PFEN_TEXTURE);
Shared->costy[framecount]->apply();
pfOverride(PFSTATE_ENTEXTURE, PF_ON);
pfOverride(PFSTATE_TEXTURE, PF_ON);
pfEnable(PFEN_TEXGEN);
Shared->linear_gen_static->apply();
pfOverride(PFSTATE_ENTEXGEN, PF_ON);
pfOverride(PFSTATE_TEXGEN, PF_ON);
return PFTRAV_CONT;
}
static int PostDrawCaustics(pfTraverser *, void *)
{
pfOverride(PFSTATE_ENTEXTURE, PF_OFF);
pfOverride(PFSTATE_TEXTURE, PF_OFF);
pfOverride(PFSTATE_ENTEXGEN, PF_OFF);
pfOverride(PFSTATE_TEXGEN, PF_OFF);
glDisable(GL_POLYGON_OFFSET_EXT);
glPolygonOffsetEXT(0.0f, 0.0f);
glBlendFunc(GL_ONE, GL_ZERO);
pfOverride(PFSTATE_TRANSPARENCY, PF_OFF);
pfTransparency(PFTR_OFF);
glDepthMask(1);
return PFTRAV_CONT;
}
--
"They can't break you if you don't have a spine."
- Wally.
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:56:33 PDT