Turn off Sixense (kalman?) filtering, cleanup code

This commit is contained in:
Philip Rosedale 2013-12-04 17:55:32 -08:00
parent c1f96ab6b4
commit 8d518f85fe
2 changed files with 20 additions and 7 deletions

View file

@ -15,6 +15,7 @@
#include "Util.h" #include "Util.h"
#include "renderer/ProgramObject.h" #include "renderer/ProgramObject.h"
using namespace std; using namespace std;
Hand::Hand(Avatar* owningAvatar) : Hand::Hand(Avatar* owningAvatar) :
@ -126,18 +127,23 @@ void Hand::simulate(float deltaTime, bool isMine) {
} }
void Hand::handleVoxelCollision(PalmData* palm, const glm::vec3& fingerTipPosition, VoxelTreeElement* voxel, float deltaTime) { void Hand::handleVoxelCollision(PalmData* palm, const glm::vec3& fingerTipPosition, VoxelTreeElement* voxel, float deltaTime) {
//
// Collision between finger and a voxel plays sound // Collision between finger and a voxel plays sound
// const float LOWEST_FREQUENCY = 100.f;
float volume = 0.1f + glm::clamp(glm::length(palm->getVelocity()), 0.f, 0.9f); const float HERTZ_PER_RGB = 3.f;
const float DECAY_PER_SAMPLE = 0.0005f;
const float DURATION_MAX = 2.0f;
const float MIN_VOLUME = 0.1f;
float volume = MIN_VOLUME + glm::clamp(glm::length(palm->getVelocity()), 0.f, (1.f - MIN_VOLUME));
float duration = volume; float duration = volume;
_collisionCenter = fingerTipPosition; _collisionCenter = fingerTipPosition;
_collisionAge = deltaTime; _collisionAge = deltaTime;
_collisionDuration = duration; _collisionDuration = duration;
int voxelBrightness = voxel->getColor()[0] + voxel->getColor()[1] + voxel->getColor()[2]; int voxelBrightness = voxel->getColor()[0] + voxel->getColor()[1] + voxel->getColor()[2];
float frequency = 100.f + (voxelBrightness * 3.f); // Hz float frequency = LOWEST_FREQUENCY + (voxelBrightness * HERTZ_PER_RGB);
// Play a sound Application::getInstance()->getAudio()->startDrumSound(volume,
Application::getInstance()->getAudio()->startDrumSound(volume, frequency, 2.0f, 0.0005f); frequency,
DURATION_MAX,
DECAY_PER_SAMPLE);
} }
void Hand::calculateGeometry() { void Hand::calculateGeometry() {

View file

@ -16,6 +16,7 @@
SixenseManager::SixenseManager() { SixenseManager::SixenseManager() {
#ifdef HAVE_SIXENSE #ifdef HAVE_SIXENSE
sixenseInit(); sixenseInit();
sixenseSetFilterEnabled(0);
#endif #endif
} }
@ -69,6 +70,12 @@ void SixenseManager::update(float deltaTime) {
palm->setTrigger(data.trigger); palm->setTrigger(data.trigger);
palm->setJoystick(data.joystick_x, data.joystick_y); palm->setJoystick(data.joystick_x, data.joystick_y);
// Vibrate if needed
if (palm->getIsCollidingWithVoxel()) {
//printf("vibrate!\n");
//vibrate(data.controller_index, 100, 1);
}
glm::vec3 position(data.pos[0], data.pos[1], data.pos[2]); glm::vec3 position(data.pos[0], data.pos[1], data.pos[2]);
// Adjust for distance between acquisition 'orb' and the user's torso // Adjust for distance between acquisition 'orb' and the user's torso
// (distance to the right of body center, distance below torso, distance behind torso) // (distance to the right of body center, distance below torso, distance behind torso)