home *** CD-ROM | disk | FTP | other *** search
/ VRML Tools for 3D Cyberspace / VRML_Tools_For_3D_Cyberspace.iso / amber / include / sensor.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-01  |  3.4 KB  |  145 lines

  1. //**********************************************************************
  2. //  DIVE Laboratories, Inc.
  3. //  Copyright(c) 1995
  4. //  All rights reserved.
  5. //  FILE:   SENSOR.HPP
  6. //
  7. //  DESCRIPTION
  8. //  This file provides the function prototypes for the sensorClass
  9. //
  10. //  Author: M. Doucet
  11. //
  12. //  Modification History:
  13. //  7/6/95    Created
  14. //
  15. //**********************************************************************
  16. #ifndef _SENSOR_HPP
  17. #define _SENSOR_HPP
  18.  
  19. #ifdef AMBER_DEBUG_LIB
  20. #define _DEBUG
  21. #endif
  22. #ifdef WIN32
  23. #include <windows.h>    // includes basic windows functionality
  24. #endif
  25. #ifdef AMBER_DEBUG_LIB
  26. #undef _DEBUG
  27. #endif
  28.  
  29. #include "slink.hpp"
  30. #include "vector.hpp"
  31. #include "channel.hpp"
  32. #include "geometry.hpp"
  33. #include "quat.hpp"
  34.  
  35. typedef enum {_NOME, _LBD, _LBU, _MBD, _MBU, _RBD, _RBU, _MM} mouseEventEnum;
  36. typedef enum {NO_COM, COM1, COM2, COM3, COM4} portEnumType;
  37. typedef enum {NO_ANGLES, ABSOLUTE_ANGLES, DELTA_ANGLES} sensorAngleEnumType;
  38. typedef enum {NO_POSITIONS, ABSOLUTE_POSITIONS, DELTA_POSITIONS} sensorPositionEnumType;
  39.  
  40. class sensorClass {
  41.  
  42. private:
  43.  
  44.     channelClass  *ch;
  45.     geometryClass *geo;
  46.     sLinkClass        channelList;
  47.     sLinkClass        geometryList;
  48.  
  49.     I3                 rotConstraint, posConstraint;
  50.     V3             rotSwitch, tranSwitch;
  51.  
  52.     vectorClass       frame[3], translation;
  53.     quatClass      quat, qi, bias;
  54.  
  55.     int                 rIndex, pIndex, filterSize, filterLastWeight;
  56.  
  57.     V3                 rot, rBuf[20], rTot, lastRot;
  58.     V3                     loc, pBuf[20], pTot, lastLoc;
  59.  
  60.     sensorAngleEnumType    sensorAngle;
  61.     sensorPositionEnumType sensorPosition;
  62.  
  63. protected:
  64.  
  65.     // Port information that is used by the driver
  66.     //
  67. #ifdef INDIGO2
  68.    int hCom;
  69. #else
  70.     void *hCom;
  71. #endif
  72.     char                  in[255], out[255];
  73.     portEnumType     commPort;
  74.     int              baudRate;
  75.     unsigned long     actual;
  76.     unsigned long     avail, msg;
  77.     int                isOpen, isAlive;
  78.     float          linearScaling, rotationalScaling;
  79.  
  80.     // Opening and closing of the sensor
  81.     //
  82.     int  sOpen();
  83.     void sClose();
  84.  
  85. public:
  86.  
  87.     // Filter functions
  88.     //
  89.     void setFilterSize(int fs=5);
  90.     void setFilterLastWeight(int fw=2);
  91.  
  92.       // Attaching channels and geometries
  93.     //
  94.     void attachChannel(channelClass *ch);
  95.     void removeChannel(channelClass *ch);
  96.  
  97.     void attachGeometry(geometryClass *geo);
  98.     void removeGeometry(geometryClass *geo);
  99.  
  100.     // Angular and linear constraints
  101.     //
  102.      void setRotConstraint(int axis);
  103.      void setPosConstraint(int axis);
  104.      void clearRotConstraint(int axis);
  105.      void clearPosConstraint(int axis);
  106.      void clearAllConstraints();
  107.  
  108.     // Switch directions
  109.     void switchRotation(int axis);
  110.     void switchTranslation(int axis);
  111.  
  112.     // Angle and position updating (angles must be in radians)
  113.     //
  114.     void updateAngles(V3 angle);
  115.     void updatePositions(V3 pos);
  116.     void update();
  117.     void getAngles(V3 angle, int smoothed=FALSE);
  118.     void getPositions(V3 pos, int smoothed=FALSE);
  119.  
  120.     // Scaling
  121.     //
  122.     void  setRotationalScaling(float val);
  123.     void  setLinearScaling(float val);
  124.     float getRotationalScaling();
  125.     float getLinearScaling();
  126.  
  127.     // Rotate frame orientation
  128.     //
  129.     void rotate(int axis, float rads);
  130.     void setBias(quatClass q);
  131.  
  132.     virtual void mouseEvent(mouseEventEnum event, I2 point, void *wnd) = 0;
  133.  
  134.     sensorClass(portEnumType           port,
  135.                     int                    baud,
  136.                     sensorAngleEnumType    sa,
  137.                     sensorPositionEnumType sp,
  138.                     int useMouseHook);
  139.  
  140.     ~sensorClass();
  141.  
  142. };
  143.  
  144. #endif
  145.