Re: line rendering in performer (part 3)

New Message Reply Date view Thread view Subject view Author view

Michael Jones (mtj++at++babar)
Tue, 7 Jun 1994 13:37:06 -0700


On Jun 7, 2:20pm, Rudy Darken wrote:
> Subject: line rendering in performer (part 3)

:This is the third pass at this problem. There have been two suggestions
:made by Michael Jones and Jim Helman which have been incorporated into
:the code stub below. The problem persists. When the only object in view
:is the grid, it is drawn in blue (as expected). However, when another
:object enters the view, the grid loses its color and goes dark. I have
:this code written into smallfly so it is the only non-sgi code in the
:application. The problem has to be in the way I define the geostate for
:the grid.

What's your experience with the code below? It's my attempt to draw
lines, and seems to work. I added it to Perfly and all seems well.

/*
 * Make a "grid of lines" graphic object
 */

pfNode *
MakeGrid (void)
{
    void *arena = NULL;
    pfMaterial *material = NULL;
    pfGeoState *geostate = NULL;
    pfGeoSet *geoset = NULL;
    pfGeode *geode = NULL;

    pfVec3 *v = NULL;
    pfVec3 *vp = NULL;
    pfVec4 *c = NULL;

    int nx = 30;
    int ny = 30;
    float x0 = -10.0f;
    float y0 = -10.0f;
    float z0 = 5.0f;
    float x1 = 10.0f;
    float y1 = 10.0f;
    float dx = x1 - x0;
    float dy = y1 - y0;

    int x;
    int y;

    /* access the global shared-memory arena */
    arena = pfGetSharedArena();

    /* make a material that specifies LMC_AD mode */
    material = pfNewMtl(arena);
    pfMtlColor(material, PFMTL_AMBIENT, 0.1, 0.1, 0.1);
    pfMtlColor(material, PFMTL_SPECULAR, 0.8, 0.8, 0.8);
    pfMtlColorMode(material, PFMTL_FRONT, LMC_AD);

    /* specify material but inherit all other geostate attributes */
    geostate = pfNewGState(arena);
    pfGStateAttr(geostate, PFSTATE_FRONTMTL, material);

    /* create geoset at attach geostate to it */
    geoset = pfNewGSet(arena);
    pfGSetPrimType(geoset, PFGS_LINES);
    pfGSetGState(geoset, geostate);

    /* build and attach vertex array */
    vp = v = (pfVec3 *)pfMalloc((2*nx + 2*ny)*sizeof(pfVec3), arena);
    for (x = 0; x < nx; x++)
    {
        pfSetVec3(vp++, x0 + x*dx/(nx-1), y0, z0);
        pfSetVec3(vp++, x0 + x*dx/(nx-1), y1, z0);
    }
    for (y = 0; y < ny; y++)
    {
        pfSetVec3(vp++, x0, y0 + y*dy/(ny-1), z0);
        pfSetVec3(vp++, x1, y0 + y*dy/(ny-1), z0);
    }
    pfGSetAttr(geoset, PFGS_COORD3, PFGS_PER_VERTEX, v, NULL);
    pfGSetNumPrims(geoset, nx + ny);

    /* build and attach color array */
    c = (pfVec4 *)pfMalloc(sizeof(pfVec4), arena);
    pfSetVec4(c, 1.0f, 0.0f, 0.0f, 1.0f);
    pfGSetAttr(geoset, PFGS_COLOR4, PFGS_OVERALL, c, NULL);

    /* create geode and attach geoset to it */
    geode = pfNewGeode();
    pfAddGSet(geode, geoset);

    /* return address of geode to caller */
    return (pfNode *)geode;
}

-- 

Be seeing you, Phone:415.390.1455 Fax:415.390.2658 M/S:9U-590 Michael T. Jones Silicon Graphics, Advanced Graphics Division mtj++at++sgi.com 2011 N. Shoreline Blvd., Mtn. View, CA 94039-7311


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:50:19 PDT

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