Scott Brabson (sbrabson++at++southernmaryland.com)
Thu, 26 Feb 1998 08:36:45 -0500
I am using 2.2MR. The flt files have the correct texture mapping
indices. When I run this in clipfly or perfly everything looks great.
To ensure my app was not doing anything weird I took some Performer
sample code and paged the flt files in the app. The code below is the
application. I took this from the sample area under share/Performer. The
comments with HSB is what I changed. It runs for a little while 2-3
minutes than dies. Do you see anything strange??
If you want the flt files and the cliptexture I could ftp them to you.
The image is pretty big.
Thanks for the help,
Scott Brabson
DCS Corporation.
/*******************************************************************/
/****************************CODE BEGIN*****************************/
/*******************************************************************/
/* Copyright (c) Silicon Graphics, Inc. 1997 */
/* dbase.c - database paging
*
* Usage: dbase
*
* Notes: Based on channel.c
* DBASE function sleeps for 5 secs, then
* loads another model file.
*
* Key commands:
*
* <h> key - print help
* <s> key - toggle statistics
* ESCAPE key - exit program
*
*/
#include <Performer/pf.h>
#include <Performer/pfdu.h>
#include <Performer/pfutil.h>
#include <Performer/pfdb/pfflt.h>
#include <stdio.h>
/* Function prototypes */
void windowSetup(char *title);
void sceneSetup(void);
void channelSetup(void);
void updateView(void);
void updateSim(void);
void handleEvents(void);
void printHelp(char *progName);
/* Global variables */
typedef struct {
pfGroup *group;
} SharedData;
char *models[] = { "N31_15_00E48_30_00.flt", "N31_15_00E48_45_00.flt"
};
pfScene *scene;
pfChannel *chan;
char *progName;
int exitFlag = 0, showStats = 0;
pfuEventStream events;
SharedData *shared;
void *arena;
pfPipe *masterPipe;
int main(int argc, char *argv[])
{
extern char *progName;
extern SharedData *shared;
extern void *arena;
extern void pfuInitClipCenterNodeClass(void);
/* Initialize Performer and create the pipe */
pfInit();
pfuInitUtil();
pfuInitClipCenterNodeClass();
/*HSB - Init Converter Mode and Texmap */
pfdInitConverter("flt");
pfdConverterMode("flt",PFFLT_USE_TEXMAP,1);
arena = pfGetSharedArena();
shared = (SharedData *)pfMalloc(sizeof(SharedData), arena);
/*HSB - Add path for flt file loading */
pfFilePath("/usr/share/Performer/data:/wkspace/irss/db/OTW/Terrain/N31_E48");
/*HSB - See what is happening internally */
pfNotifyLevel(PFNFY_INTERNAL_DEBUG);
/*HSB - Multiprocess mode - no DB */
pfMultiprocess(PFMP_APPCULLDRAW);
pfConfig();
/* Set up a window, scene graph, and channel */
progName = argv[0];
windowSetup(progName);
sceneSetup();
channelSetup();
/* Simulate */
printHelp(progName);
pfInitClock(0.0);
while ( !exitFlag) {
pfSync();
updateView();
pfFrame();
updateSim();
}
/* Clean up */
pfuExitInput();
pfuExitUtil();
pfExit();
return 0;
}
void windowSetup(char *title)
{
extern pfPipe *masterPipe;
pfPipeWindow *win;
masterPipe = pfGetPipe(0);
win = pfNewPWin(masterPipe);
pfPWinName(win, title);
pfPWinSize(win, 500, 500);
pfPWinType(win, PFPWIN_TYPE_X);
pfuInitInput(win, PFUINPUT_X);
pfuInitGUI(win);
pfOpenPWin(win);
}
void sceneSetup(void)
{
extern pfScene *scene;
extern SharedData *shared;
pfLightSource *light;
scene = pfNewScene();
light = pfNewLSource();
pfAddChild(scene, light);
shared->group = pfNewGroup();
pfAddChild(scene, shared->group);
}
void channelSetup(void)
{
extern pfScene *scene;
extern pfChannel *chan;
pfPipe *pipe;
pipe = pfGetPipe(0);
chan = pfNewChan(pipe);
pfChanScene(chan, scene);
pfChanNearFar(chan, 1.0f, 50000.0f);
pfChanFOV(chan, 60.0f, -1.0f);
}
void updateView(void)
{
extern pfChannel *chan;
double angle;
float sin, cos;
pfCoord view;
angle = pfGetTime() * 30.0f;
pfSinCos(angle, &sin, &cos);
pfSetVec3(view.hpr, 40.0f, -20.0f, 0.0f);
pfSetVec3(view.xyz, 167772.796875f, 150940.265625f, 500.0f);
pfChanView(chan, view.xyz, view.hpr);
}
void updateSim(void)
{
extern pfChannel *chan;
extern int showStats;
extern void *arena;
extern pfPipe *masterPipe;
extern SharedData *shared;
extern pfScene *scene;
static int counter = 0;
static int whichModel = 0;
handleEvents();
if (showStats)
pfDrawChanStats(chan);
/* HSB - This will wait for 500 frames then delete the old and put in
a new
flt model */
{
pfNode *old,*new;
/*HSB - every 500 frames delete old add new to scene */
if(counter >= 500)
{
counter = 0; /* HSB - reset to zero*/
old = pfGetChild(shared->group,0);
pfRemoveChild(shared->group,old);
pfDelete(old);
whichModel = (whichModel + 1) % 2;
new = pfdLoadFile(models[whichModel]);
pfAddChild(shared->group,new);
{ /* HSB - Copied block from perfly add cliptexture to scene */
pfList *mpcliptextures =
pfNewList(sizeof(pfMPClipTexture*), 1, arena);
pfuProcessClipCenters((pfNode*)shared->group, mpcliptextures);
(void)pfuAddMPClipTexturesToPipes(mpcliptextures, masterPipe, NULL);
pfDelete(mpcliptextures);
}
}
else
counter++;
}
}
void handleEvents(void)
{
extern pfuEventStream events;
extern char *progName;
extern int exitFlag;
extern int showStats;
int i, j;
int key, dev, val, numDevs;
pfuEventStream *pEvents = &events;
pfuGetEvents(&events);
numDevs = pEvents->numDevs;
for ( j=0; j < numDevs; ++j) {
dev = pEvents->devQ[j];
val = pEvents->devVal[j];
if ( pEvents->devCount[dev] > 0 ) {
switch ( dev ) {
case PFUDEV_REDRAW:
pEvents->devCount[dev] = 0;
break;
case PFUDEV_WINQUIT:
exitFlag = 1;
pEvents->devCount[dev] = 0;
break;
case PFUDEV_KEYBD:
for ( i=0; i < pEvents->numKeys; ++i ) {
key = pEvents->keyQ[i];
if ( pEvents->keyCount[key] ) {
switch ( key ) {
case 27: /* ESC key. Exits prog */
exitFlag = 1;
break;
case 'h':
printHelp(progName);
break;
case 's':
showStats = !showStats;
break;
default:
break;
}
}
}
pEvents->devCount[dev] = 0;
break;
default:
break;
}
}
}
pEvents->numKeys = 0;
pEvents->numDevs = 0;
}
void printHelp(char *progName)
{
printf("\n%s - database paging\n\n"
"<h> key\t\t\t- print help\n"
"<s> key\t\t\t- toggle statistics\n"
"ESCAPE key\t\t- exit the program\n\n",
progName);
}
/*******************************************************************/
/*****************************CODE END******************************/
/*******************************************************************/
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:56:53 PDT