Showing the changes to interface/src/ControllerScriptingInterface.cpp (1 of 3 files). Show all
Unified · Split
| @@ -134,8 +134,52 @@ int ControllerScriptingInterface::getNumberOfSpatialControls() const { · 133 unmodified lines | ||
| 134 | 134 | return getNumberOfActivePalms() * NUMBER_OF_SPATIALCONTROLS_PER_PALM; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | +const int PALM_SPATIALCONTROL = 0; | |
| 138 | +const int TIP_SPATIALCONTROL = 1; | |
| 139 | + | |
| 137 | 140 | glm::vec3 ControllerScriptingInterface::getSpatialControlPosition(int controlIndex) const { |
| 138 | − return glm::vec3(0); // not yet implemented | |
| 141 | + int palmIndex = controlIndex / NUMBER_OF_SPATIALCONTROLS_PER_PALM; | |
| 142 | + int controlOfPalm = controlIndex % NUMBER_OF_SPATIALCONTROLS_PER_PALM; | |
| 143 | + const PalmData* palmData = getActivePalm(palmIndex); | |
| 144 | + if (palmData) { | |
| 145 | + switch (controlOfPalm) { | |
| 146 | + case PALM_SPATIALCONTROL: | |
| 147 | + return palmData->getPosition(); | |
| 148 | + case TIP_SPATIALCONTROL: | |
| 149 | + return palmData->getTipPosition(); | |
| 150 | + } | |
| 151 | + } | |
| 152 | + return glm::vec3(0); // bad index | |
| 153 | +} | |
| 154 | + | |
| 155 | +glm::vec3 ControllerScriptingInterface::getSpatialControlVelocity(int controlIndex) const { | |
| 156 | + int palmIndex = controlIndex / NUMBER_OF_SPATIALCONTROLS_PER_PALM; | |
| 157 | + int controlOfPalm = controlIndex % NUMBER_OF_SPATIALCONTROLS_PER_PALM; | |
| 158 | + const PalmData* palmData = getActivePalm(palmIndex); | |
| 159 | + if (palmData) { | |
| 160 | + switch (controlOfPalm) { | |
| 161 | + case PALM_SPATIALCONTROL: | |
| 162 | + return palmData->getVelocity(); | |
| 163 | + case TIP_SPATIALCONTROL: | |
| 164 | + return palmData->getTipVelocity(); | |
| 165 | + } | |
| 166 | + } | |
| 167 | + return glm::vec3(0); // bad index | |
| 168 | +} | |
| 169 | + | |
| 170 | +glm::vec3 ControllerScriptingInterface::getSpatialControlNormal(int controlIndex) const { | |
| 171 | + int palmIndex = controlIndex / NUMBER_OF_SPATIALCONTROLS_PER_PALM; | |
| 172 | + int controlOfPalm = controlIndex % NUMBER_OF_SPATIALCONTROLS_PER_PALM; | |
| 173 | + const PalmData* palmData = getActivePalm(palmIndex); | |
| 174 | + if (palmData) { | |
| 175 | + switch (controlOfPalm) { | |
| 176 | + case PALM_SPATIALCONTROL: | |
| 177 | + return palmData->getNormal(); | |
| 178 | + case TIP_SPATIALCONTROL: | |
| 179 | + return palmData->getNormal(); // currently the tip doesn't have a unique normal, use the palm normal | |
| 180 | + } | |
| 181 | + } | |
| 182 | + return glm::vec3(0); // bad index | |
| 139 | 183 | } |
| 140 | 184 | |
| 141 | 185 | |