RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
vrpn_Tracker_AnalogFly.h
1#ifndef INCLUDED_ANALOGFLY
2#define INCLUDED_ANALOGFLY
3
4#include <quat.h> // for q_matrix_type
5#include <stdio.h> // for NULL
6
7#include "vrpn_Analog.h" // for vrpn_ANALOGCB, etc
8#include "vrpn_Button.h" // for vrpn_BUTTONCB, etc
9#include "vrpn_Configure.h" // for VRPN_API, VRPN_CALLBACK
10#include "vrpn_Shared.h" // for timeval
11#include "vrpn_Tracker.h" // for vrpn_Tracker
12#include "vrpn_Types.h" // for VRPN_FALSE, vrpn_FALSE
13
14class VRPN_API vrpn_Connection;
16
17// This parameter is passed to the constructor for the AnalogFly; it describes
18// the channel mapping and parameters of that mapping, as well as the button
19// that will be used to reset the tracker when it is pushed. Any entry which
20// has a NULL pointer for the name is disabled.
21
22class VRPN_API vrpn_TAF_axis {
23
24 public:
25
26 vrpn_TAF_axis (void)
27 { name = NULL; channel = 0; offset = 0.0f; thresh = 0.0f;
28 scale = 1.0f; power = 1.0f; };
29
30 char * name; //< Name of the Analog device driving this axis
31 int channel; //< Which channel to use from the Analog device
32 float offset; //< Offset to apply to values from this channel to reach 0
33 float thresh; //< Threshold to apply after offset within which values count as zero
34 float scale; //< Scale applied to values after offset and threshold
35 float power; //< Power to which values are taken after scaling
36};
37
39
40 public:
41
43 x.name = y.name = z.name =
44 sx.name = sy.name = sz.name = reset_name = clutch_name = NULL;
45 }
46
49
52
54
55 char * reset_name;
56 int reset_which;
57
59 // large distances
60
62 int clutch_which;
63};
64
65class VRPN_API vrpn_Tracker_AnalogFly; // Forward reference
66
67class VRPN_API vrpn_TAF_fullaxis {
68public:
69 vrpn_TAF_fullaxis (void) { ana = NULL; value = 0.0; af = NULL; };
70
71 vrpn_TAF_axis axis;
74 double value;
75};
76
78// tracker into a tracker by interpreting the joystick
79// positions as either position or velocity inputs and "flying" the user
80// around based on analog values.
81// The "absolute" parameter tells whether the tracker integrates differential
82// changes (the default, with FALSE) or takes the analog values as absolute
83// positions or orientations.
84// The mapping from analog channels to directions (or orientation changes) is
85// described in the vrpn_Tracker_AnalogFlyParam parameter. For translations,
86// values above threshold are multiplied by the scale and then taken to the
87// power; the result is the number of meters (or meters per second) to move
88// in that direction. For rotations, the result is taken as the number of
89// revolutions (or revolutions per second) around the given axis.
90// Note that the reset button has no effect on an absolute tracker.
91// The time reported by absolute trackers is as of the last report they have
92// had from their analog devices. The time reported by differential trackers
93// is the local time that the report was generated. This is to allow a
94// gen-locked camera tracker to have its time values passed forward through
95// the AnalogFly class.
96
97// If reportChanges is TRUE, updates are ONLY sent if there has been a
98// change since the last update, in which case they are generated no faster
99// than update_rate.
100
101// If worldFrame is TRUE, then translations and rotations take place in the
102// world frame, rather than the local frame. Useful for a simulated wand
103// when doing desktop testing of immersive apps - easier to keep under control.
104
105class VRPN_API vrpn_Tracker_AnalogFly : public vrpn_Tracker {
106 public:
107 vrpn_Tracker_AnalogFly (const char * name, vrpn_Connection * trackercon,
109 float update_rate, bool absolute = vrpn_FALSE,
110 bool reportChanges = VRPN_FALSE, bool worldFrame = VRPN_FALSE);
111
112 virtual ~vrpn_Tracker_AnalogFly (void);
113
114 virtual void mainloop ();
115
116 protected:
117 double d_update_interval; //< How long to wait between sends
118 struct timeval d_prevtime; //< Time of the previous report
119 bool d_absolute; //< Report absolute (vs. differential)?
120 bool d_reportChanges;
121 bool d_worldFrame;
122
123 vrpn_TAF_fullaxis d_x, d_y, d_z, d_sx, d_sy, d_sz;
124 vrpn_Button_Remote * d_reset_button;
125 int d_which_button;
126
127 vrpn_Button_Remote * d_clutch_button;
128 int d_clutch_which;
129 bool d_clutch_engaged;
130 bool d_clutch_was_off;
131
132 q_matrix_type d_initMatrix, d_currentMatrix, d_clutchMatrix;
133
134 void update_matrix_based_on_values (double time_interval);
135 void convert_matrix_to_tracker (void);
136
137 bool shouldReport (double elapsedInterval) const;
138
139 int setup_channel (vrpn_TAF_fullaxis * full);
140 int teardown_channel (vrpn_TAF_fullaxis * full);
141 virtual void reset(void);
142
143 static void VRPN_CALLBACK handle_analog_update (void * userdata,
144 const vrpn_ANALOGCB info);
145 static void VRPN_CALLBACK handle_reset_press (void * userdata, const vrpn_BUTTONCB info);
146 static void VRPN_CALLBACK handle_clutch_press (void * userdata, const vrpn_BUTTONCB info);
147 static int VRPN_CALLBACK handle_newConnection(void *, vrpn_HANDLERPARAM);
148};
149
150#endif
定义 vrpn_Analog.h:181
定义 vrpn_Button.h:251
Generic connection class not specific to the transport mechanism.
定义 vrpn_Connection.h:562
定义 vrpn_Tracker_AnalogFly.h:22
定义 vrpn_Tracker_AnalogFly.h:67
定义 vrpn_Tracker_AnalogFly.h:38
char * reset_name
Button device that is used to reset the matrix to the origin
定义 vrpn_Tracker_AnalogFly.h:55
vrpn_TAF_axis x
Translation along each of these three axes
定义 vrpn_Tracker_AnalogFly.h:48
char * clutch_name
Clutch device that is used to enable relative motion over
定义 vrpn_Tracker_AnalogFly.h:61
vrpn_TAF_axis sx
Rotation in the positive direction about the three axes
定义 vrpn_Tracker_AnalogFly.h:51
This class will turn an analog device such as a joystick or a camera
定义 vrpn_Tracker_AnalogFly.h:105
virtual void mainloop()
定义 vrpn_Tracker.h:49
定义 vrpn_Analog.h:168
定义 vrpn_Button.h:226
This structure is what is passed to a vrpn_Connection message callback.
定义 vrpn_Connection.h:41