line rendering in performer

New Message Reply Date view Thread view Subject view Author view

Rudy Darken (darken++at++enews.nrl.navy.mil)
Mon, 6 Jun 94 17:06:24 -0400


I've had this problem before but have never found the solution.
If you include the function LoadGrid (below) in with a typical
performer application like smallfly which is rendering geometry,
what you get is interference in the graphics state from the
other geometry when rendering the lines. When I have this grid
loaded exactly as written here while running "smallfly esprit.flt"
(my call is "LoadGrid (clr, 100, 1)" where clr={0, 0, 1, 1})
I get a blue grid (as expected) as long as the car is not in view.
If the car is in view, the grid changes to some other color
which seems to be different depending on what type of machine
I'm on. Furthermore, this behavior changes with distance from the
geometry. From far off, it will look fine. As you get close to the
car, the grid will change colors. In a typical application, the
effect is line rendering which flickers greatly. We have never
been able to render anything in performer with line geometry
like this which has operated as expected. We'd appreciate any
comments you might have or if you can try this, let us know
how it works for you. Thanks.

Rudy

_______________________________________________________________
Rudy Darken <202> 767-6814
darken++at++enews.nrl.navy.mil The U.S. Naval Research Laboratory
darken++at++seas.gwu.edu The George Washington University
_______________________________________________________________

/*
 * Build a geode of color of square size extent x extent with spacing
 * between lines of gap.
 */
#define Z 0.0f;
pfGeode *
LoadGrid (pfVec4 color, long extent, long gap)
{
   long numLines;
   void *arena;
   pfGeode *geode;
   pfMaterial *material;
   pfGeoState *geostate;
   pfGeoSet *gset;
   pfVec3 *vertices;
   pfVec4 *colors;
   short ctr, i, j, c;

   if (extent % gap)
   {
      pfNotify (PFNFY_WARN, PFNFY_RESOURCE,
         "Extent not divisible by gap");
      return NULL;
   }
   arena = pfGetSharedArena ();
   geode = pfNewGeode ();
   /*material = pfNewMtl (arena);*/
   /*pfMtlColor (material, PFMTL_AMBIENT, color[0], color[1], color[2]);*/
   /*pfMtlColor (material, PFMTL_DIFFUSE, color[0], color[1], color[2]);*/
   /*pfMtlColorMode (material, PFMTL_FRONT, LMC_AD);*/
   geostate = pfNewGState (arena);
   /*pfGStateAttr (geostate, PFSTATE_FRONTMTL, material);*/
   /*pfGStateMode (geostate, PFSTATE_CULLFACE, PFCF_OFF);*/
   gset = pfNewGSet (arena);
   pfGSetPrimType (gset, PFGS_LINES);
   /*pfGSetGState (gset, geostate);*/
   numLines = 2 * ((extent / gap)+1);
   vertices = (pfVec3 *) pfMalloc (numLines * 2 * sizeof (pfVec3), arena);
   colors = (pfVec4 *) pfMalloc (numLines * 2 * sizeof (pfVec4), arena);
   pfGSetNumPrims (gset, numLines);
   ctr = 0;
   for (i=-(extent/2), c=0; c<2; c++)
   {
      if (!c)
      {
         for (j=-(extent/2); j<=(extent/2); j+=gap)
         {
            vertices[ctr][0] = i;
            vertices[ctr][1] = j;
            vertices[ctr++][2] = Z;
            vertices[ctr][0] = -i;
            vertices[ctr][1] = j;
            vertices[ctr++][2] = Z;
         }
      }
      else
      {
         for (j=-(extent/2); j<=(extent/2); j+=gap)
         {
            vertices[ctr][0] = j;
            vertices[ctr][1] = i;
            vertices[ctr++][2] = Z;
            vertices[ctr][0] = j;
            vertices[ctr][1] = -i;
            vertices[ctr++][2] = Z;
         }
      }
   }
   for (i=0; i<numLines*2; i++)
      pfCopyVec4 (colors[i], color);
   /*pfGSetDrawMode (gset, PFGS_WIREFRAME, PF_ON);*/
   pfGSetAttr (gset, PFGS_COORD3, PFGS_PER_VERTEX, vertices, NULL);
   pfGSetAttr (gset, PFGS_COLOR4, PFGS_PER_VERTEX, colors, NULL);
   pfAddGSet (geode, gset);
   return geode;
}
#undef Z


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.