Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

VRJugglerTracker.C

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr
00003  *cr            (C) Copyright 1995-2019 The Board of Trustees of the
00004  *cr                        University of Illinois
00005  *cr                         All Rights Reserved
00006  *cr
00007  *cr VRJuggler patches contributed by Martijn Kragtwijk: m.kragtwijk@rug.nl
00008  *cr
00009  ***************************************************************************/
00010 
00011 /***************************************************************************
00012  * RCS INFORMATION:
00013  *
00014  *      $RCSfile: VRJugglerTracker.C,v $
00015  *      $Author: johns $        $Locker:  $             $State: Exp $
00016  *      $Revision: 1.4 $       $Date: 2019/01/17 21:21:02 $
00017  *
00018  ***************************************************************************
00019  * DESCRIPTION:
00020  * a VRJuggler specific tracker device for VMD
00021  ***************************************************************************/
00022 #include "P_Tracker.h"
00023 #include "VRJugglerTracker.h"
00024 #include "VRJugglerScene.h"
00025 
00026 VRJugglerTracker::VRJugglerTracker(VRJugglerScene* scene)
00027   : VMDTracker(),
00028     mScene(scene)
00029 {
00030 
00031 }; // VRJuggler needs no initialization
00032 
00033 void VRJugglerTracker::update() {
00034 
00035   #define WAND_SENSOR     1
00036 
00037   
00038   //float units =5;// mScene->application->getDrawScaleFactor();
00039   float x,y,z; 
00040   mScene->getWandXYZ(x,y,z); 
00041 
00042      // Get the wand matrix
00043 //  vrPointGetRWFrom6sensor(&wand_location, WAND_SENSOR);
00044   pos[0] = x;//0.0;//wand_location.v[0];
00045   pos[1] = y;//0.0;//wand_location.v[1];
00046   pos[2] = z;//0.0;//wand_location.v[2];
00047 
00048   /* "classical" Euler angles */
00049   float azi, elev, roll;
00050 
00051   // XXX hack to get us by for now until VRJuggler can do this, or 
00052   // something like this.
00053   azi=0.0;  
00054   elev=0.0;
00055   roll=0.0;
00056   // CAVE version
00057   // CAVEGetWandOrientation(azi, elev, roll);
00058 
00059   Matrix4 rot;
00060 
00061   //  mScene->getWandRot(azi, elev, roll); // get the wand rot as euler angles (degrees)
00062   mScene->getWandRotMat(rot); // get the wand rot matrix
00063 
00064   /*  orient->identity();
00065   orient->rot(azi,'y');
00066   orient->rot(elev,'x');
00067   orient->rot(roll,'z');
00068   orient->rot(90,'y'); // to face forward (-z)
00069 */
00070   orient->loadmatrix(rot);
00071   orient->rot(90,'y'); // to face forward (-z)
00072 
00073   // change the tool such that it doesn't the wanda isn't at the tip but at the other end
00074   float displacementIn[3] = {0.5, 0, 0}; // why in x direction? 
00075   //float displacementIn[3] = {0.0, 0, 0}; // why in x direction? 
00076                                          //because the tool is originally pointing towards positive x?
00077   float displacementOut[3] = {0, 0, 0};
00078   
00079   orient->multpoint3d(displacementIn, displacementOut); // multiply displacement by rotation
00080                                // and ad it to position
00081   pos[0]+=displacementOut[0];
00082   pos[1]+=displacementOut[1];
00083   pos[2]+=displacementOut[2];
00084 }
00085 
00086 int VRJugglerTracker::do_start(const SensorConfig *config) {
00087   // Must check that we are actually running in VRJuggler here; if not, 
00088   // return 0.
00089 
00090 //  if (!config->require_freevr_name()) return 0;
00091 //  if (!config->have_one_sensor()) return 0;
00092   return 1;
00093 }

Generated on Fri Oct 11 02:44:59 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002