Re: Pre/Post Draw Callbacks, dissapointment!

New Message Reply Date view Thread view Subject view Author view

Angus Dorbie (dorbie++at++bitch.reading.sgi.com)
Wed, 30 Aug 1995 09:22:26 -0600


On Aug 28, 4:04pm, Torres Mario 678-3280 AMSRL-BE-M wrote:
> Subject: Pre/Post Draw Callbacks, dissapointment!
>
> On the recommendation of a few good programmers from this list, I tried
> to illuminate a helicopter by dimming the pfLightColor of the sun on the
> perfly program through the use of PreDraw and PostDraw functions. I am
> very dissapointed because through this functions I can't even turn off
> the light for the helicopter in the PreDraw and then back ON in the
> PostDraw. I've set it up in the following manner if anyone cares to comment:
>
> pfNodeTravFuncs(Apache->dcs , PFTRAV_CULL,
> apachePreCull, apachePostCull);
>
> long apachePreDraw(pfTraverser *trav, void *data)
> {
> oldtod=ViewState->tod;
> ViewState->tod=0.00f;
> pfLightAmbient(ViewState->sun, 0.0f, 0.0f, 0.0f);
> pfLightColor(ViewState->sun, ViewState->tod, ViewState->tod,
> ViewState->tod);
> }
>
> long apachePostDraw(pfTraverser *trav, void *data)
> {
>
> ViewState->tod=oldtod;
> pfLightAmbient(ViewState->sun, 0.2f*ViewState->tod,
> 0.2f*ViewState->tod,
> 0.2f*ViewState->tod);
> pfLightColor(ViewState->sun, ViewState->tod, ViewState->tod,
> ViewState->tod);
> }
>

This probably changes the light but it's already been bound. Re-binding the
light source here may affect the change but you shouldn't do this in mid-draw.
You have your viewing matrix applied + any model matrix so this should never
be done in the draw process.

>
> The apache model is a multigen model, and I would expect that the model
> would be dark as if with no light and then the rest of the terrain would
> appear with the light.

This wouldn't happen even if your callbacks worked because your light colour
is still set to time of day in pre and post callbacks (unless your model has
no diffuse or specular in it's materials).

>
> Also, is updating the apache DCS in the preDraw function a good or bad
> practice?

This is a bad idea, you should do this in the app. What would happen if your
original position was culled and the apache never got drawn even though it was
in the frustum? I've updated pfDCSs in post cull callbacks and this worked, but
I used the callback to billboard the node (modelled around origin), so the cull
was still valid.

>
> All +comments welcomed,
>
> Mario T.
>
>
>
>-- End of excerpt from Torres Mario 678-3280 AMSRL-BE-M

-- 
Angus Dorbie,
Silicon Graphics Ltd, UK
dorbie++at++reading.sgi.com

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:51:51 PDT

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