-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.4.1
- Loading branch information
Showing
38 changed files
with
1,052 additions
and
876 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,54 +1,83 @@ | ||
#pragma once | ||
#include <openvr_driver.h> | ||
|
||
const int NUM_BONES = 31; | ||
extern vr::VRBoneTransform_t rightOpenPose[NUM_BONES]; | ||
extern vr::VRBoneTransform_t rightFistPose[NUM_BONES]; | ||
#include <array> | ||
#include <memory> | ||
|
||
#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 ComputeBoneFlexion(vr::VRBoneTransform_t* bone_transform, float transform, int index, const bool isRightHand); | ||
void ComputeBoneSplay(vr::VRBoneTransform_t* bone_transform, const float transform, int index, const bool isRightHand); | ||
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); | ||
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); | ||
|
||
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
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
Oops, something went wrong.