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::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::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::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::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::setVectors(Matrix3D &m, const Vector3D &right, const Vector3D &up, const Vector3D &dir) { m.copyColumnFrom(0, right); m.copyColumnFrom(1, up); m.copyColumnFrom(2, dir); }