예제 #1
0
Joint *Skeleton::getJointNamed(const Common::String &name) const {
    int idx = findJointIndex(name, _numJoints);
    if (name.empty()) {
        return & _joints[0];
    } else if (idx == -1) {
        warning("Skeleton has no joint named '%s'!", name.c_str());
        return NULL;
    } else {
        return & _joints[idx];
    }
}
예제 #2
0
MotionTracker::Index MotionTracker::addJoint(const Semantic& semantic, Index parent) {
    // Check the parent
    if (int(parent) < 0)
        return INVALID_PARENT;

    // Check that the semantic is not already in use
    Index foundIndex = findJointIndex(semantic);
    if (foundIndex >= 0)
        return INVALID_SEMANTIC;

    // All good then allocate the joint
    Index newIndex = _jointsArray.size();
    _jointsArray.push_back(JointTracker(semantic, parent));
    _jointsMap.insert(JointTracker::Map::value_type(semantic, newIndex));

    return newIndex;
}
예제 #3
0
void Skeleton::loadSkeleton(Common::SeekableReadStream *data) {
    _numJoints = data->readUint32LE();
    _joints = new Joint[_numJoints];

    char inString[32];

    for (int i = 0; i < _numJoints; i++) {
        data->read(inString, 32);
        _joints[i]._name = inString;
        data->read(inString, 32);
        _joints[i]._parent = inString;

        _joints[i]._trans.readFromStream(data);
        _joints[i]._quat.readFromStream(data);

        _joints[i]._parentIndex = findJointIndex(_joints[i]._parent, i);
    }
    initBones();
    resetAnim();
}
예제 #4
0
bool Skeleton::hasJoint(const Common::String &name) const {
    return name.empty() || findJointIndex(name, _numJoints) >= 0;
}