29 #ifndef __SPACEWARESENSOR_H__
30 #define __SPACEWARESENSOR_H__
66 Types< SFRotation, SFFloat > > {
84 Types< SFVec3f, SFFloat > > {
101 virtual void setValue(
const Rotation &r,
int _id = 0 ) {
109 if(
static_cast< SpaceWareSensor *
>(owner)->accumulateTimeDependent->getValue() )
110 time_scale = current_time - last_time;
111 last_time = current_time;
113 value = ( r * time_scale ) * value;
128 virtual void setValue(
const Rotation &r,
int _id = 0 ) {
133 Vec3f euler_angles = temp_r.toEulerAngles();
135 Rotation( 1, 0, 0, euler_angles.x ), sws->id );
137 Rotation( 0, 1, 0, euler_angles.y ), sws->id );
139 Rotation( 0, 0, 1, euler_angles.z ), sws->id );
148 Vec3f euler_angles = temp_r.toEulerAngles();
150 Rotation( 1, 0, 0, euler_angles.x ), sws->id );
152 Rotation( 0, 1, 0, euler_angles.y ), sws->id );
154 Rotation( 0, 0, 1, euler_angles.z ), sws->id );
158 friend class ResetAccumulatedRotation;
169 virtual void setValue(
const Vec3f &v,
int _id = 0 ) {
177 if(
static_cast< SpaceWareSensor *
>(owner)->accumulateTimeDependent->getValue() )
178 time_scale = ( current_time - last_time ) * 0.025f;
179 last_time = current_time;
181 value = value + v * time_scale;
193 virtual void setValue(
const Vec3f &v,
int _id = 0 ) {
206 friend class ResetAccumulatedTranslation;
211 Inst< SFBool > _enabled = 0,
212 Inst< SFNode > _metadata = 0,
213 Inst< SFBool > _isActive = 0,
214 Inst< SFVec3f > _rawTranslation = 0,
215 Inst< SFRotation > _rawYaw = 0,
216 Inst< SFRotation > _rawPitch = 0,
217 Inst< SFRotation > _rawRoll = 0,
218 Inst< SFRotation > _rawRotation = 0,
219 Inst< ScaleTranslation > _instantTranslation = 0,
220 Inst< ScaleRotation > _instantYaw = 0,
221 Inst< ScaleRotation > _instantPitch = 0,
222 Inst< ScaleRotation > _instantRoll = 0,
223 Inst< ScaleRotation > _instantRotation = 0,
224 Inst< AccumulateTranslation > _accumulatedTranslation = 0,
225 Inst< AccumulateRotation > _accumulatedYaw = 0,
226 Inst< AccumulateRotation > _accumulatedPitch = 0,
227 Inst< AccumulateRotation > _accumulatedRoll = 0,
228 Inst< AccumulateRotation > _accumulatedRotation = 0,
229 Inst< SFFloat > _translationScale = 0,
230 Inst< SFFloat > _rotationScale = 0,
231 Inst< SFInt32 > _buttons = 0,
232 Inst< SFInt32 > _latestButtonPress = 0,
233 Inst< SFInt32 > _latestButtonRelease = 0,
234 Inst< SFBool > _accumulateTimeDependent = 0,
235 Inst< ResetAccumulatedTranslation > _resetAccumulatedTranslation = 0,
236 Inst< ResetAccumulatedRotation > _resetAccumulatedRotation = 0
240 if(
this == sws_instance )
422 ButtonData(
int _pressed,
424 int _current_state ) :
426 released( _released ),
427 current_state( _current_state ) {}
428 unsigned int pressed, released, current_state;
432 bool thread_motion_event;
434 vector< ButtonData > thread_buttons;
436 Vec3f thread_rotation;
438 Vec3f thread_translation;
441 bool thread_is_active;
453 H3DUniquePtr< H3DUtil::SimpleThread > thread_handle;
460 struct H3DAPI_API Update
464 (owner)->updateValues();
468 H3DUniquePtr< Update > update;
Contains the SFFloat field class.
Contains the SFInt32 field class.
Contains the SFRotation field class.
Contains the SFVec3f field class.
Header file for X3DSensorNode, X3D scene-graph node.
The SFFloat field contains one single-precision floating point number.
Definition: SFFloat.h:41
The SFRotation field contains one arbitrary Rotation.
Definition: SFRotation.h:41
The SFVec3f field contains a Vec3f.
Definition: SFVec3f.h:41
virtual void setValue(const Rotation &v, int id=0)
Set the value of the field.
Definition: SField.h:215
virtual void update()
Make the field up to date given that an event has occured.
Definition: SField.h:181
This class is an AutoUpdate class that sets the field accumulatedRotation to its input value and also...
Definition: SpaceWareSensor.h:125
virtual void update()
Make the field up to date given that an event has occured.
Definition: SpaceWareSensor.h:143
This class is an AutoUpdate class that sets the field accumulatedTranslation to its input value.
Definition: SpaceWareSensor.h:191
virtual void update()
Make the field up to date given that an event has occured.
Definition: SpaceWareSensor.h:199
This is a X3DSensorNode for reading values from a 3DConnexion motion controller such as the SpaceTrav...
Definition: SpaceWareSensor.h:55
H3DUniquePtr< AccumulateRotation > accumulatedYaw
The sum of all instantYaw values.
Definition: SpaceWareSensor.h:330
H3DUniquePtr< AccumulateRotation > accumulatedRotation
The sum of all instantRotation values.
Definition: SpaceWareSensor.h:351
H3DUniquePtr< ScaleTranslation > instantTranslation
rawTranslation scaled by rotationScale
Definition: SpaceWareSensor.h:288
H3DUniquePtr< SFRotation > rawYaw
Contains the current rotation around the x-axis as reported by the device.
Definition: SpaceWareSensor.h:257
H3DUniquePtr< ScaleRotation > instantPitch
rawPitch scaled by rotationScale
Definition: SpaceWareSensor.h:302
H3DUniquePtr< AccumulateRotation > accumulatedRoll
The sum of all instantRoll values.
Definition: SpaceWareSensor.h:344
H3DUniquePtr< SFInt32 > latestButtonPress
The button number of the last button that was pressed.
Definition: SpaceWareSensor.h:387
H3DUniquePtr< SFInt32 > buttons
Integer representing the current status of the buttons.
Definition: SpaceWareSensor.h:380
H3DUniquePtr< SFVec3f > rawTranslation
Contains the current translation as reported by the device.
Definition: SpaceWareSensor.h:249
H3DUniquePtr< SFBool > accumulateTimeDependent
If true the Accumulated-fields depends on time passed since last time accumulated was updated instead...
Definition: SpaceWareSensor.h:402
H3DUniquePtr< ResetAccumulatedTranslation > resetAccumulatedTranslation
Resets the value of accumulatedTranslation to its own value.
Definition: SpaceWareSensor.h:409
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: SpaceWareSensor.h:444
H3DUniquePtr< ResetAccumulatedRotation > resetAccumulatedRotation
Resets the value of accumulatedRotation to its own value.
Definition: SpaceWareSensor.h:417
H3DUniquePtr< ScaleRotation > instantRotation
Composite rotation of instantYaw, instantPitch and instantRoll.
Definition: SpaceWareSensor.h:316
H3DUniquePtr< SFRotation > rawRoll
Contains the current rotation around the z-axis as reported by the device.
Definition: SpaceWareSensor.h:273
H3DUniquePtr< SFFloat > translationScale
The scale factor for the instantTranslation field.
Definition: SpaceWareSensor.h:359
H3DUniquePtr< ScaleRotation > instantRoll
rawRoll scaled by rotationScale
Definition: SpaceWareSensor.h:309
H3DUniquePtr< SFFloat > rotationScale
The scale factor for the instant version of the different rotation fields.
Definition: SpaceWareSensor.h:368
H3DUniquePtr< ScaleRotation > instantYaw
rawYaw scaled by rotationScale
Definition: SpaceWareSensor.h:295
H3DUniquePtr< AccumulateRotation > accumulatedPitch
The sum of all instantPitch values.
Definition: SpaceWareSensor.h:337
H3DUniquePtr< SFRotation > rawPitch
Contains the current rotation around the y-axis as reported by the device.
Definition: SpaceWareSensor.h:265
H3DUniquePtr< AccumulateTranslation > accumulatedTranslation
The sum of all instantTranslation values.
Definition: SpaceWareSensor.h:323
H3DUniquePtr< SFInt32 > latestButtonRelease
The button number of the last button that was released.
Definition: SpaceWareSensor.h:394
H3DUniquePtr< SFRotation > rawRotation
Contains the current total rotation as reported by the device.
Definition: SpaceWareSensor.h:281
A template modifier class for adding type checking on the routes to any Field class.
Definition: TypedField.h:84
This abstract node type is the base type for all sensors.
Definition: X3DSensorNode.h:40
Type getValue(const char *s, const char *&rest)
Function that reads characters from a char * and converts them to a given type.
Definition: X3DFieldConversion.h:134
H3D API namespace.
Definition: Anchor.h:38
The AutoUpdate field is a template to force the BaseField to update itself as soon as an event is rec...
Definition: FieldTemplates.h:130
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194
This class is an AutoUpdate class that accumulates the rotation values routed to it,...
Definition: SpaceWareSensor.h:98
virtual void update()
Make the field up to date given that an event has occured.
Definition: SpaceWareSensor.h:106
This class is an AutoUpdate class that accumulates the Vec3f values routed to it, i....
Definition: SpaceWareSensor.h:166
virtual void update()
Make the field up to date given that an event has occured.
Definition: SpaceWareSensor.h:174
Updates itself to the Rotation routed to it where the angle is scaled by the scale factor.
Definition: SpaceWareSensor.h:66
virtual void update()
Make the field up to date given that an event has occured.
Definition: SpaceWareSensor.h:67
Updates itself to the SFVec3f routed to it scaled by the scale factor.
Definition: SpaceWareSensor.h:84
virtual void update()
Make the field up to date given that an event has occured.
Definition: SpaceWareSensor.h:85