Re: pfCycleBuffer

New Message Reply Date view Thread view Subject view Author view

Scott McMillan (scott++at++ht.com)
Fri, 25 Jul 1997 18:17:19 -0400 (EDT)


> Performers:
>
> Could someone please clear up my thoughts on pfCycleBuffer.From the
> examples and man pages, I'm a little confused on the implementation.
>
> >From morph.C:
>
> //// This is where the new cycle buffer is created.
>
> cbuf = new(arena) pfCycleBuffer(nSph * sizeof(pfVec4));
>
> ncoords = (pfVec3*) pfMalloc(pfGetSize(coords), arena);
> nnorms = (pfVec3*) pfMalloc(pfGetSize(norms), arena);
> ....
> colors = (pfVec4*) cbuf->getData();
>
> /// How is it possible for cbuf->getData() to return anything since
> //// nothing has ever been done to cbuf since it's creation. Where is all
> //// the information allocated and created from the arena associated with
> ///// the cycle buffer?
>

Lemme try and take a stab at this and then some:

line 132: allocate pfCycleBuffer data
        Note: just enough space for a packed array of nSph color vectors.

    cbuf = new(arena) pfCycleBuffer(nSph * sizeof(pfVec4));

line 137: Get a handle to the data buffer:
        Note: I believe any time get data is called it gets a version
        of the data appropriate to which process you are in (APP, CULL,
        DRAW) and which pfMultiprocessing mode you are in (e.g.,
        PFMP_APP_CULL_DRAW)

    pfVec4 *colors = (pfVec4*) cbuf->getData();

        Again in answer to one of your questions this returns a POINTER
        to the buffer that was allocated in line 132. You still need to
        set the data as below.

line 159-160: Set the colors and hence the cbuf data:

        colors[i].set(0.0f, 0.0f, 0.0f, 1.0f);
        colors[i][max] = 1.0f;

line 178:. Initialize all the other CycleBuffer copies of this buffer:

    /* Set all pfCycleMemories to the same colors */
    cbuf->init(cbuf->getData());

line 180: Associate this cycle buffer data with the color data of the
        pfGeoSet:

    gset->setAttr(PFGS_COLOR4, PFGS_PER_VERTEX,
                  (void*)cbuf, NULL);

Now you can change your color in the APP process as shown in the
breatheMorphe function:

    colors = (pfVec4*) cbuf->getData();
    for (int i=0; i<nSph; i++)
        colors[i][0] = s;

    cbuf->changed();

And these changes will get propagated down the pipeline AUTOMAGICALLY by
the pfCycleBuffer, and if I understand this correctly... when the draw
process comes along to render the pfGeoSet and accesses the color
information. The pfCycleBuffer will feed it a pointer to the "correct"
data.

Hope this is right,
scott

-- 
  Scott McMillan  |    HT Medical, Inc.   | Developing medical VE's
   scott++at++ht.com   |   http://www.ht.com   | surgical simulations
 Ph: 301-984-3706 |6001 Montrose Rd., #902| and surgery simulation
Fax: 301-984-2104 |  Rockville, MD 20852  | creation tools.
=======================================================================
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:39 PDT

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