TriFans broken.

New Message Reply Date view Thread view Subject view Author view

Steve Baker (sbaker++at++link.com)
Fri, 7 Aug 1998 13:46:48 -0500 (CDT)


Hi,

  We have been using TriFans under Perf 2.2 and have noticed two
serious problems. In both cases, it looks like the fan vertices
are being drawn as OpenGL strip primitives.

  * Trifans don't render properly in wireframe.
  * FLAT trifans don't render properly at all.
     
  I suspect that in both cases they are being drawn as
triangle *STRIPS* instead of *FANS*.

  We are using an ONYX-1 Inf.Reality running IRIX 6.2 and
Perf 2.2 main release.

  We only just got around to boiling these down to test cases,
but I think the problem is universal since we can induce it in
the simplest program.

My colleague Howard Yang says:

> The program that I use to test tri fan is from
> /usr/share/Performer/src/pguide/libpr/C/gset.c
> This program is to draw a square.
>
> I modified this file to test tri_strip, tri_fan and the wireframe drawing.
>
> Results :
> 1. For tri_fan : Wireframe is wrong but fill is correct.
> For wireframe, the points are connected as in
> the case of tri_strip, but the orientation of
> each triangle is correct.
>
> 2. For flat_tr_fan : Both wireframe and fill are wrong.
> The orientation of each triangle alternates.
>
> 3. For tri_strip : Both wireframe and fill are correct.
> (which we've already known)
>
> You can test it to make sure that is the info you want.
>
> Usage: trifan_test [-t|-w|-f[1|2]|-s[1|2]]
> t : simulation time
> w : wireframe
> f[1|2]: tri_fan [non-flat|flat]
> s[1|2]: tri_strip [non-flat|flat]
>
> Example :
> trifan_test -f2 -w -t10
>
> This will draw a primitive type PFGS_FLAT_TRIFANS wireframe square
> with simulation time 10( seconds? ).

------------------------------------------------------------------------
#include <getopt.h>
#include <Performer/pr.h>

pfVec3 coords_f[] = { /* tri_fan coordinate */
                      {-1.0f, -1.0f, 0.0f },
                      { 1.0f, -1.0f, 0.0f },
                      { 1.0f, 1.0f, 0.0f },
                      {-1.0f, 1.0f, 0.0f }
                    } ;

pfVec3 coords_s[] = { /* tri_strip coordinate */
                      {-1.0f, -1.0f, 0.0f },
                      { 1.0f, -1.0f, 0.0f },
                      {-1.0f, 1.0f, 0.0f },
                      { 1.0f, 1.0f, 0.0f }
                    } ;

pfVec4 colors[] ={
                   {1.0f, 1.0f, 1.0f, 1.0f},
                   {0.0f, 0.0f, 1.0f, 1.0f},
                   {1.0f, 0.0f, 0.0f, 1.0f},
                   {0.0f, 1.0f, 0.0f, 1.0f}
                 };

int length[1] = { 4 } ;

int wireframe = 0 ;
int type = 1 ;
int tri_fan = 0 ;
float simtime = 5.0f ;

void Usage (void)
{
    pfNotify(PFNFY_FATAL, PFNFY_USAGE,
            "Usage: cmd [-t|-w|-f[1|2]|-s[1|2]]\n t: simulation time\n w: wireframe\n f[1|2]: tri_fan[non-flat|flat]\n s[1|2]: tri_strip[non-flat|flat]\n") ;
    exit(1);
}

int docmdline(int argc, char *argv[])
{
    int opt;

    /* process command-line arguments */
    while ((opt = getopt(argc, argv, "t:wf:s:h")) != -1)
    {
        switch (opt)
        {
          case 't':
            simtime = atof(optarg);
            break;
          case 'w':
            wireframe = 1;
            break;
          case 'f':
            tri_fan = 1;
            type = atoi(optarg);
            break;
          case 's':
            tri_fan = 0 ;
            type = atoi(optarg);
            break;
          case 'h':
            Usage();
        }
    }
    return optind;
}

int main (int argc, char *argv[])
{
    int arg ;
    int xs, ys;
    float t = 0.0f;
    pfGeoSet *gset;
    pfGeoState *gstate;
    pfWindow *win;
    pfFrustum *frust;

    arg = docmdline(argc, argv);

    /* Initialize Performer */
    pfInit();
    pfInitState(NULL);

    /* Initialize GL */
    win = pfNewWin(NULL);
    pfWinOriginSize(win, 100, 100, 500, 500);
    pfWinName(win, "Iris Performer");
    pfWinType(win, PFWIN_TYPE_X);
    pfOpenWin(win);

    /* set up the window */
    frust = pfNewFrust(NULL);
    pfApplyFrust(frust);
    pfDelete(frust);

    pfAntialias(PFAA_ON);
    pfCullFace(PFCF_BACK);

    /* Set up a geoset */
    gset = pfNewGSet(NULL);
    if ( tri_fan )
    {
      pfGSetAttr(gset, PFGS_COORD3, PFGS_PER_VERTEX, coords_f, NULL);
      switch ( type )
      {
        case 1 :
          pfGSetPrimType(gset, PFGS_TRIFANS);
          break ;
        case 2 :
          pfGSetPrimType(gset, PFGS_FLAT_TRIFANS);
          break ;
      }
    }
    else
    {
      pfGSetAttr(gset, PFGS_COORD3, PFGS_PER_VERTEX, coords_s, NULL);
      switch ( type )
      {
        case 1 :
          pfGSetPrimType(gset, PFGS_TRISTRIPS);
          break ;
        case 2 :
          pfGSetPrimType(gset, PFGS_FLAT_TRISTRIPS);
          break ;
      }
    }

    pfGSetAttr(gset, PFGS_COLOR4, PFGS_PER_VERTEX, colors, NULL);

    pfGSetPrimLengths(gset, length ) ;
    pfGSetNumPrims(gset, 1);

    /* Set up a geostate, backface removal turned off */
    gstate = pfNewGState (NULL);
    pfGStateMode(gstate, PFSTATE_CULLFACE, PFCF_BACK);
    pfGSetGState (gset, gstate);

    pfTranslate (0.0f, 0.0f, -4.0f);

    if ( wireframe )
      pfEnable ( PFEN_WIREFRAME ) ;

    /* Simulate for twenty seconds. */
    pfInitClock (0.0f);
    while (t < simtime)
    {
        static pfVec4 clr = {0.1f, 0.0f, 0.4f, 1.0f};

        t = pfGetTime();
        pfClear(PFCL_COLOR | PFCL_DEPTH, clr);

          pfRotate (PF_Y, 1.0f);

        pfDrawGSet(gset);

        pfSwapWinBuffers(win);
    }

    if ( wireframe )
      pfDisable ( PFEN_WIREFRAME ) ;

    return 0;
}

--------------------------------------------------------------------

Steve Baker (817)619-2657 (Vox/Vox-Mail)
Raytheon Systems Inc. (817)619-4028 (Fax)
Work: SBaker++at++link.com http://www.hti.com
Home: SJBaker1++at++airmail.net http://web2.airmail.net/sjbaker1

=======================================================================
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 Tue Aug 11 1998 - 13:42:35 PDT

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