SteamVRTrackPoint.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Include own headers
  2. #include "SteamVRTrackPoint.hpp"
  3. // Include modules
  4. #include "MeshTools.hpp"
  5. SteamVRTrackPoint::SteamVRTrackPoint(const osg::Vec3 point, const osg::Vec3 normal, const osg::Vec3 normalModifier, const float normalRotation, const bool compensation, const double length): TrackPoint(point, normal, normalModifier, normalRotation, compensation) {
  6. _length = length;
  7. updateShift();
  8. }
  9. double SteamVRTrackPoint::getLength() {
  10. return _length;
  11. }
  12. SteamVRTrackSettings SteamVRTrackPoint::getSteamVRTrackSettings() {
  13. return SteamVRTrackSettings {_length};
  14. }
  15. void SteamVRTrackPoint::updateSteamVRTrackSettings(SteamVRTrackSettings settings) {
  16. _length = settings.length;
  17. updateShift();
  18. }
  19. void SteamVRTrackPoint::updateShift() {
  20. osg::Vec3 shift = _normal.operator*(_length + STEAMVR_THREAD_LENGTH + STEAMVR_ORIGIN_OFFSET);
  21. _trackOrigin = shift.operator+(_origin);
  22. }
  23. float SteamVRTrackPoint::getNormalCompensation() {
  24. float compensationLength = MeshTools::compensationLength(_normal, _normalModifier, STEAMVR_CONSTANT_RADIUS);
  25. return compensationLength > 0.0f ? compensationLength : 0.0f;
  26. }
  27. int SteamVRTrackPoint::getMinimumRequiredPoints() {
  28. return _minimumPointsRequired;
  29. }