00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef ARCHON_X3D_MOUSE_H
00021 #define ARCHON_X3D_MOUSE_H
00022
00029 #include <archon/x3d/server/core.H>
00030 #include <archon/x3d/server/scene.H>
00031
00032 namespace Archon
00033 {
00034 namespace X3D
00035 {
00036 using namespace Math;
00037
00041 struct PointingDeviceSensorNode: SensorNode
00042 {
00043 static const NodeType *type;
00044
00045 protected:
00046 PointingDeviceSensorNode(): isOver(false) {}
00047
00048 private:
00049 friend class Viewer;
00050 friend void initializeMouseComponent();
00051
00052 string description;
00053 bool isOver;
00054
00055 EventSource descriptionChanged;
00056 EventSource isOverChanged;
00057
00058 Time descriptionStamp;
00059
00068 virtual void onDisable();
00069 };
00070
00071
00075 struct DragSensorNode: PointingDeviceSensorNode
00076 {
00077 static const NodeType *type;
00078
00079 protected:
00080 DragSensorNode():
00081 autoOffset(true), trackPoint(0, 0, 0) {}
00082
00083 private:
00084 friend class Viewer;
00085 friend void initializeMouseComponent();
00086
00087 bool autoOffset;
00088 Vector3 trackPoint;
00089
00090 EventSource autoOffsetChanged;
00091 EventSource trackPointChanged;
00092
00093 Time autoOffsetStamp;
00094 };
00095
00096
00100 struct PlaneSensor: DragSensorNode
00101 {
00102 static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00103 {
00104 return new PlaneSensor(c);
00105 }
00106
00107 static const NodeType *type;
00108 const NodeType *getType() const { return type; }
00109
00110 PlaneSensor(BackRef<ExecutionContext> c):
00111 NodeBase(c),
00112 maxPosition(-1, -1), minPosition(0, 0),
00113 offset(0, 0, 0), translation(0, 0, 0) {}
00114
00115 private:
00116 friend class Viewer;
00117 friend void initializeMouseComponent();
00118
00119 Vector2 maxPosition;
00120 Vector2 minPosition;
00121 Vector3 offset;
00122 Vector3 translation;
00123
00124 EventSource maxPositionChanged;
00125 EventSource minPositionChanged;
00126 EventSource offsetChanged;
00127 EventSource translationChanged;
00128
00129 Time maxPositionStamp;
00130 Time minPositionStamp;
00131 Time offsetStamp;
00132 };
00133
00134
00138 struct SphereSensor: DragSensorNode
00139 {
00140 static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00141 {
00142 return new SphereSensor(c);
00143 }
00144
00145 static const NodeType *type;
00146 const NodeType *getType() const { return type; }
00147
00148 SphereSensor(BackRef<ExecutionContext> c):
00149 NodeBase(c),
00150 offset(Vector3(0, 1, 0), 0), rotation(Vector3(0, 1, 0), 0) {}
00151
00152 private:
00153 friend class Viewer;
00154 friend void initializeMouseComponent();
00155
00156 Rotation3 offset;
00157 Rotation3 rotation;
00158
00159 EventSource offsetChanged;
00160 EventSource rotationChanged;
00161
00162 Time offsetStamp;
00163 };
00164
00165
00169 struct CylinderSensor: DragSensorNode
00170 {
00171 static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00172 {
00173 return new CylinderSensor(c);
00174 }
00175
00176 static const NodeType *type;
00177 const NodeType *getType() const { return type; }
00178
00179 CylinderSensor(BackRef<ExecutionContext> c):
00180 NodeBase(c), diskAngle(M_PI/12),
00181 maxAngle(-1), minAngle(0),
00182 offset(0), rotation(Vector3(0, 1, 0), 0) {}
00183
00184 private:
00185 friend class Viewer;
00186 friend void initializeMouseComponent();
00187
00188 double diskAngle;
00189 double maxAngle;
00190 double minAngle;
00191 double offset;
00192 Rotation3 rotation;
00193
00194 EventSource diskAngleChanged;
00195 EventSource maxAngleChanged;
00196 EventSource minAngleChanged;
00197 EventSource offsetChanged;
00198 EventSource rotationChanged;
00199
00200 Time diskAngleStamp;
00201 Time maxAngleStamp;
00202 Time minAngleStamp;
00203 Time offsetStamp;
00204 };
00205
00206
00210 struct TouchSensorNode: PointingDeviceSensorNode
00211 {
00212 static const NodeType *type;
00213
00214 protected:
00215 TouchSensorNode() {}
00216
00217 private:
00218 friend class Viewer;
00219 friend void initializeMouseComponent();
00220
00221 Time touchTime;
00222
00223 EventSource touchTimeChanged;
00224 };
00225
00226
00230 struct TouchSensor: TouchSensorNode
00231 {
00232 static Ref<NodeBase> instantiate(BackRef<ExecutionContext> c)
00233 {
00234 return new TouchSensor(c);
00235 }
00236
00237 static const NodeType *type;
00238 const NodeType *getType() const { return type; }
00239
00240 TouchSensor(BackRef<ExecutionContext> c):
00241 NodeBase(c),
00242 hitNormal(0, 0, 0), hitPoint(0, 0, 0),
00243 hitTexCoord(0, 0) {}
00244
00245 private:
00246 friend class Viewer;
00247 friend void initializeMouseComponent();
00248
00249 Vector3 hitNormal;
00250 Vector3 hitPoint;
00251 Vector2 hitTexCoord;
00252
00253 EventSource hitNormalChanged;
00254 EventSource hitPointChanged;
00255 EventSource hitTexCoordChanged;
00256 };
00257 }
00258 }
00259
00260 #endif // ARCHON_X3D_MOUSE_H