-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* inital gltf parse (really broken) * use memcpy directly * fix off-by-one error, working * fix out of range error, change file name * potential bugfix for lerp * fix lerp * Overhauled Bones.cpp to add GLTF caching (#140) * Overhauled Bones.cpp to add GLTF caching * Just call three methods as per @danwillm * Removed pointless cast * left hand transforms * Update include/DeviceConfiguration.h Co-authored-by: noob247365 <noob247365@gmail.com> * Update include/DeviceProvider.h Co-authored-by: noob247365 <noob247365@gmail.com> * Update include/DriverLog.h Co-authored-by: noob247365 <noob247365@gmail.com> * Update include/Util/Windows.h Co-authored-by: noob247365 <noob247365@gmail.com> * Update src/Communication/BTSerialCommunicationManager.cpp Co-authored-by: noob247365 <noob247365@gmail.com> * Update src/Communication/SerialCommunicationManager.cpp Co-authored-by: noob247365 <noob247365@gmail.com> * Update src/DeviceProvider.cpp Co-authored-by: noob247365 <noob247365@gmail.com> * Update src/Util/Windows.cpp Co-authored-by: noob247365 <noob247365@gmail.com> * Update src/Util/Windows.cpp Co-authored-by: noob247365 <noob247365@gmail.com> * Update src/Util/Windows.cpp Co-authored-by: noob247365 <noob247365@gmail.com> * Gltf node index (#143) * bone index->node index? * remove num_bones from class members * redo configuration * bugfix node * comments Co-authored-by: noob247365 <noob247365@gmail.com>
- Loading branch information
1 parent
10d933b
commit 8b858f0
Showing
22 changed files
with
541 additions
and
425 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "libraries/openvr"] | ||
path = libraries/openvr | ||
url = https://github.com/ValveSoftware/openvr.git | ||
url = https://github.com/ValveSoftware/openvr.git | ||
[submodule "libraries/tinygltf"] | ||
path = libraries/tinygltf | ||
url = https://github.com/syoyo/tinygltf.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,83 @@ | ||
#pragma once | ||
#include <openvr_driver.h> | ||
|
||
#include <array> | ||
#include <memory> | ||
|
||
const int NUM_BONES = 31; | ||
extern vr::VRBoneTransform_t rightOpenPose[NUM_BONES]; | ||
extern vr::VRBoneTransform_t rightFistPose[NUM_BONES]; | ||
#include "openvr_driver.h" | ||
|
||
enum class HandSkeletonBone : vr::BoneIndex_t { | ||
eBone_Root = 0, | ||
eBone_Wrist, | ||
eBone_Thumb0, | ||
eBone_Thumb1, | ||
eBone_Thumb2, | ||
eBone_Thumb3, | ||
eBone_IndexFinger0, | ||
eBone_IndexFinger1, | ||
eBone_IndexFinger2, | ||
eBone_IndexFinger3, | ||
eBone_IndexFinger4, | ||
eBone_MiddleFinger0, | ||
eBone_MiddleFinger1, | ||
eBone_MiddleFinger2, | ||
eBone_MiddleFinger3, | ||
eBone_MiddleFinger4, | ||
eBone_RingFinger0, | ||
eBone_RingFinger1, | ||
eBone_RingFinger2, | ||
eBone_RingFinger3, | ||
eBone_RingFinger4, | ||
eBone_PinkyFinger0, | ||
eBone_PinkyFinger1, | ||
eBone_PinkyFinger2, | ||
eBone_PinkyFinger3, | ||
eBone_PinkyFinger4, | ||
eBone_Aux_Thumb, | ||
eBone_Aux_IndexFinger, | ||
eBone_Aux_MiddleFinger, | ||
eBone_Aux_RingFinger, | ||
eBone_Aux_PinkyFinger, | ||
eBone_Count | ||
}; | ||
|
||
const short NUM_BONES = (short)HandSkeletonBone::eBone_Count; | ||
|
||
extern vr::VRBoneTransform_t rightOpenPose[NUM_BONES]; | ||
extern vr::VRBoneTransform_t leftOpenPose[NUM_BONES]; | ||
extern vr::VRBoneTransform_t leftFistPose[NUM_BONES]; | ||
|
||
enum HandSkeletonBone : vr::BoneIndex_t { | ||
eBone_Root = 0, | ||
eBone_Wrist, | ||
eBone_Thumb0, | ||
eBone_Thumb1, | ||
eBone_Thumb2, | ||
eBone_Thumb3, | ||
eBone_IndexFinger0, | ||
eBone_IndexFinger1, | ||
eBone_IndexFinger2, | ||
eBone_IndexFinger3, | ||
eBone_IndexFinger4, | ||
eBone_MiddleFinger0, | ||
eBone_MiddleFinger1, | ||
eBone_MiddleFinger2, | ||
eBone_MiddleFinger3, | ||
eBone_MiddleFinger4, | ||
eBone_RingFinger0, | ||
eBone_RingFinger1, | ||
eBone_RingFinger2, | ||
eBone_RingFinger3, | ||
eBone_RingFinger4, | ||
eBone_PinkyFinger0, | ||
eBone_PinkyFinger1, | ||
eBone_PinkyFinger2, | ||
eBone_PinkyFinger3, | ||
eBone_PinkyFinger4, | ||
eBone_Aux_Thumb, | ||
eBone_Aux_IndexFinger, | ||
eBone_Aux_MiddleFinger, | ||
eBone_Aux_RingFinger, | ||
eBone_Aux_PinkyFinger, | ||
eBone_Count | ||
|
||
struct Transform_t { | ||
Transform_t(); | ||
std::array<float, 4> rotation; | ||
std::array<float, 3> translation; | ||
}; | ||
|
||
void ComputeHand(vr::VRBoneTransform_t* skeleton, const std::array<float, 5>& flexion, bool isRightHand); | ||
void ComputeBoneFlexion(vr::VRBoneTransform_t* bone_transform, float transform, int index, const bool isRightHand); | ||
struct AnimationData_t { | ||
AnimationData_t(); | ||
Transform_t startTransform; | ||
float startTime; | ||
Transform_t endTransform; | ||
float endTime; | ||
}; | ||
|
||
class IModelManager { | ||
public: | ||
virtual bool Load() = 0; | ||
|
||
virtual AnimationData_t GetAnimationDataByBoneIndex(const HandSkeletonBone& boneIndex, float f) const = 0; | ||
virtual Transform_t GetTransformByBoneIndex(const HandSkeletonBone& boneIndex) const = 0; | ||
}; | ||
|
||
class BoneAnimator { | ||
public: | ||
BoneAnimator(const std::string& fileName); | ||
void ComputeSkeletonTransforms(vr::VRBoneTransform_t* skeleton, const std::array<float, 5>& flexion, const bool rightHand); | ||
void TransformLeftBone(vr::VRBoneTransform_t& bone, const HandSkeletonBone& boneIndex); | ||
|
||
private: | ||
vr::VRBoneTransform_t GetTransformForBone(const HandSkeletonBone& boneIndex, const float f, const bool rightHand); | ||
|
||
vr::HmdQuaternionf_t CalculateOrientation(const float transform, const int boneIndex, const vr::VRBoneTransform_t* openPose, const vr::VRBoneTransform_t* fistPose); | ||
vr::HmdVector4_t CalculatePosition(const float transform, const int boneIndex, const vr::VRBoneTransform_t* openPose, const vr::VRBoneTransform_t* fistPose); | ||
int FingerFromBone(vr::BoneIndex_t bone); | ||
/** | ||
*Linear interpolation between a and b. | ||
**/ | ||
float Lerp(const float a, const float b, const float f); | ||
std::string m_fileName; | ||
std::unique_ptr<IModelManager> m_modelManager; | ||
bool m_loaded; | ||
std::vector<float> m_keyframes; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,50 @@ | ||
#pragma once | ||
#include <openvr_driver.h> | ||
#include "openvr_driver.h" | ||
|
||
#include <functional> | ||
#include <memory> | ||
|
||
#include "Communication/CommunicationManager.h" | ||
#include "Encode/LegacyEncodingManager.h" | ||
#include "DeviceDriver/DeviceDriver.h" | ||
|
||
#include "Bones.h" | ||
|
||
#include "Communication/CommunicationManager.h" | ||
#include "ControllerPose.h" | ||
#include "DeviceConfiguration.h" | ||
#include "DeviceDriver/DeviceDriver.h" | ||
#include "Encode/LegacyEncodingManager.h" | ||
|
||
static const char* c_lucidGloveDeviceSettingsSection = "device_lucidgloves"; | ||
|
||
/** | ||
This class controls the behavior of the controller. This is where you | ||
tell OpenVR what your controller has (buttons, joystick, trackpad, etc.). | ||
This is also where you inform OpenVR when the state of your controller | ||
changes (for example, a button is pressed). | ||
For the methods, take a look at the comment blocks for the ITrackedDeviceServerDriver | ||
class too. Those comment blocks have some good information. | ||
**/ | ||
class LucidGloveDeviceDriver : public IDeviceDriver { | ||
public: | ||
LucidGloveDeviceDriver(VRDeviceConfiguration_t configuration, std::unique_ptr<ICommunicationManager> communicationManager, std::string serialNumber); | ||
public: | ||
LucidGloveDeviceDriver(VRDeviceConfiguration_t configuration, std::unique_ptr<ICommunicationManager> communicationManager, std::string serialNumber, | ||
std::shared_ptr<BoneAnimator> boneAnimator); | ||
|
||
vr::EVRInitError Activate(uint32_t unObjectId); | ||
void Deactivate(); | ||
|
||
vr::EVRInitError Activate(uint32_t unObjectId); | ||
void Deactivate(); | ||
void EnterStandby(); | ||
void* GetComponent(const char* pchComponentNameAndVersion); | ||
void DebugRequest(const char* pchRequest, char* pchResponseBuffer, uint32_t unResponseBufferSize); | ||
vr::DriverPose_t GetPose(); | ||
void RunFrame(); | ||
|
||
void EnterStandby(); | ||
void* GetComponent(const char* pchComponentNameAndVersion); | ||
void DebugRequest(const char* pchRequest, char* pchResponseBuffer, uint32_t unResponseBufferSize); | ||
vr::DriverPose_t GetPose(); | ||
void RunFrame(); | ||
std::string GetSerialNumber(); | ||
|
||
std::string GetSerialNumber(); | ||
bool IsActive(); | ||
|
||
bool IsActive(); | ||
private: | ||
void StartDevice(); | ||
bool IsRightHand() const; | ||
private: | ||
void StartDevice(); | ||
bool IsRightHand() const; | ||
|
||
bool m_hasActivated; | ||
uint32_t m_driverId; | ||
bool m_hasActivated; | ||
uint32_t m_driverId; | ||
|
||
vr::VRInputComponentHandle_t m_skeletalComponentHandle{}; | ||
vr::VRInputComponentHandle_t m_inputComponentHandles[15]{}; | ||
vr::VRInputComponentHandle_t m_skeletalComponentHandle{}; | ||
vr::VRInputComponentHandle_t m_inputComponentHandles[15]{}; | ||
|
||
vr::VRBoneTransform_t m_handTransforms[NUM_BONES]; | ||
vr::VRBoneTransform_t m_handTransforms[NUM_BONES]; | ||
|
||
VRDeviceConfiguration_t m_configuration; | ||
std::unique_ptr<ICommunicationManager> m_communicationManager; | ||
std::string m_serialNumber; | ||
VRDeviceConfiguration_t m_configuration; | ||
std::unique_ptr<ICommunicationManager> m_communicationManager; | ||
std::string m_serialNumber; | ||
|
||
std::unique_ptr<ControllerPose> m_controllerPose; | ||
std::unique_ptr<ControllerPose> m_controllerPose; | ||
std::shared_ptr<BoneAnimator> m_boneAnimator; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
extern std::string GetDriverPath(); | ||
extern std::string GetLastErrorAsString(); |
Submodule asio
deleted from
57577c
Binary file not shown.
Oops, something went wrong.