[info-performer] pfVolume: Problems with setShader

Date view Thread view Subject view Author view

From: Bjorn Hanch Sollie (bjorns++at++sgi.com)
Date: 06/13/2003 03:57:28


Hi all,

I'm using pfVolume in a Performer application, and I'm trying to
adjust the transparency of a volume. To do this, I'm trying to use a
lookup table with the vzTMLUTshader. However, when I use setShader()
to apply the new shader, my application exits with the following error
message (some code is listed below):

PF Fatal(12): pfVolume error type 9, severity 0,

What is the best way to set the volume transparency? Why doesn't my
code work? Also, can someone explain to me exactly what the
"width"-parameter to vzParameterLookupTable does?

Thanks,

-Beorn

void Surge::initScene(void)
{
  pfLightSource *light;
  pfVolume *vol;

  scene = new pfScene();
  light = new pfLightSource();
  scene->addChild(light);

  vol = new pfVolume();
  vol->init();
  vol->loadFile("/oslo/people/bjorns/Surge/data/3d/AAA43_CT.vz");

  scene->addChild(vol);

  // Initialize a LUMINANCE_ALPHA lookup table
  int width = 16;
  float* data = (float*)pfMalloc(4*width*sizeof(float));

  for (int i = 0; i < width; i++)
  {
    data[i*4 + 0] = i;
    data[i*4 + 1] = i;
    data[i*4 + 2] = i;
    data[i*4 + 3] = 0.4;
  }

  vzParameterLookupTable* table =
    new vzParameterLookupTable(width, data, VZ_FLOAT, VZ_RGBA);

  vzTMLUTShader *newShader = new vzTMLUTShader();
  vol->getShape()->getAppearance()->setShader(newShader);

  return;
}

void Surge::initChannels(void)
{
  pfSphere bsphere;
  pfCoord viewCoord;
  pfChannel *masterChan; // Main channel.
  pfPipeWindow *window;

  // Determine extent of entire scene.
  bsphere = bsphere;
  scene->getBound(&bsphere);

  // Create and return a window
  window = new pfPipeWindow(pfGetPipe(0));
  window->setWinType(PFWIN_TYPE_X);
  pfuInitInput(window, PFUINPUT_X);
  // Window size (and position).
  window->setSize(960, 540);
  window->open();

  masterChan = new pfChannel(pfGetPipe(0));
  window->addChan(masterChan);

  masterChan->setScene(scene);
  masterChan->setFOV(60.0, 0.0);
  viewCoord.xyz.set(0.0f, -3.0f*bsphere.radius, 1.0f);
  viewCoord.hpr.set(0.0f, 0.0f, 0.0f);
  masterChan->setView(viewCoord.xyz, viewCoord.hpr);

  return;
}

void Surge::execute(int argc, char *argv[])
{
  /* Configure Performer. */
  pfNotifyLevel(PFNFY_INFO);
  // Initialize OpenGL Performer.
  pfInit();
  // Initialize the utility library.
  pfuInit();
  // If multiprocessing, configure the rendering pipe and forks
  processes
  pfConfig();
  // Create the visual database.
  Surge::initScene();
  // Initialize channels.
  Surge::initChannels();
  // Find the highest resolution clock available and initialize it.
  pfInitClock(0.0);
  // Set the desired frame rate.
  pfFrameRate(30.0);

  /* Application main loop */
  while (!exitFlag)
  {
    // Sleep until next frame.
    pfSync();
    // Trigger cull and draw processing for this frame.
    pfFrame();
  }

  /* Clean up. */
  pfuFreeAllCPUs();
  pfuExitInput();
  pfuExitUtil();
  pfExit();

  return;
}


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Fri Jun 13 2003 - 03:55:57 PDT