Re: models whith DCS node are not displayed

New Message Reply Date view Thread view Subject view Author view

Mario Veraart (rioj7++at++fel.tno.nl)
Wed, 10 Feb 1999 14:49:21 +0100 (MET)


>
>
> --simple boundary
> Content-Type: text/plain; charset=ISO-2022-JP
> Content-Transfer-Encoding: 7bit
>
> <<ファイル : page.c>>Hello,
>
> I want to display some models which have been loaded in DBASE
> process and have been attached a DCS node.( please see a attched
> file.)
> I load the models at first time using pfdLoadFile() function,
> the models can not be displayed. If I re-load the some models,
> the models can be dislayed.
>
> I want to display the models at fisat loading time. Does anyone
> Please any suggestions for me.

A quick llo kat the source code shows that you call pfBuffer::merge()
for every model loaded. pfBuffer::merge() blocks until APP calls
pfSync(). So you anly see one update per frame. Solution mode the
    buf->merge();
line outside the for loop and put it just before
    pfDBase();

Mario

>
> Thanks.
>
> --- Mitsubishi Precision Co.,LTD. ---
> --- Visual System Department ---
> --- Engineering Section No.1 ---
> --- Kazuhiko Ohkawa ---
>
>
>
> --simple boundary
> Content-Type: text/plain; charset=US-ASCII; name="PAGE.C"
> Content-Transfer-Encoding: 7bit
> Content-Disposition: attachment; filename="PAGE.C"
>
> #include <stdlib.h>
>
> #include <Performer/pf/pfChannel.h>
> #include <Performer/pf/pfLightSource.h>
> #include <Performer/pf/pfNode.h>
> #include <Performer/pf/pfScene.h>
> #include <Performer/pf/pfDCS.h>
>
> #include <Performer/pfutil.h>
> #include <Performer/pfdu.h>
>
> #define TREEON 1
> #define DCSON 1
> #define BLK_COUNT 4
> #define STATE_UNLOAD 0
> #define STATE_LOAD 1
> #define STATE_DONE 2
> #define STATE_ACTV 3
> typedef struct {
> char fname[255];
> pfDCS *ds;
> pfGroup *gp;
> pfNode *nd;
> int state;
> } SharedType;
> SharedType *shd;
>
> typedef struct {
> pfScene *scene;
> } PassData;
>
> void dbload(void *);
> void drawfunc( pfChannel *, void * );
> int
> main (int argc, char *argv[])
> {
> int i;
> float t = 0.0f;
>
> pfInit();
> shd = NULL;
> shd = (SharedType*)pfCalloc( BLK_COUNT, sizeof(SharedType), pfGetSharedArena() );
> for( i=0; i<BLK_COUNT; i++ ) memset( &shd[i], 0, sizeof(SharedType) );
> strcpy( shd[0].fname, "n0e0.flt"); strcpy( shd[1].fname, "n0e1.flt");
> strcpy( shd[2].fname, "n0e2.flt"); strcpy( shd[3].fname, "n0e3.flt");
>
> pfMultiprocess( PFMP_APPCULLDRAW | PFMP_FORK_DBASE );
> for( i=0; i<BLK_COUNT; i++ ) pfdInitConverter(shd[i].fname);
>
> pfConfig();
>
> pfFilePath(".:/usr/share/Performer/data");
>
> if (shd == NULL)
> {
> pfExit();
> exit(-1);
> }
>
> // Attach loaded file to a new pfScene
> pfScene *scene = new pfScene;
>
> // Create a pfLightSource and attach it to scene
> scene->addChild(new pfLightSource);
>
> // Configure and open GL window
> pfPipe *p = pfGetPipe(0);
> pfPipeWindow *pw = new pfPipeWindow(p);
> pw->setWinType(PFPWIN_TYPE_X);
> pw->setName("IRIS Performer");
> pw->setOriginSize(0,0,500,500);
> pw->open();
> #if TREEON
> pfuInitGUI(pw);
> #endif
>
> // Create and configure a pfChannel.
> pfChannel *chan = new pfChannel(p);
> chan->setScene(scene);
> chan->setFOV(45.0f, 0.0f);
>
> PassData *pd;
> pd = (PassData*)chan->allocChanData( sizeof(PassData) );
> pd->scene = scene;
> chan->setTravFunc( PFTRAV_DRAW, drawfunc );
>
> // determine extent of scene's geometry
> pfSphere bsphere;
> chan->setNearFar(1.0f, 10.0f * 32000.0f );
>
> pfPhase( PFPHASE_LOCK );
> pfFrameRate( 30.0f );
>
> // database load
> for( i=0; i<BLK_COUNT; i++ ) shd[i].gp = new pfGroup;
> for( i=0; i<BLK_COUNT; i++ ) {
> shd[i].ds = new pfDCS;
> shd[i].ds->addChild( shd[i].gp );
> }
> pfDBaseFunc( dbload );
>
> // Simulate for twenty seconds.
> while (t < 60.0f)
> {
> pfCoord view;
> float s, c;
> static float tmp = 0.0f;
> static int num = 0;
>
> // Go to sleep until next frame time.
> pfSync();
>
> // Initiate cull/draw for this frame.
> pfFrame();
>
> // Compute new view position.
> t = pfGetTime();
>
> // DBload
> if ( t - tmp > 2.0f ) {
> for( i=0; i<BLK_COUNT; i++ ) {
> if ( shd[i].state == STATE_ACTV ) {
> #if DCSON
> scene->removeChild( shd[i].ds );
> #else
> scene->removeChild( shd[i].gp );
> #endif
> shd[i].gp->removeChild( shd[i].nd );
> pfAsyncDelete( shd[i].nd );
> shd[i].state = STATE_UNLOAD;
> }
> }
> if ( num >= BLK_COUNT ) num = 0;
> printf(" Load File[%s]\n", shd[num].fname );
> shd[num++].state = STATE_LOAD;
> tmp = t;
> }
> for( i=0; i<BLK_COUNT; i++ ) {
> if ( shd[i].state == STATE_DONE ) {
> #if DCSON
> scene->addChild( shd[i].ds );
> #else
> scene->addChild( shd[i].gp );
> #endif
> shd[i].state = STATE_ACTV;
> }
> shd[i].ds->setTrans( 0.0f, 0.0f, 0.0f );
> shd[i].ds->setRot( 0.0f, 0.0f, 0.0f );
> }
>
> //
> view.hpr.set(0.0f, -10.0f, 0.0f);
> view.xyz.set(0.0f, -2000.0f, 3000.0f);
> chan->setView(view.xyz, view.hpr);
> }
>
> // Terminate parallel processes and exit
> pfExit();
> return 0;
> }
>
> void drawfunc( pfChannel *ch, void *data )
> {
> static pfVec3 tscl;
>
> PassData *pd = (PassData*)data;
> ch->clear();
> pfDraw();
>
> #if TREEON
> tscl.set(0.0f, 0.0f, 1.0f);
> pfuDrawTree( ch, (pfNode*)pd->scene, tscl );
> #endif
> return;
> }
>
> void dbload(void *data)
> {
> static pfBuffer *buf = NULL;
> int i;
>
> if ( !buf ) {
> pfWindow *win;
> buf = new pfBuffer;
> buf->select();
> win = new pfWindow;
> win->openNewNoPort( "Query", -1 );
> }
>
> for ( i=0; i<BLK_COUNT; i++ ) {
> if( shd[i].state == STATE_LOAD ) {
> shd[i].nd = pfdLoadFile( shd[i].fname );
> if ( shd[i].nd == NULL ) {
> printf("Can not Load[%s]\n", shd[i].fname );
> break;
> }
> shd[i].gp->addChild( shd[i].nd );
> shd[i].state = STATE_DONE;
> buf->merge();
> }
> }
> pfDBase();
>
> return;
> }
>
>
>
>
> --simple boundary--
> =======================================================================
> List Archives, FAQ, FTP: http://www.sgi.com/software/performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com
>


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Wed Feb 10 1999 - 05:53:48 PST

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