#include <SimPosition.h>
Inheritance diagram for gadget::SimPosition:


Public Types | |
| enum | Key { FORWARD = 0, BACK = 1, LEFT = 2, RIGHT = 3, UP = 4, DOWN = 5, ROTR = 6, ROTL = 7, ROTU = 8, ROTD = 9, ROT_ROLL_CCW = 10, ROT_ROLL_CW = 11, NUM_POS_CONTROLS = 12 } |
| Constants for the key array. More... | |
| enum | CoordSystem { LOCAL = 0, GLOBAL = 1 } |
| Const for coord system selection. More... | |
Public Methods | |
| SimPosition () | |
| virtual | ~SimPosition () |
| virtual bool | config (jccl::ConfigElementPtr element) |
| bool | startSampling () |
| These functions don't do anything. More... | |
| bool | stopSampling () |
| bool | sample () |
| virtual void | updateData () |
| Updates the data. More... | |
| void | operator delete (void *p) |
| Invokes the global scope delete operator. More... | |
Static Public Methods | |
| std::string | getElementType () |
Protected Methods | |
| virtual void | destroy () |
| Deletes this object. More... | |
Simulates a positional device from an event source. This class should not be accessed directly by the user.
Definition at line 53 of file SimPosition.h.
|
|
Constants for the key array.
Definition at line 57 of file SimPosition.h.
00058 {
00059 FORWARD = 0,
00060 BACK = 1,
00061 LEFT = 2,
00062 RIGHT = 3,
00063 UP = 4,
00064 DOWN = 5,
00065 ROTR = 6,
00066 ROTL = 7,
00067 ROTU = 8,
00068 ROTD = 9,
00069 ROT_ROLL_CCW = 10,
00070 ROT_ROLL_CW = 11,
00071 NUM_POS_CONTROLS = 12
00072 };
|
|
|
Const for coord system selection.
Definition at line 75 of file SimPosition.h.
|
|
|
Definition at line 82 of file SimPosition.h. References LOCAL.
|
|
|
Definition at line 89 of file SimPosition.h.
00089 {;}
|
|
|
Reimplemented from gadget::Position. Definition at line 56 of file SimPosition.cpp. References NUM_POS_CONTROLS.
00057 {
00058 if (! (Input::config(element) && Position::config(element) &&
00059 SimInput::config(element)) )
00060 {
00061 return false;
00062 }
00063
00064 mDTrans = element->getProperty<float>("translation_delta");
00065 mDRot = element->getProperty<float>("rotation_delta");
00066
00067 mTransCoordSystem = element->getProperty<int>("translation_coordinate_system");
00068 mRotCoordSystem = element->getProperty<int>("rotation_coordinate_system");
00069
00070 std::vector<jccl::ConfigElementPtr> key_list;
00071 int key_count = element->getNum("key_pair");
00072 for ( int i = 0; i < key_count; ++i )
00073 {
00074 key_list.push_back(element->getProperty<jccl::ConfigElementPtr>("key_pair", i));
00075 }
00076 std::vector<KeyModPair> key_pairs = readKeyList(key_list);
00077
00078 // Create keypairs
00079 vprASSERT(key_pairs.size() == NUM_POS_CONTROLS);
00080 for ( int i = 0; i < NUM_POS_CONTROLS; ++i )
00081 {
00082 mSimKeys[i] = key_pairs[i];
00083 }
00084
00085 // Set initial position
00086 float x_pos = element->getProperty<float>("initial_position",0);
00087 float y_pos = element->getProperty<float>("initial_position",1);
00088 float z_pos = element->getProperty<float>("initial_position",2);
00089 float x_rot = element->getProperty<float>("initial_rotation",0);
00090 float y_rot = element->getProperty<float>("initial_rotation",1);
00091 float z_rot = element->getProperty<float>("initial_rotation",2);
00092
00093 gmtl::identity( mPos.mPosData );
00094
00095 if((x_pos != 0.0f) || (y_pos != 0.0f) || (z_pos != 0.0f))
00096 {
00097 gmtl::setTrans( mPos.mPosData, gmtl::Vec3f(x_pos, y_pos, z_pos));
00098 }
00099 if((x_rot != 0.0f) || (y_rot != 0.0f) || (z_rot != 0.0f))
00100 {
00101 gmtl::EulerAngleXYZf euler( gmtl::Math::deg2Rad(x_rot),
00102 gmtl::Math::deg2Rad(y_rot),
00103 gmtl::Math::deg2Rad(z_rot) );
00104 gmtl::postMult( mPos.mPosData, gmtl::makeRot<gmtl::Matrix44f>(euler) );
00105 }
00106 mPos.setTime();
00107
00108 return true;
00109 }
|
|
|
These functions don't do anything.
Definition at line 94 of file SimPosition.h.
00094 { return 1; }
|
|
|
Definition at line 95 of file SimPosition.h.
00095 { return 1; }
|
|
|
Definition at line 96 of file SimPosition.h.
00096 { return 1; }
|
|
|
Updates the data.
Definition at line 112 of file SimPosition.cpp. References gadget::Position::addPositionSample, BACK, DOWN, FORWARD, LEFT, RIGHT, ROT_ROLL_CCW, ROT_ROLL_CW, ROTD, ROTL, ROTR, ROTU, gadget::Position::swapPositionBuffers, and UP.
00113 {
00114 float amt(0); // Number of times key pressed
00115 // Used to keep from calling checkKey twice on success
00116 // NOTE: Could have implemented using side effects of assignment
00117 // and used less lines, but this is more explicit
00118
00119 amt = checkKeyPair(mSimKeys[FORWARD]);
00120 if(amt > 0.0f)
00121 {
00122 moveFor( amt );
00123 }
00124
00125 amt = checkKeyPair(mSimKeys[BACK]);
00126 if(amt > 0.0f)
00127 {
00128 moveFor( -amt );
00129 }
00130
00131 amt = checkKeyPair(mSimKeys[LEFT]);
00132 if(amt > 0.0f)
00133 {
00134 moveLeft( amt );
00135 }
00136
00137 amt = checkKeyPair(mSimKeys[RIGHT]);
00138 if(amt > 0.0f)
00139 {
00140 moveLeft( -amt );
00141 }
00142
00143 amt = checkKeyPair(mSimKeys[UP]);
00144 if(amt > 0.0f)
00145 {
00146 moveUp ( amt );
00147 }
00148
00149 amt = checkKeyPair(mSimKeys[DOWN]);
00150 if(amt > 0.0f)
00151 {
00152 moveUp ( -amt );
00153 }
00154
00155 amt = checkKeyPair(mSimKeys[ROTR]);
00156 if(amt > 0.0f)
00157 {
00158 rotLeft( -amt );
00159 }
00160
00161 amt = checkKeyPair(mSimKeys[ROTL]);
00162 if(amt > 0.0f)
00163 {
00164 rotLeft( amt );
00165 }
00166
00167 amt = checkKeyPair(mSimKeys[ROTU]);
00168 if(amt > 0.0f)
00169 {
00170 rotUp( amt );
00171 }
00172
00173 amt = checkKeyPair(mSimKeys[ROTD]);
00174 if(amt > 0.0f)
00175 {
00176 rotUp( -amt );
00177 }
00178
00179 amt = checkKeyPair(mSimKeys[ROT_ROLL_CCW]);
00180 if(amt > 0.0f)
00181 {
00182 rotRollCCW( amt );
00183 }
00184
00185 amt = checkKeyPair(mSimKeys[ROT_ROLL_CW]);
00186 if(amt > 0.0f)
00187 {
00188 rotRollCCW( -amt );
00189 }
00190
00191 // Set the time for the position data to the EventWindow timestamp
00192 mPos.setTime(mEventWin->getTimeStamp());
00193 addPositionSample(std::vector< gadget::PositionData>(1, mPos) );
00194
00195 swapPositionBuffers(); // Swap the buffers
00196 }
|
|
|
Definition at line 51 of file SimPosition.cpp.
00052 {
00053 return "simulated_positional_device";
00054 }
|
|
|
Invokes the global scope delete operator. This is required for proper releasing of memory in DLLs on Win32. Definition at line 107 of file SimPosition.h.
00108 {
00109 ::operator delete(p);
00110 }
|
|
|
Deletes this object. This is an implementation of the pure virtual gadget::Input::destroy() method. Definition at line 117 of file SimPosition.h.
00118 {
00119 delete this;
00120 }
|
1.2.14 written by Dimitri van Heesch,
© 1997-2002