Created
July 14, 2016 13:34
-
-
Save dwilliamson/cb43fb22db95cb41eca1329191222a1d to your computer and use it in GitHub Desktop.
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
void cMirrorControllerImpl::Sample(scenegraph::iSkeleton::Ptr skeleton, cOrientation* blend_buffer, int bone_group, float multiplier, float& current_weight) | |
{ | |
bone_group &= m_BoneGroup; | |
if (m_Controller) | |
{ | |
// Sample input | |
m_Controller->Sample(skeleton, blend_buffer, bone_group, multiplier, current_weight); | |
// TODO: Use bone groups on the mirror ? | |
const tVector<scenegraph::iSkeleton::Bone>& bones = skeleton->GetBones(); | |
int nb_bones = bones.size(); | |
// Iterate through each sampled bone in the blend buffer | |
for (int i = 0; i < nb_bones; i++) | |
{ | |
cOrientation& o = blend_buffer[i]; | |
if (!(bone_group & bones[i].group)) | |
continue; | |
// Mirror bone rotation on the x-axis | |
//o.rotation.w = maths::Sin(-maths::ASin(o.rotation.w)); | |
//o.rotation.x = -o.rotation.x; | |
o.rotation.y = -o.rotation.y; | |
o.rotation.z = -o.rotation.z; | |
// Mirror bone position on x-axis | |
o.position.x = -o.position.x; | |
} | |
// Iterate through each bone pair | |
const tVector<scenegraph::iSkeleton::BonePair>& bone_pairs = skeleton->GetBonePairs(); | |
int nb_bone_pairs = bone_pairs.size(); | |
for (int i = 0; i < nb_bone_pairs; i++) | |
{ | |
const scenegraph::iSkeleton::BonePair& bp = bone_pairs[i]; | |
if (!(bone_group & bones[bp.left].group)) | |
continue; | |
// Swap left and right bones in the skeleton | |
cOrientation temp = blend_buffer[bp.left]; | |
blend_buffer[bp.left] = blend_buffer[bp.right]; | |
blend_buffer[bp.right] = temp; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment