// // Copyright 1995, Silicon Graphics, Inc. // ALL RIGHTS RESERVED // // UNPUBLISHED -- Rights reserved under the copyright laws of the United // States. Use of a copyright notice is precautionary only and does not // imply publication or disclosure. // // U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND: // Use, duplication or disclosure by the Government is subject to restrictions // a n Technical Data and Computer Software clause at DFARS 252.227-7013 and/or // in similar or successor clauses in the FAR, or the DOD or NASA FAR // Supplement. Contractor/manufacturer is Silicon Graphics, Inc., // 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311. // // Permission to use, copy, modify, distribute, and sell this software // and its documentation for any purpose is hereby granted without // fee, provided that (i) the above copyright notices and this // permission notice appear in all copies of the software and related // documentation, and (ii) the name of Silicon Graphics may not be // used in any advertising or publicity relating to the software // without the specific, prior written permission of Silicon Graphics. // // THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, // EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY // WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. // // IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, // INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY // DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, // WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY // THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE // OR PERFORMANCE OF THIS SOFTWARE. // // // multichanC.C: Performer program to demonstrate multiple channels // in one pipe. Derived from simple.c // // $Revision: 1.11 $ // $Date: 1995/11/22 14:35:11 $ // // // Clases standar :------------- #include #include #include #include #include #include #include #include // Clases propias de INMER :------- #include "IMNDriverGC.h" static void OpenPipeWin(pfPipeWindow *pw); static void DrawChannel(pfChannel *chan, void *data); static void luces(pfScene* scene); // // Usage() -- print usage advice and exit. This // procedure is executed in the application process. // static void Usage (void) { pfNotify(PFNFY_FATAL, PFNFY_USAGE, "Usage: multichanC file.ext ....\n"); exit(1); } int main (int argc, char *argv[]) { float t = 0.0f, rotx2,roty2,rotz2, casco_x ,casco_y ,casco_z; // Coordenadas del campo de vision pfLight *luz1; IMNDriverGC mivar; pfGroup* mig; // pfType* tipo; pfVec3 vec, pos_mano, pos_casco; // Posicion del casco const char* nombre_tipo; pfDCS* dcs2; if (argc < 2) Usage(); // Initialize Performer pfInit(); // Use default multiprocessing mode based on number of // processors. // pfMultiprocess( PFMP_APP_CULL_DRAW ); // Load all loader DSO's before pfConfig() forks pfdInitConverter(argv[1]); // Configure multiprocessing mode and start parallel // processes. // pfConfig(); pfDCS* dcs1 = new pfDCS(); // Attach loaded file to a pfScene. pfScene *scene = new pfScene; // Append to PFPATH additional standard directories where // geometry and textures exist // pfFilePath(".:/usr/share/Performer/data"); // Read a single file, of any known type. pfNode *root = pfdLoadFile(argv[1]); if (root == NULL) { pfExit(); exit(-1); } // determine extent of scene's geometry pfSphere bsphere; root->getBound(&bsphere); scene->addChild(root); // Create a pfLightSource and attach it to scene. // pfType* tipo;->addChild(new pfLightSource); /*luces(scene);*/ // Configure and open GL window pfPipe *p = pfGetPipe(0); pfPipeWindow *pw = new pfPipeWindow(p); pw->setName("IRIS Performer"); pw->setOriginSize(0, 0, 640, 420); pw->setConfigFunc(OpenPipeWin); pw->config(); // Create and configure a pfChannel. pfChannel *chan = new pfChannel(p); chan->setScene(scene); //chan->setFOV(45.0f, 0.0f); /*for (int loop=0; loop < 2; loop++) { chan[loop] = new pfChannel(p); chan[loop]->setTravFunc(PFTRAV_DRAW,DrawChannel); chan[loop]->setScene(scene); chan[loop]->setNearFar(1.0f, 10.0f * bsphere.radius); chan[loop]->setFOV(45.0f, 0.0f); pfFrameStats *fstats = chan[loop]->getFStats(); fstats->setClass(PFSTATS_ENGFX, PFSTATS_ON); }*/ /*chan[0]->setViewport(0.0f, 0.0f, 0.0f, 0.5f); chan[1]->setViewport(0.5f, 1.0f, 0.0f, 0.5f); chan[0]->setViewport(0.5f, 1.0f, 0.5f, 1.0f); chan[1]->setViewport(0.0f, 0.5f, 0.5f, 1.0f);*/ casco_x = 0.077f; casco_y = -0.4f; casco_z = 1.075f; //scene->addChild(dcs1); mig = mivar.ObtenerNodoMano(0); pfSCS* scss ; pfDCS* niidea; scene->addChild(mig); scss = (pfSCS*)mig->getChild(0); niidea = (pfDCS*)scss->getChild(0); const char *nombre1; pfType *tipo; // tipo = niidea->getType(); nombre1 = pfGetTypeName(niidea); pfNotify(NULL,NULL,"tipo = %s",nombre1); //d1->addChild(mig); mivar.Actualizar(); pos_mano = mivar.ObtenerPosGuante(0); int i; i = niidea->getNumChildren(); pfNotify(NULL,NULL,"hijos del DCS del guante= %i",i); pfDCS* hijoDCS = new pfDCS(); hijoDCS =(pfDCS*)niidea->getChild(0); nombre1 = pfGetTypeName(hijoDCS); pfNotify(NULL,NULL,"hijoDCS = %s",nombre1); pfNode* hijohijoDCS; hijohijoDCS = hijoDCS->getChild(0); nombre1 = pfGetTypeName(hijohijoDCS); pfNotify(NULL,NULL,"hijo del hijoDCS = %s",nombre1); //vt_set_tracker_offset(0,origen); //d1->setTrans(0,0,0); /*-pos_mano[0],-pos_mano[1], -pos_mano[2]); */ mivar.Actualizar(); mivar.ObtenerRotCasco(rotx2,roty2,rotz2); pos_casco = mivar.ObtenerPosCasco(); chan->setNearFar(3.0,1000.0); /*chan[1]->setNearFar(3.0,1000.0);*/ pfMatrix res,rotx,roty,rotz,girox; res.makeTrans(pos_casco[0],pos_casco[1],pos_casco[2]); rotz.makeRot(rotz2*180/3.14,0,0,1); roty.makeRot(roty2*180/3.14,0,1,0); rotx.makeRot(rotx2*180/3.14,1,0,0); girox.makeRot(-90,0,1,0); //res.preMult(rotz); //res.preMult(roty); //res.preMult(rotx); //res.preMult(girox); while (true) { i--; float hv,pv,rv,xv,yv,zv,s, c, coord_x, coord_y, coord_z; pfCoord * view = new pfCoord(); pfVec3 posguante; // Go to sleep until next frame time. pfSync(); // Actualizamos nueva posicion. //posguante = mivar.ObtenerPosGuante(0); //view.xyz.set(0.0f,0.0f,50.0f); //view.hpr.set(0.0f,0.0f,0.0f); //view.xyz.set(0.0f,0.0f,50.0f); //view.hpr.set(0.0f,-100.0f,0.0f); mivar.Actualizar(); mivar.ObtenerRotCasco(rotx2,roty2,rotz2); pos_casco = mivar.ObtenerPosCasco(); res.makeTrans(pos_casco[0],pos_casco[1],pos_casco[2]); rotz.makeRot(rotz2*180/3.14,0,0,-1); roty.makeRot(roty2*180/3.14,0,1,0); rotx.makeRot(rotx2*180/3.14,-1,0,0); res.preMult(rotz); res.preMult(roty); res.preMult(rotx); res.preMult(girox); res.getOrthoCoord(view); hv = view->hpr[0]; pv = view->hpr[1]; rv = view->hpr[2]; view->hpr[0] = 45 + pv; view->hpr[1] = rv; view->hpr[2] = hv - 90; //view->xyz[0] = view->xyz[0] + 50; //view->xyz[1] = view->xyz[1] + 50; //view->xyz[2] = view->xyz[2] + 50; /* Cambios iniciales. ---- xv = view->hpr[2]; view->hpr[2]=-view->hpr[1]; view->hpr[1] = xv; xv = view->hpr[2]; view->hpr[2]=-view->hpr[0]; view->hpr[0] = xv; view->hpr[2] += +90; view->hpr[0] = -view->hpr[0]+45; view->hpr[2] =- view->hpr[2]; ---- Fin cambios iniciales. */ view->xyz[1] += 100; chan->setView(view->xyz, view->hpr); //chan->setViewMat(res); // Calculamos nueva posicion. //mivar.ObtenerRotCasco(rotx2,roty2,rotz2); //mivar.ObtenerRotGuante(0,rotx2,roty2,rotz2); printf("1º -> x -> %f",view->xyz[0]); printf("2º -> y -> %f",view->xyz[1]); printf("3º -> z -> %f\n",view->xyz[2]); // pos_casco = mivar.ObtenerPosCasco(); // Initiate cull/draw for this frame. pfFrame(); } // Terminate parallel processes and exit. pfExit(); return 0; } // // OpenPipeWin() -- create a GL window: set up the // window system, IRIS GL, and IRIS Performer. This // procedure is executed for each window in the draw process // for that pfPipe. // static void OpenPipeWin(pfPipeWindow *pw) { pw->open(); // create a light source in the "south-west" (QIII) pfLight *Sun = new pfLight; Sun->setPos(0.2f, -0.3f, 0.6f, 0.0f); } static void DrawChannel (pfChannel *, void *) { static pfVec4 clr[] = { pfVec4(1.0f, 0.0f, 0.0f, 1.0f), pfVec4(0.0f, 0.0f, 1.0f, 1.0f) }; static int i=0; // erase framebuffer and draw Earth-Sky model pfClear(PFCL_COLOR | PFCL_DEPTH, &clr[i]); i ^= 1; // invoke Performer draw-processing for this frame pfDraw(); } static void luces(pfScene* scene) { pfLightSource *lamp = new pfLightSource(); /* set direction of infinite light source */ lamp->setPos( 0.1f, -0.3f, 1.6f, 0.0f); /* set light source color */ lamp->setColor(PFLT_DIFFUSE, 0.9f, 0.9f, 0.9f); /* add lamp to scene */ scene->addChild(lamp); }