Missed the actual files.

This commit is contained in:
Andrzej Kapolka 2013-11-15 18:47:25 -08:00
parent 1f2fe5ddee
commit 9c401607b1
3 changed files with 119 additions and 0 deletions

View file

@ -0,0 +1,44 @@
# Try to find the Sixense controller library
#
# You must provide a SIXENSE_ROOT_DIR which contains lib and include directories
#
# Once done this will define
#
# SIXENSE_FOUND - system found Sixense
# SIXENSE_INCLUDE_DIRS - the Sixense include directory
# SIXENSE_LIBRARIES - Link this to use Sixense
#
# Created on 11/15/2013 by Andrzej Kapolka
# Copyright (c) 2013 High Fidelity
#
if (SIXENSE_LIBRARIES AND SIXENSE_INCLUDE_DIRS)
# in cache already
set(SIXENSE_FOUND TRUE)
else (SIXENSE_LIBRARIES AND SIXENSE_INCLUDE_DIRS)
find_path(SIXENSE_INCLUDE_DIRS sixense.h ${SIXENSE_ROOT_DIR}/include)
if (APPLE)
find_library(SIXENSE_LIBRARIES libsixense.dylib ${SIXENSE_ROOT_DIR}/lib/MacOS/)
elseif (UNIX)
find_library(SIXENSE_LIBRARIES libsixense_x64.so ${SIXENSE_ROOT_DIR}/lib/UNIX/)
endif ()
if (SIXENSE_INCLUDE_DIRS AND SIXENSE_LIBRARIES)
set(SIXENSE_FOUND TRUE)
endif (SIXENSE_INCLUDE_DIRS AND SIXENSE_LIBRARIES)
if (SIXENSE_FOUND)
if (NOT SIXENSE_FIND_QUIETLY)
message(STATUS "Found Sixense: ${SIXENSE_LIBRARIES}")
endif (NOT SIXENSE_FIND_QUIETLY)
else (SIXENSE_FOUND)
if (SIXENSE_FIND_REQUIRED)
message(FATAL_ERROR "Could not find Sixense")
endif (SIXENSE_FIND_REQUIRED)
endif (SIXENSE_FOUND)
# show the SIXENSE_INCLUDE_DIRS and SIXENSE_LIBRARIES variables only in the advanced view
mark_as_advanced(SIXENSE_INCLUDE_DIRS SIXENSE_LIBRARIES)
endif (SIXENSE_LIBRARIES AND SIXENSE_INCLUDE_DIRS)

View file

@ -0,0 +1,53 @@
//
// Sixense.cpp
// interface
//
// Created by Andrzej Kapolka on 11/15/13.
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
//
#include "sixense.h"
#include "Application.h"
#include "SixenseManager.h"
SixenseManager::SixenseManager() {
sixenseInit();
}
SixenseManager::~SixenseManager() {
sixenseExit();
}
void SixenseManager::update() {
if (sixenseGetNumActiveControllers() == 0) {
return;
}
Hand& hand = Application::getInstance()->getAvatar()->getHand();
hand.getPalms().clear();
int maxControllers = sixenseGetMaxControllers();
for (int i = 0; i < maxControllers; i++) {
if (!sixenseIsControllerEnabled(i)) {
continue;
}
sixenseControllerData data;
sixenseGetNewestData(i, &data);
PalmData palm(&hand);
palm.setActive(true);
glm::vec3 position(-data.pos[0], data.pos[1], -data.pos[2]);
palm.setRawPosition(position);
glm::quat rotation(data.rot_quat[3], -data.rot_quat[0], data.rot_quat[1], -data.rot_quat[2]);
palm.setRawNormal(rotation * glm::vec3(0.0f, -1.0f, 0.0f));
FingerData finger(&palm, &hand);
finger.setActive(true);
finger.setRawRootPosition(position);
finger.setRawTipPosition(position + rotation * glm::vec3(0.0f, 0.0f, 100.0f));
palm.getFingers().clear();
palm.getFingers().push_back(finger);
palm.getFingers().push_back(finger);
palm.getFingers().push_back(finger);
hand.getPalms().push_back(palm);
}
}

View file

@ -0,0 +1,22 @@
//
// SixenseManager.h
// interface
//
// Created by Andrzej Kapolka on 11/15/13.
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
//
#ifndef __interface__SixenseManager__
#define __interface__SixenseManager__
/// Handles interaction with the Sixense SDK (e.g., Razer Hydra).
class SixenseManager {
public:
SixenseManager();
~SixenseManager();
void update();
};
#endif /* defined(__interface__SixenseManager__) */