Exemplo n.º 1
0
void Matrix3DUtils::translateY(Matrix3D &m, const float distance) {
    m.copyColumnTo(3, _pos);
    m.copyColumnTo(1, _up);
    _pos.x += distance * _up.x;
    _pos.y += distance * _up.y;
    _pos.z += distance * _up.z;
    m.copyColumnFrom(3, _pos);
}
Exemplo n.º 2
0
void Matrix3DUtils::translateX(Matrix3D &m, const float distance) {
    m.copyColumnTo(3, _pos);
    m.copyColumnTo(0, _right);
    _pos.x += distance * _right.x;
    _pos.y += distance * _right.y;
    _pos.z += distance * _right.z;
    m.copyColumnFrom(3, _pos);
}
Exemplo n.º 3
0
void Matrix3DUtils::getScale(const Matrix3D &m, Vector3D &out) {
    m.copyColumnTo(0, _right);
    m.copyColumnTo(1, _up);
    m.copyColumnTo(2, _dir);
    out.x = _right.length();
    out.y = _up.length();
    out.z = _dir.length();
}
Exemplo n.º 4
0
void Matrix3DUtils::translateAxis(Matrix3D &m, const float distance, const Vector3D &axis) {
    m.copyColumnTo(3, _pos);
    _pos.x += distance * axis.x;
    _pos.y += distance * axis.y;
    _pos.z += distance * axis.z;
    m.copyColumnFrom(3, _pos);
}
Exemplo n.º 5
0
void Matrix3DUtils::lookAt(Matrix3D &m, const float x, const float y, const float z, const Vector3D &up, const float smooth) {
    m.copyColumnTo(3, _pos);
    _vector.x = x - _pos.x;
    _vector.y = y - _pos.y;
    _vector.z = z - _pos.z;
    setOrientation(m, _vector, up, smooth);
}
Exemplo n.º 6
0
void Matrix3DUtils::translateZ(Matrix3D &m, const float distance) {
    m.copyColumnTo(3, _pos);
    m.copyColumnTo(2, _dir);
    _pos.x += distance * _dir.x;
    _pos.y += distance * _dir.y;
    _pos.z += distance * _dir.z;
    m.copyColumnFrom(3, _pos);
}
Exemplo n.º 7
0
void Matrix3DUtils::scaleZ(Matrix3D &m, float scale) {
    if (scale < MIN_SCALE) {
        scale = MIN_SCALE;
    }
    m.copyColumnTo(2, _dir);
    _dir.normalize();
    _dir.scaleBy(scale);
    m.copyColumnFrom(2, _dir);
}
Exemplo n.º 8
0
void Matrix3DUtils::scaleY(Matrix3D &m, float scale) {
    if (scale < MIN_SCALE) {
        scale = MIN_SCALE;
    }
    m.copyColumnTo(1, _up);
    _up.normalize();
    _up.scaleBy(scale);
    m.copyColumnFrom(1, _up);
}
Exemplo n.º 9
0
void Matrix3DUtils::scaleX(Matrix3D &m, float scale) {
    if (scale < MIN_SCALE) {
        scale = MIN_SCALE;
    }
    m.copyColumnTo(0, _right);
    _right.normalize();
    _right.scaleBy(scale);
    m.copyColumnFrom(0, _right);
}
Exemplo n.º 10
0
void Matrix3DUtils::transformVector(const Matrix3D &m, const Vector3D &in, Vector3D &out) {
    _vector.copyFrom(in);
    m.copyRawTo(0, _right);
    m.copyRawTo(1, _up);
    m.copyRawTo(2, _dir);
    m.copyColumnTo(3, out);
    out.x += _vector.x * _right.x + _vector.y * _right.y + _vector.z * _right.z;
    out.y += _vector.x * _up.x + _vector.y * _up.y + _vector.z * _up.z;
    out.z += _vector.z * _dir.x + _vector.y * _dir.y + _vector.z * _dir.z;
}
Exemplo n.º 11
0
void Matrix3DUtils::rotateAxis(Matrix3D &m, const float angle, const Vector3D &axis, Vector3D *pivot) {
    _vector.x = axis.x;
    _vector.y = axis.y;
    _vector.z = axis.z;
    _vector.normalize();
    m.copyColumnTo(3, _pos);
    if (pivot) {
        m.appendRotation(angle, _vector, pivot);
    } else {
        m.appendRotation(angle, _vector, &_pos);
    }
}
Exemplo n.º 12
0
void Matrix3DUtils::setPosition(Matrix3D &m, const float x, const float y, const float z, const float smooth) {
    if (smooth == 1.0f) {
        _vector.setTo(x, y, z);
        _vector.w = 1.0f;
        m.copyColumnFrom(3, _vector);
    } else {
        m.copyColumnTo(3, _pos);
        _pos.x += (x - _pos.x) * smooth;
        _pos.y += (y - _pos.y) * smooth;
        _pos.z += (z - _pos.z) * smooth;
        m.copyColumnFrom(3, _pos);
    }
}
Exemplo n.º 13
0
void Matrix3DUtils::getRight(const Matrix3D &m, Vector3D &out) {
    m.copyColumnTo(0, out);
}
Exemplo n.º 14
0
void Matrix3DUtils::getPosition(const Matrix3D &m, Vector3D &out) {
    m.copyColumnTo(3, out);
}
Exemplo n.º 15
0
void Matrix3DUtils::getDown(const Matrix3D &m, Vector3D &out) {
    m.copyColumnTo(1, out);
    out.negate();
}
Exemplo n.º 16
0
void Matrix3DUtils::getBackward(const Matrix3D &m, Vector3D &out) {
    m.copyColumnTo(2, out);
    out.negate();
}
Exemplo n.º 17
0
void Matrix3DUtils::getDir(const Matrix3D &m, Vector3D &out) {
    m.copyColumnTo(2, out);
}