Re: TG_CONTOUR

New Message Reply Date view Thread view Subject view Author view

Chris Tanner (cct++at++faith)
Thu, 16 Jun 1994 13:21:08 -0700


On Jun 16, 1:46am, Desmond Hii Toh Onn wrote:
> Subject: TG_CONTOUR
> Greetings,
> I've implemented texgen using the predraw and postdraw
> callbacks and it works pretty well for TG_SPHEREMAP
>
> So one day, I tried it with TG_CONTOUR and It doesn't look
> like it's working. Is there anything that i missed. The effect
> is like TG_LINEAR.
>
> thanks
>
> des'
>
>
>
>
>-- End of excerpt from Desmond Hii Toh Onn

I originally had the same problem when recently implementing callbacks to
attenuate light points
using texgen.

The answer is that texgen uses the model viewing matrix when texgen is actually
called verses
the model view matrix when the geometry is draw to figure out the transforms
necessary for
TG_CONTOUR. Thus, because you attach the callbacks to the leaf nodes in
performer, the
model view matrix is always the same when you call texgen as when you draw the
geometry.
Thus the effect is that of TG_LINEAR.
The workaround is quite simple, just load the model view matrix with the
identity matrix
before calling texgen then pop it afterwards.
SO...

example performer code:

long pfuPreDrawContour(pfTraverser *trav, void *data)
{
    (trav, trav);
    (data, data);

    mmode(MVIEWING);
    pushmatrix();
    loadmatrix(IdentMat);
    texgen(TX_S, TG_CONTOUR, params2);
    texgen(TX_T, TG_CONTOUR, params3);
    texgen(TX_S, TG_ON, NULL);
    texgen(TX_T, TG_ON, NULL);
    popmatrix();
    return NULL;
}

long pfuPostDrawContour(pfTraverser *trav, void *data)
{
    (trav, trav);
    (data, data);

    texgen(TX_S, TG_OFF, NULL);
    texgen(TX_T, TG_OFF, NULL);

    return NULL;
}

-- 

_____________________________________________________________ Chris Tanner (cct++at++faith.asd.sgi.com) Silicon Graphics - Advanced Graphics Division _____________________________________________________________


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:50:20 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.