vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InputConnector.h
Go to the documentation of this file.
1 #pragma once
2 
3 
4 
5 # ifdef INPUTCONNECTOR_LIBRARY
6 # define INPUTCONNECTOR_EXPORT __declspec(dllexport)
7 # else
8 # define INPUTCONNECTOR_EXPORT __declspec(dllimport)
9 #endif
10 
11 
12 using namespace vrecko;
13 
14 typedef struct
15 {
17  string senderString;
18  string inputPin;
19 }Receiver;
20 
21 
22 typedef std::map<int, Receiver> ReceiversList;
23 
24 
25 namespace APInputConnector
26 {
27 
28 // if needed, this can be increased to any value
29 // see also 'OptiTrack.h' and 'GUI_Controller.h', some limitations is also there
30 // Kinect uses 20 points
31 #define SENSOR_MAX_COUNT 20
32 
33 
35 
46 {
47 public:
48 
50  ~InputConnector();
51 
52 
53  bool initialize(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *parametersNode);
54 
55  // New way of processing incoming events can't be used here
56  // because inputPins aren't known at compile time and therefore relevant methods can't be defined
58  virtual void processEvent(const std::string &input_name, VreckoMessage *value);
59 
60  void processAction( int sensorNumber, VreckoMessage * value, const std::string & input_name );
61 
62  void ProcessOrientation( int sensorNumber, VreckoMessage * value, const std::string & input_name );
63 
64  void processSensorTransformation( int sensorNumber, VreckoMessage * value, const std::string & input_name );
65 
67  static int parseSensorNumber( const std::string &input_name );
68 
70  static std::string parseEventName( const std::string &input_name );
71 
72  void update();
73 
74 
75 
76 
77 
78 protected:
79 
80 
81  osg::Vec3 _lastKnownPositions[SENSOR_MAX_COUNT];
82  osg::Quat _lastKnownOrientations[SENSOR_MAX_COUNT];
83  unsigned int _lastKnownPointedObjects[SENSOR_MAX_COUNT];
84  osg::Vec3 _lastCheckedPositions[SENSOR_MAX_COUNT];
85 
86  //key - action string, value - type string
87  std::map<string, string> _actionMap;
88 
89  //key - action, value - map of all receivers with non-zero priority
90  std::map<string, ReceiversList *> _outputMappingsWithPriorities;
91 
93 
100  bool parseInputDevice( XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *deviceNode );
101 
103 
111  bool parseInputMappingPair( string deviceID, XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *pairNode );
112 
113  bool parseSenderReceiver(std::string sr, bool isSender, BaseClass **pEntity, bool bNoErrorOutput);
114 
116 
124  std::vector<XERCES_CPP_NAMESPACE_QUALIFIER DOMNode*> *getChildNodesbyName( XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* parentNode, const string childNodeName );
125  bool parseReceiverAbility( XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * ChainPairNode );
126  bool parseOutputMappingPair( vrecko::Ability * receiverAbility, std::string receiverString, XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *pairNode );
127  bool processChainofResponsibility( ReceiversList *receivers, MessageBool * value );
128 
129  // for backward compatibility only
130  DECLARE_OUTPUT(Sensor_0_position, MessageVec3);
131  DECLARE_OUTPUT(Sensor_0_orientation, MessageQuat);
132 
133  DECLARE_OUTPUT(Sensor_1_position, MessageVec3);
134  DECLARE_OUTPUT(Sensor_1_orientation, MessageQuat);
135 
136 
137  // for answering request about actual position and orientation
138  DECLARE_REQUEST_INPUT(SensorPosition, MessageInt, MessageVec3);
139  DECLARE_REQUEST_INPUT(SensorOrientation, MessageInt, MessageQuat);
140  DECLARE_REQUEST_INPUT(SensorTransformation, MessageInt, MessageSensorTransformation);
141 
142  // dedicated for communication with dynamic menu ability - beware of DIFFERENT ID NUMBERING
143  DECLARE_REQUEST_INPUT(MenuSensorPosition, MessageInt, MessageVec3);
144 
145  //for answering about actually pointed objects - used by GUI, DAEnvironment, e.g.
146  DECLARE_REQUEST_INPUT(SelectedObjectID, MessageInt, MessageObjectID);
147 
148  //to find what object is selected
149  DECLARE_REQUEST_OUTPUT(SelectionByPointerPos, MessageVec3, MessageObjectID);
150 
151  //not used at all
152  //bool parseTriggerString( const string *fullActionString, string *action, bool *value );
153 };
154 
155 }