mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 20:15:15 +02:00
add angularVelocity to controller
This commit is contained in:
parent
af99a5d07b
commit
d74856e01b
5 changed files with 32 additions and 2 deletions
|
@ -260,6 +260,18 @@ void SixenseManager::update(float deltaTime) {
|
|||
float sign = (i == 0) ? -1.0f : 1.0f;
|
||||
rotation *= glm::angleAxis(sign * PI/4.0f, glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
|
||||
// Angular Velocity of Palm
|
||||
glm::quat deltaRotation = rotation * glm::inverse(palm->getRawRotation());
|
||||
glm::vec3 angularVelocity(0.0f);
|
||||
float rotationAngle = glm::angle(deltaRotation);
|
||||
if ((rotationAngle > EPSILON) && (deltaTime > 0.0f)) {
|
||||
angularVelocity = glm::normalize(glm::axis(deltaRotation));
|
||||
angularVelocity *= (rotationAngle / deltaTime);
|
||||
palm->setRawAngularVelocity(angularVelocity);
|
||||
} else {
|
||||
palm->setRawAngularVelocity(glm::vec3(0.0f));
|
||||
}
|
||||
|
||||
if (_lowVelocityFilter) {
|
||||
// Use a velocity sensitive filter to damp small motions and preserve large ones with
|
||||
// no latency.
|
||||
|
|
|
@ -208,6 +208,21 @@ glm::quat ControllerScriptingInterface::getSpatialControlRawRotation(int control
|
|||
}
|
||||
return glm::quat(); // bad index
|
||||
}
|
||||
|
||||
glm::vec3 ControllerScriptingInterface::getSpatialControlRawAngularVelocity(int controlIndex) const {
|
||||
int palmIndex = controlIndex / NUMBER_OF_SPATIALCONTROLS_PER_PALM;
|
||||
int controlOfPalm = controlIndex % NUMBER_OF_SPATIALCONTROLS_PER_PALM;
|
||||
const PalmData* palmData = getActivePalm(palmIndex);
|
||||
if (palmData) {
|
||||
switch (controlOfPalm) {
|
||||
case PALM_SPATIALCONTROL:
|
||||
return palmData->getRawAngularVelocity();
|
||||
case TIP_SPATIALCONTROL:
|
||||
return palmData->getRawAngularVelocity(); // Tip = palm angular velocity
|
||||
}
|
||||
}
|
||||
return glm::vec3(0); // bad index
|
||||
}
|
||||
|
||||
glm::vec3 ControllerScriptingInterface::getSpatialControlNormal(int controlIndex) const {
|
||||
int palmIndex = controlIndex / NUMBER_OF_SPATIALCONTROLS_PER_PALM;
|
||||
|
|
|
@ -96,6 +96,7 @@ public slots:
|
|||
virtual glm::vec3 getSpatialControlVelocity(int controlIndex) const;
|
||||
virtual glm::vec3 getSpatialControlNormal(int controlIndex) const;
|
||||
virtual glm::quat getSpatialControlRawRotation(int controlIndex) const;
|
||||
virtual glm::vec3 getSpatialControlRawAngularVelocity(int controlIndex) const;
|
||||
virtual void captureKeyEvents(const KeyEvent& event);
|
||||
virtual void releaseKeyEvents(const KeyEvent& event);
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ PalmData::PalmData(HandData* owningHandData) :
|
|||
_rawRotation(0.0f, 0.0f, 0.0f, 1.0f),
|
||||
_rawPosition(0.0f),
|
||||
_rawVelocity(0.0f),
|
||||
_rotationalVelocity(0.0f),
|
||||
_rawAngularVelocity(0.0f),
|
||||
_totalPenetration(0.0f),
|
||||
_controllerButtons(0),
|
||||
_isActive(false),
|
||||
|
|
|
@ -98,6 +98,8 @@ public:
|
|||
void setRawPosition(const glm::vec3& pos) { _rawPosition = pos; }
|
||||
void setRawVelocity(const glm::vec3& velocity) { _rawVelocity = velocity; }
|
||||
const glm::vec3& getRawVelocity() const { return _rawVelocity; }
|
||||
void setRawAngularVelocity(const glm::vec3& angularVelocity) { _rawAngularVelocity = angularVelocity; }
|
||||
const glm::vec3& getRawAngularVelocity() const { return _rawAngularVelocity; }
|
||||
void addToPosition(const glm::vec3& delta);
|
||||
|
||||
void addToPenetration(const glm::vec3& penetration) { _totalPenetration += penetration; }
|
||||
|
@ -148,7 +150,7 @@ private:
|
|||
glm::quat _rawRotation;
|
||||
glm::vec3 _rawPosition;
|
||||
glm::vec3 _rawVelocity;
|
||||
glm::vec3 _rotationalVelocity;
|
||||
glm::vec3 _rawAngularVelocity;
|
||||
glm::quat _lastRotation;
|
||||
|
||||
glm::vec3 _tipPosition;
|
||||
|
|
Loading…
Reference in a new issue