Re: LOD and "selected" Callbacks

New Message Reply Date view Thread view Subject view Author view

Amaury Aubel (aubel++at++lig.di.epfl.ch)
Thu, 4 Sep 1997 09:45:21 -0600


On Sep 3, 2:37pm, Tom Impelluso wrote:
> It would be ideal if there was a function:
>
> (int) current_lod_index = pfGetCurrentLODIndex(lod)
>
> that I could call as a LOD was being traversed. Then, based upon that
> index, I call my appropriate function.
>
>
> Naturally, the easiest way may be to calculate the LOD-center to Camera
> distance, and call a function manually. However, it would be cleaner
> if I could automate the process without an additional if test.
>
> (and to be more direct, what I really want is for the function to be called
> on LOD passage. Meaning, as LOD-1 is visible printData1() is called ONCE.
> Upon passage to LOD-2, printData2() is called ONCE. Upon passage back to
LOD-1,
> printData1() is called ONCE. etc.).
>
> Is this possible?

Yes it is, by setting an appropriate callback function.
As the LOD passage occurs first in the CULL process, you set a pre-cull
drawback function on the pfLOD itself.
It might look like:

LOD_callback(pfTraverser *trav, void *userData)
{
        ...
    pfLOD *lod = (pfLOD*) pfGetTravNode(trav);
    pfMatrix mat;
    int child;
        ...

    pfGetTravMat(trav, mat);

    /* get LOD's active child */
    child = (int) pfEvaluateLOD(lod, pfGetTravChan(trav), &mat);

    /* Has a switch occured? */
    if ( child!=*index )
    {
        printf("switch LOD: child %d index %d\n",child,index);

        /* do what you have to here
           probably something like

           switch (child) {
           case 1: prindData1() etc. */

        *index = child;
    }
    return PFTRAV_CONT;
}

index is a shared memory variable where the current LOD is stored. So upon
initialization it must be assigned the right value.

Hope this helps,

Amaury.

=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++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:55:52 PDT

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