Triangle Strips

New Message Reply Date view Thread view Subject view Author view

Katyl, Donald (katyl++at++C80.Npt.nuwc.navy.mil)
26 Aug 1996 14:42:17 U


Hello all,

    I'm having some trouble with tristrips. I'm trying to create a GeoSet
with a couple of triangle strips in it. The problem is that all of the strips
are taking the vertices from the beginning of the vertex array (or from the
beginning of the index array when I use indices).

    I put the vertices for all of the strips into one array. I put the indices
for the vertices in another array. I was expecting the second strip to take
ts vertices from the array starting from where the first one left off.

    My code is below. I'm trying to create 2 strips with 5 triangles each.
When I pfPrint the geode, both strips are using the same index numbers and
have identical geometries.

    What am I doing wrong? (I'm using Performer 1.2 with IRIX 5.3)

Don Katyl
Naval Undersea Warfare Center
Newport, Rhode Island
katyl ++at++ c80.npt.nuwc.navy.mil

My Code:

#include <stdio.h>
#include <string.h>
#include <Performer/pf.h>
#include <Performer/pr.h>

static pfVec3 verts_dat [] = {
        { 0.0, 0.0, 0.0 },
        { 1.0, 0.0, 0.0 },
        { 2.0, 0.0, 0.0 },
        { 0.0, 1.0, 0.0 },
        { 1.0, 1.0, 0.0 },
        { 2.0, 1.0, 0.0 },
        { 0.0, 2.0, 0.0 },
        { 1.0, 2.0, 0.0 },
        { 2.0, 2.0, 0.0 }
};

static unsigned short indices_dat [] = {
        3, 0, 4, 1, 5, 2,
        6, 3, 7, 4, 8, 5
};

static long lengths [] = {
        6, 6
};

static void* AllocateAndCopy (void*, int, void*);

main ()
{
    pfGeode *test;
    pfGeoSet *gset;
    pfVec3 *verts;
    unsigned short *index;
    long *lens;
    void *arena;

    pfInit();
    pfConfig();

    arena = pfGetSharedArena ();

    verts = (pfVec3*) AllocateAndCopy (verts_dat, sizeof (verts_dat), arena);
    index = (unsigned short *)
        AllocateAndCopy (indices_dat, sizeof (indices_dat), arena);
    lens = (long*) AllocateAndCopy (lengths, sizeof (lengths), arena);

    gset = pfNewGSet (arena);
    pfGSetNumPrims (gset, 2);
    pfGSetPrimLengths (gset, lens);
    pfGSetPrimType (gset, PFGS_TRISTRIPS);
    pfGSetAttr (gset, PFGS_COORD3, PFGS_PER_VERTEX, verts, index);

    test = pfNewGeode ();
    pfAddGSet (test, gset);

    pfPrint (test, PFTRAV_SELF | PFTRAV_DESCEND, PFPRINT_VB_DEBUG, NULL);
    pfExit();

}

static void *
AllocateAndCopy (void* src, int size, void* arena)
{
    void *dest;

    dest = pfMalloc (size, arena);
    if (dest == NULL) {
               pfExit ();
    }
    memcpy (dest, src, size);
    return dest;
}

===================================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:53:25 PDT

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