[info-performer] pfdBuilder bug???

Date view Thread view Subject view Author view

From: John Kelso (kelso++at++nist.gov)
Date: 01/19/2004 13:08:38


Hi,

Included after this email is a small Performer file loader which I hope
illustrates either something I'm doing wrong, or a bug in the pfdBuilder.

Here's the behavior- when I load a pfMaterial into the builder AND the X
coordinate of the third vertex of the first polygon is ".20", the
geometry is displayed as opaque, even though its alpha value is .05.

If I change either the X coordinate to ".21", OR, don't load a pfMaterial
into the builder, OR remove any polygon from the list, the geometry is
displayed as translucent, which I interpret as correct.

I have no idea what's going wrong. This is causing objects in our
visualizations to be drawn as opaque when they should be translucent.

I've seen this behavior on both IRIX and Linux, Performer 3.0 and 3.1 beta.

Can someone please let me know what's going wrong? Hopefully I'm doing
something dumb and obvious and easy to fix.

Thanks,

-John

--------------------------------------------------------------
#include <stdio.h>
#include <ctype.h>

#ifdef WIN32
#include <windows.h>

#define PFPFB_DLLEXPORT __declspec(dllexport)
#else
#define PFPFB_DLLEXPORT

#endif // WIN32

#include <Performer/pfdu.h>
#include <Performer/pr/pfGeoSet.h>
#include <Performer/pr/pfMaterial.h>

#ifdef __linux__
#include <limits.h>
#endif

extern "C" PFPFB_DLLEXPORT pfNode *
pfdLoadFile_foo(char *fileName) {

  pfVec3 verts[9][3] = {
    {pfVec3(0.22f, -0.7f, -1.f),
     pfVec3(0.23f, -0.6f, -0.9f),
     //pfVec3(0.21f, -0.6f, -1.f)}, // this is translucent
     pfVec3(0.20f, -0.6f, -1.f)}, // this is opaque with material
    
    {pfVec3(0.30f, -0.86f, -1.1f),
     pfVec3(0.32f, -0.90f, -1.1f),
     pfVec3(0.30f, -0.89f, -1.0f)},
    
    {pfVec3(0.30f, -0.86f, -1.1f),
     pfVec3(0.31f, -0.80f, -1.2f),
     pfVec3(0.38f, -0.90f, -1.2f)},
    
    {pfVec3(0.3f, -0.8f, -1.18f),
     pfVec3(0.26f, -0.8f, -1.1f),
     pfVec3(0.23f, -0.7f, -1.1f)},
    
    {pfVec3(0.26f, -0.8f, -1.1f),
     pfVec3(0.22f, -0.7f, -1.f),
     pfVec3(0.23f, -0.7f, -1.1f)},
    
    {pfVec3(0.23f, -0.7f, -1.1f),
     pfVec3(0.22f, -0.7f, -1.f),
     pfVec3(0.21f, -0.6f, -1.f)},
    
    {pfVec3(0.21f, -0.6f, -1.f),
     pfVec3(0.22f, -0.6f, -0.9f),
     pfVec3(0.23f, -0.5f, -0.9f)},
    
    {pfVec3(0.23f, -0.6f, -0.9f),
     pfVec3(0.26f, -0.5f, -0.8f),
     pfVec3(0.23f, -0.5f, -0.9f)},
    
    {pfVec3(0.23f, -0.5f, -0.9f),
     pfVec3(0.26f, -0.5f, -0.8f),
     pfVec3(0.27f, -0.4f, -0.8f)}
  } ;

  // restore builder to initial state
  pfdResetBldrGeometry();
  pfdResetBldrState();
  // also get the bug with just PFTR_HIGH_QUALITY, or with PFTR_ON
  pfdBldrStateMode(PFSTATE_TRANSPARENCY,
                   PFTR_HIGH_QUALITY | PFTR_NO_OCCLUDE);

  // establish material definition for model
  // having a material and X coord of first triangle = .020 makes opaque
  pfMaterial *m = new pfMaterial();
  pfdBldrStateAttr(PFSTATE_FRONTMTL, m);

  // allocate primitive buffer
  pfdGeom *prim = pfdNewGeom(3);

  // set up prims
  int i ;
  for (i=0; i<9; i++) {
    prim->primtype = PFGS_POLYS ;

    prim->coords[0] = verts[i][0] ;
    prim->coords[1] = verts[i][1] ;
    prim->coords[2] = verts[i][2] ;

    prim->nbind = PFGS_OFF;

    prim->cbind = PFGS_PER_PRIM;
    prim->colors[0] = pfVec4(0.f, 0.f, 1.f, 0.5f) ;

    // always turn off textures
    int j ;
    for (j=0; j<PF_MAX_TEXTURES; j++)
      prim->tbind[j] = PFGS_OFF;

    // add this primitive to builder
    pfdAddBldrGeom(prim, 1);

  }

  // release primitive buffer
  pfdDelGeom(prim);

  // get a complete scene graph representing file's primitives
  return pfdBuild();
  
}


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Mon Jan 19 2004 - 13:24:56 PST