Simple Program

New Message Reply Date view Thread view Subject view Author view

Matthew Hesher (hesher++at++nu.cs.fsu.edu)
Fri, 3 Dec 1999 17:44:24 -0500 (EST)


Good evening all,
  I sat down today and decided to write my first performer program. My first
attempt was miserable, so I read alot of docs and I have a window now. I'm
attemping to read in a mesh and display it (very similar to simple.C that
comes with Performer). However, I just can't seem to get a picture to appear.
If anyone could point me in the right direction to finding the problem with my
program, I would appreciate it. Below is the program.
Curt Hesher
hesher++at++cs.fsu.edu
P.S. The path to the mesh isn't the problem. Here's the output when it runs:

calais 148% myScene
PF Notice: pfdLoadFile_iv: /usr/people/hesher/Inventor/MODELS/IV/teapot.iv
PF Notice: Using 72Hz video rate.

// My second attempt at a Performer program
// compile this with "cc myScene.c++ -lpf"
// or with "make"

// Regular includes
#include <iostream.h>

// Performer includes
#include <Performer/pf/pfChannel.h>
#include <Performer/pf/pfLightSource.h>
#include <Performer/pfdu.h>

int main (int argc, char *argv[])
{
  float time = 0.0f;

  if(pfInit() == -1) {
    cerr << "Error in pfInit. Exiting.\n";
    pfExit();
    exit(-1);
  }

  // Use default multiprocessing mode based on number of
  // processors.
  pfMultiprocess( PFMP_DEFAULT );

  // Call pfdInitConverter before pfConfig
  const char ext[] = "iv";
  if(!pfdInitConverter(ext)) {
    cerr << "Could not load DSO for " << ext << ". Exiting." << endl;
    pfExit();
    exit(-1);
  }

  // Fork App, Cull, Draw, and some other stuff
  if(pfConfig() == -1) {
    cerr << "Error in pfConfig. Exiting.\n";
    pfExit();
    exit(-1);
  }

  // Load a mesh
  const char meshFile[80] = "/usr/people/hesher/Inventor/MODELS/IV/teapot.iv";
  pfNode *myObject = pfdLoadFile(meshFile);

  // Create the Scene
  pfScene *scene = new pfScene;
  scene -> addChild(myObject);

  // Create a light and attach it to the scene
  scene -> addChild(new pfLightSource);

  // Create the Pipe
  pfPipe *p = pfGetPipe(0);
  pfPipeWindow *pw = new pfPipeWindow(p);
  pw -> setWinType(PFPWIN_TYPE_X);
  pw -> setOriginSize(0,0,512,512);
  pw -> open();

  // Create the Channel
  pfChannel *chan = new pfChannel(p);
  chan -> setScene(scene);
  chan -> setFOV(135.0f, 0.0f);
  //chan -> setAutoAspect(PFFRUST_CALC_HORIZ);
  //chan -> setAutoAspect(PFFRUST_CALC_VERT);
  // makePersp and makeOrtho disable setAutoAspect
  //chan -> makePersp(-10.0f, 10.0f, -10.0f, 10.0f); //left, right, bottom, top
  //chan -> drawStats();
  pfVec3 position(0.0f, 5.0f, 0.0f);
  pfVec3 orientation(0.0f, 0.0f, 0.0f);
  chan -> setView(position, orientation);

  // Determine the size of the bounding sphere
  pfSphere bsphere;
  myObject -> getBound(&bsphere);
  chan -> setNearFar(1.0f, 10.0f * bsphere.radius);

  while (time < 20.0f)
  {
    //pfSync(); //pfFrame will automatically call pfSync
    pfFrame();
    time += 0.1;
  }

  // Terminate parallel processes and exit
  pfExit();
  return 0;
}


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Fri Dec 03 1999 - 14:44:30 PST

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