#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void OpenPipeWin(pfPipeWindow *pw); static void DrawChannel(pfChannel *channel, void *data); static pfGeode *AddGeode( const int option ); const int NUM_LIGHTS = 5; static pfLight *ls[NUM_LIGHTS]; #define PI (3.1415926535897) #define DEG_TO_RAD( d ) ( (d) * PI / 180.0 ) int main( int argc, char *argv[] ) { int l1; char line[80]; cout << "Enter option (0 or 1) : "; cin.getline( line, 79, '\n' ); int option = atoi( line ); int bbox = 0, num_pw = 1; if( !option ) { if(1){ num_pw = 1; bbox = 1; } else{ cout << "Enter no. of pipe windows (1 or 2) : "; cin.getline( line, 79, '\n' ); num_pw = atoi( line ); cout << "Force updates of node bounds (0 or 1) : "; cin.getline( line, 79, '\n' ); bbox = atoi( line ); } } // // Initialise and configure Performer // pfInit(); pfuInit(); pfMultiprocess( PFMP_DEFAULT ); pfdInitConverter("dummy.iv"); pfdInitConverter("dummy.flt" ); pfdInitConverter("dummy.obj" ); pfConfig(); // // Configure and open pipe and pipewindow(s) // pfPipe *pipe = pfGetPipe(0); pfPipeWindow *pw[2]; if( num_pw == 1 ) { int pw_origin[2] = {0, 64}, pw_size[2] = {640, 960}; pw[0] = new pfPipeWindow(pipe); pw[0]->setOriginSize( pw_origin[0], pw_origin[1], pw_size[0], pw_size[1] ); } else { int pw_origin[2] = {0, 64}, pw_size[2] = {640, 480}; pw[0] = new pfPipeWindow(pipe); pw[0]->setOriginSize( pw_origin[0], pw_origin[1], pw_size[0], pw_size[1] ); pw_origin[1] += pw_size[1]; pw[1] = new pfPipeWindow(pipe); pw[1]->setOriginSize( pw_origin[0], pw_origin[1], pw_size[0], pw_size[1] ); } for( l1=0; l1setMode( PFWIN_NOBORDER, PFIS_TRUE ); pw[l1]->setConfigFunc(OpenPipeWin); pw[l1]->config(); } // // Scene // pfScene *scene = new pfScene(); // // Open channels // const int NC = 2; pfChannel *chan[NC]; pfVec3 v1, v2; float vp_left[NC] = {0.0, 0.0}, vp_right[NC] = {1.0, 1.0}; float vp_bottom[NC] = {0.0, 0.5}, vp_top[NC] = {0.5, 1.0}; if( num_pw == 2 ) { vp_bottom[1] = 1.0; vp_top[0] = 0.0; } for( l1=0; l1removeChan( chan[l1] ); pw[1]->addChan( chan[l1] ); } chan[l1]->setViewport( vp_left[l1], vp_right[l1], vp_bottom[l1], vp_top[l1] ); chan[l1]->setFOV( 48.0, 0.0 ); chan[l1]->setNearFar( 0.1, 1000.0 ); chan[l1]->setScene( scene ); chan[l1]->setTravFunc( PFTRAV_DRAW, DrawChannel ); //v1.set( 0.0, -8.5, 1.7 ); v2.set( 0.0, -15.0, 0.0 ); v1.set( 0.0, -0.5, 1.7 ); v2.set( 180.0, -15.0, 0.0 ); chan[l1]->setView( v1, v2 ); } v1.set( 0.0, -4.5, 1.0 ); pfGeode *geode = AddGeode( option ); scene->addChild( geode ); int cnt = 0; do { pfSync(); if( !cnt && !option ) { AddGeode( 2 ); // Set vertex positions } if( bbox ) { (geode->getGSet( 0 ))->setBound( 0, PFBOUND_STATIC ); geode->setBound( 0, PFBOUND_STATIC ); } float hh = float( cnt ); float ang = DEG_TO_RAD( -90.0 + hh ); float len = 4.0; v2.set( len * cos( ang ), len * sin( ang ), 0.0 ); pfVec3 v3; v3.add( v1, v2 ); v2.set( hh, 0.0, 0.0 ); chan[1]->setView( v3, v2 ); // Set view of top channel (rotates) pfFrame(); cnt++; } while( cnt < 720 ); pfuExitUtil(); pfExit(); return 0; } void OpenPipeWin(pfPipeWindow *pw_local) { int l1; pw_local->open(); l1 = 0; pfLightModel *light_model = new pfLightModel; float col, factor = 1.0; //(display_type & RGCD_DT_PROJECTOR) ? 0.3 : 1.0; //col = 1.0; // Temporary hack for desk-top col = 0.3 * factor; light_model->setAmbient( col, col, col ); light_model->apply(); col = 0.7 * factor; // 1.0f; l1 = 0; ls[l1] = new pfLight; ls[l1]->setColor( PFLT_DIFFUSE, col, col, col ); //ls[l1]->setPos( 0.0f, 0.0f, -1.0f, 0.0f ); l1++; ls[l1]->setPos( -1.0f, 0.0f, 0.0f, 0.0f ); l1++; ls[l1] = new pfLight; col = 0.4 * factor; // 0.7f; ls[l1]->setColor( PFLT_DIFFUSE, col, col, col ); //ls[l1]->setPos( -2.0f, -1.0f, 0.1f, 0.0f ); l1++; ls[l1]->setPos( 0.6f, 0.8f, 0.0f, 0.0f ); l1++; ls[l1] = new pfLight; col = 1.0 * factor; //0.4f; ls[l1]->setColor( PFLT_DIFFUSE, col, col, col ); //ls[l1]->setPos( 1.0f, 1.5f, 0.1f, 0.0f ); l1++; ls[l1]->setPos( 0.0f, 0.0f, 1.0f, 0.0f ); l1++; ls[l1] = new pfLight; col = 1.0 * factor; ls[l1]->setColor( PFLT_DIFFUSE, col, col, col ); ls[l1]->setPos( 0.0f, 0.0f, -1.0f, 0.0f ); l1++; ls[l1] = new pfLight; col = 0.2f * factor; ls[l1]->setColor( PFLT_DIFFUSE, col, col, col ); ls[l1]->setPos( 0.6f, -0.8f, 0.0f, 0.0f ); l1++; pfEnable(PFEN_LIGHTING); //pfOverride(PFSTATE_FRONTMTL, PF_ON); pfOverride(PFSTATE_LIGHTMODEL, PF_ON); pfAntialias( PFAA_OFF ); } static void DrawChannel (pfChannel *channel, void *data) { int l1; for( l1=0; l1on(); } channel->clear(); pfDraw(); } static pfGeode *AddGeode( const int option ) // // Add rectangular lineset // // option IN 0 (create geode but set all vertices to [0,0,0] // 1 (create but set vertices to non-zero) // 2 (set vertices to non-zero) // { static pfVec3 *vertices = 0; pfVec3 v1; int l1; pfGeode *geode = 0; pfVec3 va[5]; // Rectangle in plane of constant Y va[0].set( -0.5, 0.0, -0.5 ); va[1].set( 0.5, 0.0, -0.5 ); va[2].set( 0.5, 0.0, 0.5 ); va[3].set( -0.5, 0.0, 0.5 ); va[4].copy( va[0] ); if( !vertices ) { vertices = new pfVec3[5]; } v1.set( 0.0, -5.0, 1.0 ); for( l1=0; l1<5; l1++ ) { if( !option ) { (vertices + l1)->set( 0.0, 0.0, 0.0 ); } else { (vertices + l1)->add( va[l1], v1 ); } } if( option <= 1 ) { pfGeoSet *gset = new pfGeoSet(); gset->setPrimType( PFGS_LINESTRIPS ); gset->setNumPrims( 1 ); int *p_lengths = new int; *p_lengths = 5; gset->setPrimLengths( p_lengths ); pfVec4 *col = new pfVec4( 0.0, 1.0, 1.0, 1.0 ); gset->setAttr( PFGS_COLOR4, PFGS_OVERALL, col, 0 ); gset->setAttr( PFGS_COORD3, PFGS_PER_VERTEX, vertices, 0 ); pfVec3 *normals = new pfVec3( 0.0, 0.0, 1.0 ); gset->setAttr( PFGS_NORMAL3, PFGS_OVERALL, normals, 0 ); geode = new pfGeode; geode->addGSet( gset ); } return geode; }