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); }
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); }
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(); }
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); }
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); }
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); }
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); }
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); }
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); }
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; }
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); } }
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); } }
void Matrix3DUtils::getRight(const Matrix3D &m, Vector3D &out) { m.copyColumnTo(0, out); }
void Matrix3DUtils::getPosition(const Matrix3D &m, Vector3D &out) { m.copyColumnTo(3, out); }
void Matrix3DUtils::getDown(const Matrix3D &m, Vector3D &out) { m.copyColumnTo(1, out); out.negate(); }
void Matrix3DUtils::getBackward(const Matrix3D &m, Vector3D &out) { m.copyColumnTo(2, out); out.negate(); }
void Matrix3DUtils::getDir(const Matrix3D &m, Vector3D &out) { m.copyColumnTo(2, out); }