Bladeren bron

Update normal modifier, now accepting rotation values in degree

Johannes Kreutz 3 jaren geleden
bovenliggende
commit
15ddf0c696
3 gewijzigde bestanden met toevoegingen van 30 en 9 verwijderingen
  1. 25 7
      trackpoint-app/gui/EditWidget.ui
  2. 3 1
      trackpoint-app/src/PointShape.cpp
  3. 2 1
      trackpoint-app/src/TrackPoint.cpp

+ 25 - 7
trackpoint-app/gui/EditWidget.ui

@@ -314,7 +314,7 @@
                </sizepolicy>
               </property>
               <property name="text">
-               <string>Normal vector</string>
+               <string>Rotation around axis</string>
               </property>
              </widget>
             </item>
@@ -333,11 +333,17 @@
             </item>
             <item row="1" column="1">
              <widget class="QDoubleSpinBox" name="normalModX">
+              <property name="decimals">
+               <number>2</number>
+              </property>
+              <property name="minimum">
+               <double>0.000000000000000</double>
+              </property>
               <property name="maximum">
-               <double>1.000000000000000</double>
+               <double>360.000000000000000</double>
               </property>
               <property name="singleStep">
-               <double>0.010000000000000</double>
+               <double>1.000000000000000</double>
               </property>
              </widget>
             </item>
@@ -369,21 +375,33 @@
             </item>
             <item row="2" column="1">
              <widget class="QDoubleSpinBox" name="normalModY">
+              <property name="decimals">
+               <number>2</number>
+              </property>
+              <property name="minimum">
+               <double>0.000000000000000</double>
+              </property>
               <property name="maximum">
-               <double>1.000000000000000</double>
+               <double>360.000000000000000</double>
               </property>
               <property name="singleStep">
-               <double>0.010000000000000</double>
+               <double>1.000000000000000</double>
               </property>
              </widget>
             </item>
             <item row="3" column="1">
              <widget class="QDoubleSpinBox" name="normalModZ">
+              <property name="decimals">
+               <number>2</number>
+              </property>
+              <property name="minimum">
+               <double>0.000000000000000</double>
+              </property>
               <property name="maximum">
-               <double>1.000000000000000</double>
+               <double>360.000000000000000</double>
               </property>
               <property name="singleStep">
-               <double>0.010000000000000</double>
+               <double>1.000000000000000</double>
               </property>
              </widget>
             </item>

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

@@ -48,7 +48,9 @@ void PointShape::setNormalModifier(osg::Vec3f normalModifier) {
 }
 
 void PointShape::rotateToNormalVector(osg::Vec3f normal) {
-  normal = normal.operator+(_normalModifier);
+  osg::Matrix modifierRotation = osg::Matrix::rotate(_normalModifier.x() * M_PI / 180, osg::Vec3(1.0f, 0.0f, 0.0f), _normalModifier.y() * M_PI / 180, osg::Vec3(0.0f, 1.0f, 0.0f), _normalModifier.z() * M_PI / 180, osg::Vec3(0.0f, 0.0f, 1.0f));
+  normal = modifierRotation.preMult(normal);
+
   normal.normalize();
   _selectionRotateGroup->setMatrix(osg::Matrix::rotate(osg::Vec3f(0.0f, 0.0f, 1.0f), normal));
   if (_activeTrackingSystem == OptiTrack || _activeTrackingSystem == SteamVRTrack) {

+ 2 - 1
trackpoint-app/src/TrackPoint.cpp

@@ -16,7 +16,8 @@ osg::Vec3 TrackPoint::getTranslation() {
 
 osg::Vec3 TrackPoint::getRotation() {
   osg::Vec3 start = osg::Vec3(0.0f, 0.0f, 1.0f);
-  osg::Vec3 finalNormal = _normal.operator+(_normalModifier);
+  osg::Matrix modifierRotation = osg::Matrix::rotate(_normalModifier.x() * M_PI / 180, osg::Vec3(1.0f, 0.0f, 0.0f), _normalModifier.y() * M_PI / 180, osg::Vec3(0.0f, 1.0f, 0.0f), _normalModifier.z() * M_PI / 180, osg::Vec3(0.0f, 0.0f, 1.0f));
+  osg::Vec3 finalNormal = modifierRotation.preMult(normal);
 
   // From https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles
   osg::Quat quat = osg::Quat(0.0f, 0.0f, 0.0f, 0.0f);