Browse Source

Implement thin pin for optitrack (Closes #23)

Johannes Kreutz 2 years ago
parent
commit
2496f9a82a

+ 1 - 1
trackpoint-app/gui/EditWidget.ui

@@ -503,7 +503,7 @@
                 <item row="1" column="1">
                  <widget class="QDoubleSpinBox" name="optiTrackRadius">
                   <property name="minimum">
-                   <double>1.000000000000000</double>
+                   <double>1.500000000000000</double>
                   </property>
                   <property name="maximum">
                    <double>10.000000000000000</double>

+ 1 - 0
trackpoint-app/include/PointShape.hpp

@@ -38,6 +38,7 @@ private:
   osg::ref_ptr<osg::MatrixTransform> _screwMove;
   osg::ref_ptr<osg::Group> _renderRoot;
   osg::ref_ptr<osg::ShapeDrawable> _shape;
+  osg::ref_ptr<osg::ShapeDrawable> _optiConnector;
   osg::ref_ptr<osg::Geode> _thread;
   osg::ref_ptr<osg::Geode> _geode;
   osg::Vec3f _normalModifier;

+ 1 - 1
trackpoint-app/include/defaults.hpp

@@ -3,7 +3,7 @@
 #include <string>
 
 #define OPTITRACK_DEFAULT_LENGTH 10.0
-#define OPTITRACK_DEFAULT_RADIUS 1.0
+#define OPTITRACK_DEFAULT_RADIUS 1.5
 
 #define EMFTRACK_DEFAULT_WIDTH 50.0
 #define EMFTRACK_DEFAULT_HEIGHT 10.0

+ 4 - 1
trackpoint-app/src/OpenScadRenderer.cpp

@@ -19,7 +19,10 @@ const char* openScadBase =
   "$fn = 100;\n"
   "use <threads.scad>\n"
   "module optiTrackPointBase(translation, rotation, length, radius) {\n"
-  "translate(translation) rotate(rotation) cylinder(length, radius, radius, false);\n"
+  "translate(translation) rotate(rotation) {\n"
+  "cylinder(length - 5, radius, radius, false);\n"
+  "translate([0, 0, length - 5]) cylinder(5, 0.74, 0.74, false);\n"
+  "}\n"
   "}\n"
   "module emfTrackPointBase(translation, rotation, width, height, depth) {\n"
   "translate(translation) rotate(rotation) {\n"

+ 8 - 1
trackpoint-app/src/PointShape.cpp

@@ -71,6 +71,9 @@ void PointShape::setColor(osg::Vec4 color) {
   if (_thread) {
     OSGWidget::fixMaterialState(_thread, &color);
   }
+  if (_optiConnector) {
+    _optiConnector->setColor(color);
+  }
 }
 
 void PointShape::setupOptiTrack(OptiTrackSettings optiTrackSettings) {
@@ -78,9 +81,13 @@ void PointShape::setupOptiTrack(OptiTrackSettings optiTrackSettings) {
     _optiTrackSteamVRLength = optiTrackSettings.length;
     _geode = new osg::Geode;
     _shape = new osg::ShapeDrawable;
-    _shape->setShape(new osg::Cylinder(osg::Vec3(0.0f, 0.0f, 0.0f), optiTrackSettings.radius, optiTrackSettings.length));
+    _shape->setShape(new osg::Cylinder(osg::Vec3(0.0f, 0.0f, -2.5f), optiTrackSettings.radius, optiTrackSettings.length - 5.0f));
     _shape->setColor(osg::Vec4(1.0f, 1.0f, 1.0f, 0.2f));
     _geode->addDrawable(_shape.get());
+    _optiConnector = new osg::ShapeDrawable;
+    _optiConnector->setShape(new osg::Cylinder(osg::Vec3(0.0f, 0.0f, optiTrackSettings.length - 7.5f), 0.74f, 5.0f));
+    _optiConnector->setColor(osg::Vec4(1.0f, 1.0f, 1.0f, 0.2f));
+    _geode->addDrawable(_optiConnector.get());
     OSGWidget::fixMaterialState(_geode);
     _selectionRotateGroup->addChild(_geode.get());
   }