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

P_Tracker.h

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  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: P_Tracker.h,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.30 $       $Date: 2019/01/17 21:21:01 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  * This is Paul's new Tracker code -- pgrayson@ks.uiuc.edu
00019  *
00020  * An object representing a connection to a machine that controls 3d
00021  * input devices (optionally with buttons, force-feedback, etc). One
00022  * connection may control one or many devices, so there needs to be a
00023  * global list of trackers which the Sensors peruse when first being
00024  * initialized.
00025  *
00026  ***************************************************************************/
00027 
00028 #ifndef VMDTRACKER_H
00029 #define VMDTRACKER_H
00030 
00031 #include "Matrix4.h"
00032 #include "P_SensorConfig.h"
00033 
00065 
00066 
00067 
00068 
00069 
00070 
00071 
00072 class VMDTracker { 
00073  private:
00074   float scale;         
00075   float offset[3];
00076   float offset_pos[3];
00077 
00078   Matrix4 left_rot, right_rot;
00079 
00080  protected:
00081   int dim;             
00082 
00083   float pos[3];
00084   Matrix4 *orient;
00085   Matrix4 rot_orient;
00086 
00087   void moveto(float x, float y, float z) {
00088     pos[0] = x; pos[1] = y; pos[2] = z;
00089   }
00090 
00092   virtual int do_start(const SensorConfig *) { return 1; }
00093 
00094  public:
00096   VMDTracker();
00097   virtual ~VMDTracker();
00098 
00100   virtual const char *device_name() const = 0;
00101 
00102   virtual VMDTracker *clone() = 0;
00103 
00106   virtual int start(const SensorConfig *);
00107   virtual void update() = 0;
00108   virtual int alive() = 0; // am I alive?
00109   const float *position() { 
00110     offset_pos[0] = scale*(offset[0] + pos[0]);
00111     offset_pos[1] = scale*(offset[1] + pos[1]);
00112     offset_pos[2] = scale*(offset[2] + pos[2]);
00113     return offset_pos;
00114   }
00115   inline const Matrix4 &orientation() { 
00116     rot_orient.loadmatrix(left_rot);
00117     rot_orient.multmatrix(*orient);
00118     rot_orient.multmatrix(right_rot);
00119     return rot_orient;    
00120   }
00121 
00122   void set_offset(const float o[3]) {
00123     offset[0] = o[0];
00124     offset[1] = o[1];
00125     offset[2] = o[2];
00126   }
00127   const float *get_offset() const { return offset; }
00128 
00129   void set_scale(float s) { scale = s;    }
00130   float get_scale() const { return scale; }
00131 
00132   void set_right_rot(const Matrix4 *right) { right_rot = *right; }
00133   void set_left_rot(const Matrix4 *left)   { left_rot = *left;   }
00134 
00137   int dimension() const { return dim; }
00138 };
00139 
00140 #endif
00141 

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