Пример #1
0
void Flow::updateAbsolutePoses(const AnimPoseVec& relativePoses, AnimPoseVec& absolutePoses) {
    for (auto &joint : _flowJointData) {
        int index = joint.second.getIndex();
        int parentIndex = joint.second.getParentIndex();
        if (index >= 0 && index < (int)relativePoses.size() &&
            parentIndex >= 0 && parentIndex < (int)absolutePoses.size()) {
            absolutePoses[index] = absolutePoses[parentIndex] * relativePoses[index];
        }
    }
}
Пример #2
0
AnimPose AnimSkeleton::getAbsolutePose(int jointIndex, const AnimPoseVec& poses) const {
    if (jointIndex < 0 || jointIndex >= (int)poses.size() || jointIndex >= (int)_joints.size()) {
        return AnimPose::identity;
    } else {
        return getAbsolutePose(_joints[jointIndex].parentIndex, poses) * poses[jointIndex];
    }
}
Пример #3
0
AnimPose AnimSkeleton::getAbsolutePose(int jointIndex, const AnimPoseVec& relativePoses) const {
    if (jointIndex < 0 || jointIndex >= (int)relativePoses.size() || jointIndex >= _jointsSize) {
        return AnimPose::identity;
    } else {
        return getAbsolutePose(_joints[jointIndex].parentIndex, relativePoses) * relativePoses[jointIndex];
    }
}
Пример #4
0
bool Flow::getJointTranslation(const AnimPoseVec& relativePoses, int jointIndex, glm::vec3& translation) const {
    if (jointIndex >= 0 && jointIndex < (int)relativePoses.size()) {
        translation = relativePoses[jointIndex].trans();
        return true;
    } else {
        return false;
    }
}
Пример #5
0
bool Flow::getJointRotation(const AnimPoseVec& relativePoses, int jointIndex, glm::quat& rotation) const {
    if (jointIndex >= 0 && jointIndex < (int)relativePoses.size()) {
        rotation = relativePoses[jointIndex].rot();
        return true;
    } else {
        return false;
    }
}
Пример #6
0
bool Flow::getJointRotationInWorldFrame(const AnimPoseVec& absolutePoses, int jointIndex, glm::quat& result, const glm::quat& rotation) const {
    if (jointIndex >= 0 && jointIndex < (int)absolutePoses.size()) {
        result = rotation * absolutePoses[jointIndex].rot();
        return true;
    } else {
        return false;
    }
}
Пример #7
0
void AnimSkeleton::convertRelativePosesToAbsolute(AnimPoseVec& poses) const {
    // poses start off relative and leave in absolute frame
    for (int i = 0; i < (int)poses.size() && i < (int)_joints.size(); ++i) {
        int parentIndex = _joints[i].parentIndex;
        if (parentIndex != -1) {
            poses[i] = poses[parentIndex] * poses[i];
        }
    }
}
Пример #8
0
void AnimSkeleton::convertAbsolutePosesToRelative(AnimPoseVec& poses) const {
    // poses start off absolute and leave in relative frame
    int lastIndex = std::min((int)poses.size(), _jointsSize);
    for (int i = lastIndex - 1; i >= 0; --i) {
        int parentIndex = _joints[i].parentIndex;
        if (parentIndex != -1) {
            poses[i] = poses[parentIndex].inverse() * poses[i];
        }
    }
}
Пример #9
0
void Flow::setJoints(AnimPoseVec& relativePoses, const std::vector<bool>& overrideFlags) {
    for (auto &thread : _jointThreads) {
        auto &joints = thread._joints;
        for (int jointIndex : joints) {
            auto &joint = _flowJointData[jointIndex];
            if (jointIndex >= 0 && jointIndex < (int)relativePoses.size() && !overrideFlags[jointIndex]) {
                relativePoses[jointIndex].rot() = joint.getSettings()._active ? joint.getCurrentRotation() : joint.getInitialRotation();
            }            
        }
    }
}
Пример #10
0
bool Flow::getJointPositionInWorldFrame(const AnimPoseVec& absolutePoses, int jointIndex, glm::vec3& position, glm::vec3 translation, glm::quat rotation) const {
    if (jointIndex >= 0 && jointIndex < (int)absolutePoses.size()) {
        glm::vec3 poseSetTrans = absolutePoses[jointIndex].trans();
        position = (rotation * poseSetTrans) + translation;
        if (!isNaN(position)) {
            return true;
        } else {
            position = glm::vec3(0.0f);
        }
    }
    return false;
}
Пример #11
0
void AnimSkeleton::mirrorAbsolutePoses(AnimPoseVec& poses) const {
    AnimPoseVec temp = poses;
    for (int i = 0; i < (int)poses.size(); i++) {
        poses[_mirrorMap[i]] = temp[i].mirror();
    }
}