VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtOsgObserverObject.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2018 MAK Technologies, Inc.
3  * All rights reserved.
4  *****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
15 
16 #include <boost/unordered_map.hpp>
17 
18 #include <osg/Matrixd>
19 #include <osg/Vec3d>
20 #include <osg/Vec3>
21 
22 #include <list>
23 
24 class DtTaitBryan;
25 
26 namespace osg
27 {
28  class Node;
29 }
30 
31 namespace makVrv
32 {
33  class DtChannel;
34  class DtOsgChannel;
35  class DtCoordinateConverter;
36  class DtSceneObject;
37  class DtTerrainPatchObject;
38  class DtAgentUpdateResolverInterface;
39 
44  {
45 
46  public:
47 
49  {
50  TerrainResultNoData = 0,
52  TerrainResultComplete
53  };
54 
56  DtOsgObserverObject( DtDe& de, DtUniqueID id, const std::string& name="" );
57 
59  virtual ~DtOsgObserverObject();
60 
62  virtual void tick( double simTime );
63 
65  virtual void tickAttachment();
66 
69  virtual void setModelSet( int modelSet );
70 
72  virtual double altitude() const;
73 
74  virtual void setNameAndRegister( const std::string& name );
75 
81  virtual void setCameraPositionAndOrientation( const osg::Vec3d& position,
82  const osg::Quat& rotation );
83 
84  virtual void getCameraPositionAndOrientation( osg::Vec3d& position,
85  osg::Quat& rotation ) const;
86 
87 
89  static void matrixdToTaitBryan( const osg::Matrixd& mat, DtTaitBryan& tb, bool isWorld2D = false );
90  static double clampUnity( double x );
91 
92 
93  //
94  //
96  //
97  //
98 
100  virtual void startMoveObserverRight();
103  virtual void stopMoveObserverRight();
104  virtual void moveObserverRight( double meters );
105 
107  virtual void startMoveObserverForward();
110  virtual void stopMoveObserverForward();
111  virtual void moveObserverForward( double meters );
113 
115  virtual void startMoveObserverUp();
118  virtual void stopMoveObserverUp();
119  virtual void moveObserverUp( double meters );
121 
123  virtual void startMoveObserverLeft();
126  virtual void stopMoveObserverLeft();
127  virtual void moveObserverLeft( double meters );
129 
131  virtual void startMoveObserverBack();
134  virtual void stopMoveObserverBack();
135  virtual void moveObserverBack( double meters );
137 
139  virtual void startMoveObserverDown();
142  virtual void stopMoveObserverDown();
143  virtual void moveObserverDown( double meters );
145 
147  virtual void startMoveLevelObserverRight();
151  virtual void stopMoveLevelObserverRight();
152  virtual void moveLevelObserverRight( double meters );
154 
156  virtual void startMoveLevelObserverForward();
160  virtual void stopMoveLevelObserverForward();
161  virtual void moveLevelObserverForward( double meters );
163 
165  virtual void startMoveLevelObserverUp();
169  virtual void stopMoveLevelObserverUp();
170  virtual void moveLevelObserverUp( double meters );
172 
174  virtual void startMoveLevelObserverLeft();
178  virtual void stopMoveLevelObserverLeft();
179  virtual void moveLevelObserverLeft( double meters );
181 
183  virtual void startMoveLevelObserverBack();
187  virtual void stopMoveLevelObserverBack();
188  virtual void moveLevelObserverBack( double meters );
190 
192  virtual void startMoveLevelObserverDown();
195  virtual void stopMoveLevelObserverDown();
196  virtual void moveLevelObserverDown( double meters );
198 
200  virtual void startMoveAttachedRight();
203  virtual void stopMoveAttachedRight();
204  virtual void moveAttachedRight( double meters );
205 
207  virtual void startMoveAttachedForward();
210  virtual void stopMoveAttachedForward();
211  virtual void moveAttachedForward( double meters );
213 
215  virtual void startMoveAttachedUp();
218  virtual void stopMoveAttachedUp();
219  virtual void moveAttachedUp( double meters );
221 
223  virtual void startMoveAttachedLeft();
226  virtual void stopMoveAttachedLeft();
227  virtual void moveAttachedLeft( double meters );
229 
231  virtual void startMoveAttachedBack();
234  virtual void stopMoveAttachedBack();
235  virtual void moveAttachedBack( double meters );
237 
239  virtual void startMoveAttachedDown();
242  virtual void stopMoveAttachedDown();
243  virtual void moveAttachedDown( double meters );
245 
247  virtual void startMoveLevelAttachedRight();
251  virtual void stopMoveLevelAttachedRight();
252  virtual void moveLevelAttachedRight( double meters );
254 
256  virtual void startMoveLevelAttachedForward();
260  virtual void stopMoveLevelAttachedForward();
261  virtual void moveLevelAttachedForward( double meters );
263 
265  virtual void startMoveLevelAttachedUp();
269  virtual void stopMoveLevelAttachedUp();
270  virtual void moveLevelAttachedUp( double meters );
272 
274  virtual void startMoveLevelAttachedLeft();
278  virtual void stopMoveLevelAttachedLeft();
279  virtual void moveLevelAttachedLeft( double meters );
281 
283  virtual void startMoveLevelAttachedBack();
287  virtual void stopMoveLevelAttachedBack();
288  virtual void moveLevelAttachedBack( double meters );
290 
292  virtual void startMoveLevelAttachedDown();
295  virtual void stopMoveLevelAttachedDown();
296  virtual void moveLevelAttachedDown( double meters );
298 
300  virtual void startMoveAttachedContextRight();
303  virtual void stopMoveAttachedContextRight();
304  virtual void moveAttachedContextRight( double meters );
306 
308  virtual void startMoveAttachedContextForward();
311  virtual void stopMoveAttachedContextForward();
312  virtual void moveAttachedContextForward( double meters );
314 
316  virtual void startMoveAttachedContextUp();
319  virtual void stopMoveAttachedContextUp();
320  virtual void moveAttachedContextUp( double meters );
322 
324  virtual void startMoveAttachedContextLeft();
327  virtual void stopMoveAttachedContextLeft();
328  virtual void moveAttachedContextLeft( double meters );
330 
332  virtual void startMoveAttachedContextBack();
335  virtual void stopMoveAttachedContextBack();
336  virtual void moveAttachedContextBack( double meters );
338 
340  virtual void startMoveAttachedContextDown();
342  virtual void stopMoveAttachedContextDown();
343  virtual void moveAttachedContextDown( double meters );
345 
347  virtual void startYawLeft();
350  virtual void stopYawLeft();
351  virtual void rotateYawLeft(double rads);
353 
355  virtual void startYawRight();
359  virtual void stopYawRight();
360  virtual void rotateYawRight(double rads);
362 
364  virtual void startPitchUp();
367  virtual void stopPitchUp();
368  virtual void rotatePitchUp( double rads );
369  virtual void rotateFlashlightPitchUp( double rads );
371 
373  virtual void startPitchDown();
376  virtual void stopPitchDown();
377  virtual void rotatePitchDown( double rads );
378  virtual void rotateFlashlightPitchDown( double rads );
380 
382  virtual void startRollLeft();
385  virtual void stopRollLeft();
386  virtual void rollLeft(double rads);
388 
390  virtual void startRollRight();
393  virtual void stopRollRight();
394  virtual void rollRight(double rads);
396 
398  virtual void startLevelYawLeft();
401  virtual void stopLevelYawLeft();
403 
405  virtual void startLevelYawRight();
409  virtual void stopLevelYawRight();
411 
413  virtual void startLevelPitchUp();
416  virtual void stopLevelPitchUp();
417  virtual void rotateLevelPitchUp(double rads);
419 
421  virtual void startLevelPitchDown();
424  virtual void stopLevelPitchDown();
425  virtual void rotateLevelPitchDown(double rads);
427 
429  virtual void startLevelRollLeft();
432  virtual void stopLevelRollLeft();
433  virtual void rollLevelLeft(double rads);
435 
437  virtual void startLevelRollRight();
440  virtual void stopLevelRollRight();
441  virtual void rollLevelRight(double rads);
443 
444  virtual void rotateLevelYawLeft( double rads );
445  virtual void rotateLevelYawRight( double rads );
446  virtual void rotateFlashlightYawLeft( double rads );
447  virtual void rotateFlashlightYawRight( double rads );
448 
449  virtual void startLookLeft();
450  virtual void stopLookLeft();
451  virtual void lookLeft( double rads );
452 
453  virtual void startLookRight();
454  virtual void stopLookRight();
455  virtual void lookRight( double rads );
456 
457  virtual void startLookUp();
458  virtual void stopLookUp();
459  virtual void lookUp( double rads );
460 
461  virtual void startLookDown();
462  virtual void stopLookDown();
463  virtual void lookDown( double rads );
464 
465  virtual void startLookTiltRight();
466  virtual void stopLookTiltRight();
467  virtual void lookTiltRight( double rads );
468 
469  virtual void startLookTiltLeft();
470  virtual void stopLookTiltLeft();
471  virtual void lookTiltLeft( double rads );
472 
474  virtual void startOrbitingLeft();
477  virtual void stopOrbitingLeft();
478  virtual void orbitLeft( double rads );
480 
482  virtual void startOrbitingRight();
485  virtual void stopOrbitingRight();
486  virtual void orbitRight( double rads );
488 
490  virtual void startOrbitingUp();
493  virtual void stopOrbitingUp();
494  virtual void orbitUp( double rads );
496 
498  virtual void startOrbitingDown();
501  virtual void stopOrbitingDown();
502  virtual void orbitDown( double rads );
504 
506  virtual void setLocation( double x, double y, double z);
507 
511  virtual void setAttachedLocation( double x, double y, double z );
512 
514  virtual void setOrientation( double psi, double theta, double phi );
515 
517  virtual void setTopographicOrientation( double psi, double theta, double phi );
518 
520  virtual void setOrientation( double x, double y, double z, double w);
521 
523  virtual void setAttachedOrientation( double psi, double theta, double phi );
524 
526  virtual void setAttachedOrientation( double x, double y, double z,
527  double w);
528 
531  void setLocalModelScalingEnabled( bool enabled );
532 
535  void setLocalModelScalingAmount( float amount );
536 
539  virtual void jumpTo( double x, double y, double z );
540 
542  virtual void jumpTo( DtUniqueID elementID );
543 
544  virtual void orientTo( double x, double y, double z );
545 
547  virtual void dragTerrain( double lastX, double lastY, double lastZ,
548  double currX, double currY, double currZ );
549 
550  virtual void dragTerrain2( double myStartDragX, double myStartDragY,
551  double myStartDragZ, int deltaMouseX, int deltaMouseY );
552 
553  virtual void dragGravityUp( double windowUnits );
554  virtual void dragGravityDown( double windowUnits );
555  virtual void dragGravityLeft( double windowUnits );
556  virtual void dragGravityRight( double windowUnits );
557  virtual void scrollObserverForward( int wheelUnits );
558  virtual void scrollObserverBack( int wheelUnits );
559  virtual void scrollLevelObserverForward( int wheelUnits );
560  virtual void scrollLevelObserverBack( int wheelUnits );
561 
562  virtual void scrollFlashlightWider( int wheelUnits );
563  virtual void scrollFlashlightNarrower( int wheelUnits );
564 
566  virtual float flashlightAngle();
567 
568  //{@
570  virtual void startIncreasingViewResolution();
571  virtual void stopIncreasingViewResolution();
572  virtual void increaseViewResolution();
573 
574  virtual void startDecreasingViewResolution();
575  virtual void stopDecreasingViewResolution();
576  virtual void decreaseViewResolution();
577 
578  // Sets the view resolution in meters per pixel.
579  virtual void setViewResolution( double resolution);
580 
581  // Get the current view resolution.
582  virtual double viewResolution() const;
583 
589  virtual void setCurrentViewMagnification( double mag );
590 
592  virtual double currentViewMagnification() const;
593 
595 
596  //
598  //
599 
601  virtual void setOrbitSpeed( double speed );
602 
604  virtual void setLinearSpeed( double speed );
605 
607  virtual void setRotationSpeed( double speed );
608 
610  virtual void setMinLinearSpeed( double minSpeed );
611 
613  virtual void setMaxLinearSpeed( double maxSpeed );
614 
616  virtual void setLinearScaledSpeedGain( double gain );
617 
623  virtual void gotoTerrainCenter( DtUniqueID terrainPatch, bool retry );
624 
626  virtual void resetAttachment();
627 
628  virtual void resetOrientation();
629 
631  virtual void resetCamera();
632  virtual void level();
633 
634  virtual void stopAll();
635 
636  virtual void attachToObjects( const std::vector<DtUniqueID>& elementIds );
637  virtual void setSecondaryAttachment( const std::vector<DtUniqueID>& elementIds );
638  virtual void setLocationTrackAttachment( const osg::Vec3d& location );
639  virtual void setLocationTrackAttachment( double x, double y, double z );
640 
641  virtual void attachToPart( int partId);
642  virtual void detach();
643  virtual void setAttachType( DtObserverObject::AttachType type );
644  virtual void setHideModelOnAttach( bool hide );
645 
649  virtual void setAttachmentHas3DCockpit( bool cockpit );
650 
651  virtual void scaleCurrentAttachments( bool scaled );
652  virtual void setOrientToTargetConstraint( bool orient );
653  virtual void setOrbiting( bool orbit );
654  virtual void setOrientCameraToTargetConstraint( bool orient );
655 
656  virtual void setConstrainToTerrain( bool trueFalse );
657  virtual void setConstrainToCenter( bool trueFalse );
658 
661  virtual void suppressConstrainToTerrain( bool trueFalse );
662 
663  virtual void setSpeedScaling( bool trueFalse );
664 
666  virtual void setSpeedScaledSpeed( double speed );
667 
669  virtual void getLocation(double &x, double &y, double& z) const;
671  virtual void getObserverPosition(double &x, double &y, double& z) const;
672  virtual void getEffectiveLocation(double &x, double &y, double& z) const;
674 
676  virtual void getObserverCameraPosition(double& x, double& y, double& z) const;
677 
679  virtual void getOrientation( double& psi, double& theta, double& phi ) const;
680 
683  virtual void getObserverCameraOrientation(double& psi, double& theta, double& phi, bool includeShake) const;
684 
686  virtual void getTopographicOrientation( double& psi, double& theta, double& phi ) const;
687 
688  virtual void getOrientation( double& x, double& y, double& z, double& w ) const;
689 
690  virtual void getFlashlightOrientation( double& x, double& y, double& z, double& w ) const;
691 
694  virtual void getObserverPlatformFront(double& x, double& y, double& z) const;
695 
698  virtual void getObserverPlatformUp(double& x, double& y, double& z) const;
699 
702  virtual void getObserverPlatformRight(double& x, double& y, double& z) const;
703 
706  virtual void getObserverCameraFront(double& x, double& y, double& z, bool includeShake) const;
707 
709  virtual void getObserverCameraUp(double& x, double& y, double& z, bool includeShake) const;
710 
712  virtual void getObserverCameraRight(double& x, double& y, double& z, bool includeShake) const;
713 
714  virtual void getCameraUp(double& x, double& y, double& z);
715 
716  virtual void getCameraFront(double& x, double& y, double& z);
717 
718  virtual void getCameraRight(double& x, double& y, double& z);
719 
721  virtual void setCameraShakeRotation(double x, double y, double z, double w);
722 
724  virtual void getCameraShakeRotation(double& x, double& y, double& z, double& w);;
725 
728 // virtual double calculate2DAltitude();
729 
730 
733  virtual double heightAboveTerrainFromCurrentZoom(double magnification = 1.) const;
734 
738  virtual double altitudeFromCurrentZoom(double magnification=1.) const;
739 
742  virtual double zoomFromHeightAboveTerrain(double hat, double magnification=1) const;
743 
746  virtual double zoomFromAltitude(double altitude, double magnification=1.) const;
747 
748 
752  virtual double zoomFromCurrentAltitude() const;
753 
756  virtual double topographicHeading() const;
757 
759  virtual void getLinearVelocity(double &x, double &y, double &z) const;
760 
762  virtual void getRotationalVelocity( double& x, double& y, double& z) const;
763 
767  virtual void setModeSetting( int setting, bool value );
768 
770  virtual std::vector<DtUniqueID> currentAttachments() const;
771 
774 
775  virtual const osg::Vec3d& locationTrackAttachmentVec3d() const;
776  virtual void getLocationTrackAttachment( double& x, double& y, double& z ) const;
778 
782  virtual DtObserverObject::AttachType attachType3D() const;
783 
787  virtual DtObserverObject::AttachType attachType2D() const;
788 
790  virtual bool attachedObjectHidden() const;
791 
795  virtual bool attachmentHas3DCockpit() const;
796 
799  virtual osg::Vec3d attachedOffsetVector() const;
800 
805  virtual double attachedNearClipOffset() const;
806 
808  virtual double heightAboveTerrain() const;
809 
811  virtual double heightOfTerrain() const;
812  private:
813 
816 
818  DtOsgObserverObject& operator=( const DtOsgObserverObject& );
819 
820  protected:
821 
823  virtual bool shouldOrientToGlobeCenter();
824 
826  virtual void adjustToGlobeCurvature();
827 
829  virtual bool shouldRotateGlobe();
830 
831  virtual void calcObserverWorldVectors();
832  virtual const osg::Vec3d& observerWorldUp() const;
833  virtual const osg::Vec3d& observerWorldNorth() const;
834  virtual const osg::Vec3d& observerWorldEast() const;
835 
836  virtual const osg::Vec3d& attachedWorldUp() const;
837 
838  virtual osg::Vec3d& observerUp();
839  virtual osg::Vec3d& observerFront();
840  virtual osg::Vec3d& observerRight();
841  virtual void observerBasis(osg::Vec3d& up, osg::Vec3d& front, osg::Vec3d& right);
842 
843  virtual osg::Vec3d& attachedUp();
844  virtual osg::Vec3d& attachedFront();
845  virtual osg::Vec3d& attachedRight();
846 
847  virtual osg::Vec3d& attachedOffsetUp();
848  virtual osg::Vec3d& attachedOffsetFront();
849  virtual osg::Vec3d& attachedOffsetRight();
850 
852  virtual osg::Vec3d& levelAttachedUp();
853  virtual osg::Vec3d& levelAttachedFront();
854  virtual osg::Vec3d& levelAttachedRight();
855 
857  virtual osg::Vec3d& levelObserverMimicUp();
858  virtual osg::Vec3d& levelObserverMimicFront();
859  virtual osg::Vec3d& levelObserverMimicRight();
860 
861  virtual osg::Vec3d& cameraUp();
862  virtual osg::Vec3d& cameraFront();
863  virtual osg::Vec3d& cameraRight();
864 
865  virtual osg::Vec3d& levelObserverUp();
866  virtual osg::Vec3d& levelObserverFront();
867  virtual osg::Vec3d& levelObserverRight();
868 
869  virtual void advanceOrbitLeft( double rads );
870  virtual void advanceOrbitRight( double rads );
871  virtual void advanceOrbitUp( double rads );
872  virtual void advanceOrbitDown( double rads );
873 
874  virtual void makeLevelObserverMatrix();
875 
877  virtual void calculateLevelAttachedRotation();
878 
880  virtual void makeLevelObserverMimicMatrix();
881 
885  virtual osg::Vec3d calcWorldPositionChange();
886 
887  virtual osg::Vec3d calcMimicPositionChange();
888 
889  virtual osg::Vec3d calcAttachedPosition(const osg::Quat& attInverse, const osg::Vec3d& attachedAdvance);
890  virtual osg::Vec3d calcAttachedAdvance(const osg::Quat& tetherTrackInverse);
891 
892  virtual osg::Vec3d calcFollowPositionChange();
893  virtual osg::Vec3d calcSpaceFollowPositionChange();
894  virtual osg::Vec3d calcTetherPositionChange();
895  virtual osg::Vec3d calcTetherTrackPositionChange();
896 
897  virtual osg::Vec3d calcTrackPositionChange();
898  virtual osg::Quat calcTetherTrackRotation();
899 
900  virtual osg::Quat calcFlashlightOrientationChange();
901  virtual osg::Quat calcWorldOrientationChange();
902  virtual osg::Quat calcTetherOrientationChange();
903  virtual osg::Quat calcMimicOrientationChange();
904  virtual osg::Quat calcFollowOrientationChange();
905 
906  virtual void setCurrentAttachmentsVisibility( bool visible );
907 
914 
917  virtual void orientTo( const osg::Vec3d& target );
918 
920  virtual void orientCameraTo( const osg::Vec3d& target );
921 
922  virtual TerrainResult getTerrainCenter( const DtUniqueID& patchID, osg::Vec3d& center );
923 
924  virtual DtCoordinateConverter& coordinateConverter();
925  virtual const DtCoordinateConverter& coordinateConverter() const;
926 
927  virtual void initializeAttachment();
928 
929  virtual const osg::Vec3d& scalingIntersection() const;
930  virtual void getViewIntersection();
931 
933  virtual double linearSpeed();
934 
936  virtual double speedScalingGain() const;
937 
938  virtual void calcTerrainConstraint(const osg::Vec3d& prev );
939 
945  virtual bool updateAttachPositionAndOrientation();
946 
947  virtual bool getSecondaryAttachPosition( osg::Vec3d& position );
948 
949  virtual void getObserverOffsetVector( double& x, double& y, double& z ) const;
950  virtual void setObserverOffsetVector( double x, double y, double z );
951 
954 
955  virtual void getCameraFromParentOffsetVector( double& x, double& y, double& z ) const;
956  virtual void getCameraFromParentRotationOffset( double& x, double& y, double& z, double& w ) const;
958 
959  virtual void getAttachedRotationOffset( double& x, double& y, double& z, double& w ) const;
960  virtual void setAttachedRotationOffset( double x, double y, double z,
961  double w );
962 
963  virtual void getBoundingVolume( DtSceneObject& sceneObject,
964  osg::Vec3& bvolExtents, osg::Vec3d& bvolCenter );
965 
966  virtual void getBoundingVolume( DtTerrainPatchObject& patchObject,
967  osg::Vec3& bvolExtents, osg::Vec3d& bvolCenter );
968 
969  virtual void setLocation( const osg::Vec3d& location, bool suppress=true );
970 
971  virtual bool isMoving() const;
972  virtual bool isRotating() const;
973 
974  virtual double computeNearClipDistance( DtSceneObject* sceneObject );
975  virtual float computeLocalModelScalingAmount( DtSceneObject* sceneObject );
976 
977  virtual void calcScaledSpeed();
978  virtual bool getTerrainOrPropIntersection( const osg::Vec3d& startPos,
979  const osg::Vec3d& endPos, osg::Vec3d& result ) const;
980 
982  virtual DtSceneObject* findSceneObjectFromElement(const DtElementID& id);
983 
985  virtual DtTerrainPatchObject* findTerrainPatchObjectFromElement( DtElementID id );
986  virtual DtOsgObserverObject* findObserverObjectFromElement( DtElementID id );
987 
988  virtual void getPositionAndOrientation( DtSceneObject& sceneObject, osg::Vec3d& position,
989  osg::Vec3d& orientToPosition, osg::Quat& orientation );
990 
991  virtual void getPositionAndOrientation( DtTerrainPatchObject& patchObject, osg::Vec3d& position,
992  osg::Vec3d& orientToPosition, osg::Quat& orientation );
993 
994  virtual void getPositionAndOrientation( DtOsgObserverObject& observerObject, osg::Vec3d& position,
995  osg::Vec3d& orientToPosition, osg::Quat& orientation );
996 
998  virtual void getPositionFromSceneObject( DtSceneObject& sceneObject, osg::Vec3d& position ) const;
999 
1001  virtual void getPositionFromObserverObject( DtOsgObserverObject& observerObject, osg::Vec3d& position ) const;
1002 
1005  virtual bool getPartPositionOriFromSceneObject( DtSceneObject& sceneObject,
1006  int partId, osg::Vec3d& position, osg::Quat& ori ) const;
1007 
1010  virtual void force2D();
1011 
1013  virtual void dimensionChanged( bool is2D );
1014  virtual void setIs2D( bool is2D );
1015 
1017  virtual double calculate3DAltitude() const;
1018 
1020  virtual void calculateAltitude();
1021 
1022  // Sends the location of the observer on the master to all others; only used
1023  // if different
1024  virtual void synchronizeLocation( double x, double y, double z );
1025 
1026  // Sends the orientation of the observer on the master to all others; only used
1027  // if different
1028  virtual void synchronizeOrientation( double x, double y, double z, double w );
1029 
1045  virtual void calcHeightAboveTerrain(bool force=false);
1046 
1048  std::list<DtChannel*> findChannels();
1051  std::list<const DtChannel*> findChannels() const;
1053 
1062  double frustumPixelHeight() const;
1063 
1064  protected:
1065 
1066  static const double theObserverBoundingSphere;
1068 
1069  static const double theMaxTerrainRetryTime;
1070 
1071  // below this altitude, ignore myConstrainToCenter
1072  static const double theCenterConstrainHeight;
1073 
1074  // Zoom won't get any smaller than this
1075  static const double theMinViewResolution;
1076 
1077  // Zoom won't get any larger than this
1078  static const double theMaxViewResolution;
1079 
1080 
1081  protected:
1082 
1083  std::vector<DtUniqueID> myCurrentAttachments;
1084  std::vector<DtUniqueID> mySecondaryAttachments;
1086 
1089 
1090  //
1092  //
1101 
1104 
1107 
1110 
1113 
1116 
1118 
1120 
1122  osg::Vec3d myDragMove;
1123 
1125 
1126  osg::Vec3d myOrbitAdvance;
1127 
1133 
1136 
1139  osg::Quat myMasterRotation;
1140 
1143 
1146 
1151 
1154 
1157 
1160 
1164 
1165  //bool myGlobeObserverMode;
1167 
1170 
1172  {
1173  public:
1174 
1176  {
1177  Stopped = 0,
1178  Forward = 1,
1179  Backward = 2,
1180  Left = 4,
1181  Right = 8,
1182  Up = 16,
1183  Down = 32
1184  };
1185 
1187  : myState(Stopped)
1188  {
1189  }
1190 
1192  inline void applyMovement(double linearDistance)
1193  {
1194  if(moving(Right)) myAdvance[0] += linearDistance;
1195  if(moving(Left)) myAdvance[0] -= linearDistance;
1196  if(moving(Forward)) myAdvance[1] += linearDistance;
1197  if(moving(Backward)) myAdvance[1] -= linearDistance;
1198  if(moving(Up)) myAdvance[2] += linearDistance;
1199  if(moving(Down)) myAdvance[2] -= linearDistance;
1200  }
1201 
1203  inline const osg::Vec3d& advance() const
1204  {
1205  return myAdvance;
1206  }
1207 
1208  inline void stop()
1209  {
1210  myState = Stopped;
1211  myAdvance.set(0.0,0.0,0.0);
1212  myEuler.set(0.0,0.0,0.0);
1213  }
1214 
1215  inline void clearAdvance()
1216  {
1217  myAdvance.set(0.0,0.0,0.0);
1218  }
1219 
1220  inline bool stopped()
1221  {
1222  return myState == Stopped;
1223  }
1224 
1225  inline bool moving() const
1226  {
1227  return myState != Stopped;
1228  }
1229 
1230  inline bool moving(Direction d) const
1231  {
1232  return (myState & d) != 0;
1233  }
1234 
1235  inline void setMoving(Direction d, bool moving)
1236  {
1237  myState = moving ? myState | d : myState & ~d;
1238  }
1239 
1240  enum Angle
1241  {
1242  YawLeft = 1,
1243  YawRight = 2,
1244  PitchUp = 4,
1245  PitchDown = 8,
1246  RollLeft = 16,
1247  RollRight = 32
1248  };
1249 
1250  inline void applyRotation(double angle)
1251  {
1252  if(rotating(YawRight)) myEuler[0] -= angle;
1253  if(rotating(YawLeft)) myEuler[0] += angle;
1254  if(rotating(PitchUp)) myEuler[1] += angle;
1255  if(rotating(PitchDown)) myEuler[1] -= angle;
1256  if(rotating(RollRight)) myEuler[2] += angle;
1257  if(rotating(RollLeft)) myEuler[2] -= angle;
1258  }
1259 
1260  inline const osg::Vec3d& euler() const
1261  {
1262  return myEuler;
1263  }
1264 
1265  inline osg::Vec3d& euler()
1266  {
1267  return myEuler;
1268  }
1269 
1270  inline void level()
1271  {
1272  myEuler.set(0.0,0.0,0.0);
1273  }
1274 
1275  inline bool rotating() const
1276  {
1277  return myState != Stopped;
1278  }
1279 
1280  inline bool rotating( Angle d ) const
1281  {
1282  return (myState & d) != 0;
1283  }
1284 
1285  inline void setRotating( Angle d, bool rotating )
1286  {
1287  myState = rotating ? myState | d : myState & ~d;
1288  }
1289 
1290  protected:
1291 
1295  osg::Vec3d myAdvance;
1296  osg::Vec3d myEuler;
1297 
1298  unsigned char myState;
1299  };
1300 
1305 
1310 
1312 
1317 
1321 
1327 
1331 
1332  //
1341 
1345 
1349 
1351  osg::Vec3d myCameraOffset;
1353  osg::Quat myCameraRotation;
1354 
1355  osg::Vec3d myObserverWorldUp;
1358 
1359  osg::Vec3d myAttachedWorldUp;
1362 
1363  osg::Vec3d myObserverUp;
1364  osg::Vec3d myObserverFront;
1365  osg::Vec3d myObserverRight;
1366 
1367  osg::Vec3d myLevelObserverUp;
1370 
1371  osg::Vec3d myAttachedUp;
1372  osg::Vec3d myAttachedFront;
1373  osg::Vec3d myAttachedRight;
1374 
1375  osg::Vec3d myLevelAttachedUp;
1378 
1382 
1386 
1387  osg::Vec3d myCameraUp;
1388  osg::Vec3d myCameraFront;
1389  osg::Vec3d myCameraRight;
1390 
1392 
1397 
1399 
1402 
1405 
1414  // force an orientation reset AFTER the next time the observer position is updated
1415  // Needed when making large attach jumps
1417 
1419 
1421  osg::Vec3d myViewIntersect;
1422 
1424  mutable osg::Vec3d myMutableDownIntersect;
1425 
1426  osg::Vec3d myAttachPosition;
1427 
1430 
1434 
1435  double myAltitude;
1436 
1441 
1445 
1446  typedef boost::unordered_map<DtElementID, bool> ElementVisibilityMap;
1448 
1449  // Paged terrain initialization
1457 
1458  // Used for speed scaling, this is the same as myHeightAboveTerrain
1459  // when unattached, but the distance from the attached entity when
1460  // attached
1462 
1463  // curvature adjustment
1467 
1468  osg::Quat myCameraShakeRot;
1469 
1471  };
1472 
1473 }
osg::Quat myCameraRotation
This is the camera (wrt the observer) as a quaternion.
Definition: DtOsgObserverObject.h:1353
osg::Vec3d myDragMove
Change in world position due to drag.
Definition: DtOsgObserverObject.h:1122
osg::Vec3d myMutableDownIntersect
Definition: DtOsgObserverObject.h:1424
Definition: DtOsgObserverObject.h:51
bool myHaveViewIntersect
Definition: DtOsgObserverObject.h:1420
void setRotating(Angle d, bool rotating)
Definition: DtOsgObserverObject.h:1285
ElementVisibilityMap myPendingVisibilityState
Definition: DtOsgObserverObject.h:1447
bool myAttachmentHas3DCockpit
Definition: DtOsgObserverObject.h:1394
osg::Vec3d myLevelObserverMimicUp
Definition: DtOsgObserverObject.h:1379
osg::Vec3d myAttachedWorldEast
Definition: DtOsgObserverObject.h:1361
int myOrientToTargetConstraint
This is an int rather than a bool because we increment/decrement it, much like a reference pointer...
Definition: DtOsgObserverObject.h:1410
osg::Vec3d myObserverUp
Definition: DtOsgObserverObject.h:1363
double myHeightOfTerrain
Definition: DtOsgObserverObject.h:1456
std::vector< DtUniqueID > myCurrentAttachments
Definition: DtOsgObserverObject.h:1083
double myStartGotoTerrainCenterTime
Definition: DtOsgObserverObject.h:1452
osg::Quat my2DTo3DCachedRotation
Definition: DtOsgObserverObject.h:1159
osg::Quat myLevelAttachedRotation
Definition: DtOsgObserverObject.h:1153
osg::Vec3d myAttachedOffsetUp
Definition: DtOsgObserverObject.h:1383
osg::Vec3d myAttachedOffsetRight
Definition: DtOsgObserverObject.h:1385
osg::Vec3d myOrbitAdvance
Definition: DtOsgObserverObject.h:1126
DtCoordinateConverter is the base class for &#39;local (cig) to geocentric&#39; converters.
Definition: DtCoordinateConverter.h:25
osg::Vec3d myCameraRight
Definition: DtOsgObserverObject.h:1389
osg::Vec3d myCameraUp
Definition: DtOsgObserverObject.h:1387
double myHeightAboveTerrain
Definition: DtOsgObserverObject.h:1455
double myMaxLinearSpeed
Need just these, for terrain scaling.
Definition: DtOsgObserverObject.h:1323
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
double myLinearSpeed
Definition: DtOsgObserverObject.h:1319
This form is used for doing level (&#39;flying carpet&#39;) style movements.
Definition: DtOsgObserverObject.h:1171
osg::Vec3d myLevelAttachedFront
Definition: DtOsgObserverObject.h:1376
DT_DLL_VRVCORE DtTaitBryan level(const DtCoordinateSystem &cs, const DtVector &localOrigin, double topoHeading)
Returns a level orientation with the topographic heading.
bool myOrbitingLeft
Definition: DtOsgObserverObject.h:1313
osg::Vec3d myObserverPosition
Change in observer position this frame.
Definition: DtOsgObserverObject.h:1112
MotionState myFlashlightRotatingState
Definition: DtOsgObserverObject.h:1311
osg::Vec3d myLocationAttachPoint
Definition: DtOsgObserverObject.h:1470
osg::Vec3d my2DTo3DCachedObserverOffsetVector
Definition: DtOsgObserverObject.h:1158
osg::Vec3d myLevelAttachedPosition
Definition: DtOsgObserverObject.h:1119
double mySceneCenterOffsetX
Definition: DtOsgObserverObject.h:1328
void level()
Definition: DtOsgObserverObject.h:1270
bool mySpeedScaling
Definition: DtOsgObserverObject.h:1395
bool myViewResolutionDecreasingState
Definition: DtOsgObserverObject.h:1439
osg::Vec3d myLevelObserverFront
Definition: DtOsgObserverObject.h:1368
double myViewResolution
Definition: DtOsgObserverObject.h:1440
bool myLookingUp
Definition: DtOsgObserverObject.h:1337
osg::Vec3d myAttachedOffsetFront
Definition: DtOsgObserverObject.h:1384
osg::Matrixd myLevelObserverRotationMatrix
Definition: DtOsgObserverObject.h:1156
bool myOrbitingUp
Definition: DtOsgObserverObject.h:1315
static const double theCenterConstrainHeight
Definition: DtOsgObserverObject.h:1072
void applyMovement(double linearDistance)
Update the advance based upon the movement.
Definition: DtOsgObserverObject.h:1192
TerrainResult
Definition: DtOsgObserverObject.h:48
bool myOrbitingDown
Definition: DtOsgObserverObject.h:1316
bool myInternalSuppressConstrainToTerrain
suppress when jumping...
Definition: DtOsgObserverObject.h:1401
osg::Vec3d myObserverWorldUp
Definition: DtOsgObserverObject.h:1355
bool rotating(Angle d) const
Definition: DtOsgObserverObject.h:1280
osg::Vec3d myAttachedWorldNorth
Definition: DtOsgObserverObject.h:1360
osg::Vec3d myLevelObserverRight
Definition: DtOsgObserverObject.h:1369
bool myHaveTerrainPivot
Definition: DtOsgObserverObject.h:1418
const osg::Vec3d & advance() const
Get the current movement advance.
Definition: DtOsgObserverObject.h:1203
osg::Vec3d myAttachedFront
Definition: DtOsgObserverObject.h:1372
osg::Vec3d myLevelAttachedUp
Definition: DtOsgObserverObject.h:1375
osg::Quat myAttachedRotationOffset
My Attached rotation offset.
Definition: DtOsgObserverObject.h:1135
osg::Quat myPreviousAttachedObserverRotation
This is here so we can be in tether attach mode, detach, then attach to another entity and have a rea...
Definition: DtOsgObserverObject.h:1150
DtUniqueID DtElementID
The ElementID is a specific type of unique ID used to represent VR-Vantage uniquely defined elements...
Definition: DtUniqueID.h:26
double mySpeedScaleHeightEquivalent
Definition: DtOsgObserverObject.h:1461
MotionState myAbsoluteLevelRotatingState
Definition: DtOsgObserverObject.h:1309
unsigned char myState
Definition: DtOsgObserverObject.h:1298
bool myLookingTiltLeft
Definition: DtOsgObserverObject.h:1340
double myLinearScaledSpeedGain
Definition: DtOsgObserverObject.h:1325
osg::Vec3d myObserverPositionVector
— Observer
Definition: DtOsgObserverObject.h:1094
bool myLookingLeft
Definition: DtOsgObserverObject.h:1336
osg::Vec3d myPreviousOffsetVector
Definition: DtOsgObserverObject.h:1433
bool myGotoTerrainCenterPending
Definition: DtOsgObserverObject.h:1450
A DtTerrainPatchObject contains the methods for loading a file as a terrain.
Definition: DtTerrainPatchObject.h:37
static const double theHeightAboveTerrainUpdatePeriod
Definition: DtOsgObserverObject.h:1067
bool myOrientToOnReset
Definition: DtOsgObserverObject.h:1412
bool myViewResolutionIncreasingState
note, this is only calculated if myConstrainToCenter is true
Definition: DtOsgObserverObject.h:1438
osg::Vec3d myObserverWorldEast
Definition: DtOsgObserverObject.h:1357
double mySceneCenterOffsetZ
Definition: DtOsgObserverObject.h:1330
MotionState myRotatingState
Definition: DtOsgObserverObject.h:1306
const osg::Vec3d & euler() const
Definition: DtOsgObserverObject.h:1260
osg::Matrixd myLevelObserverMimicRotationMatrix
Definition: DtOsgObserverObject.h:1155
double myAltitude
Definition: DtOsgObserverObject.h:1435
osg::Quat myAttachedRotation
Definition: DtOsgObserverObject.h:1152
osg::Vec3d myLevelObserverMimicFront
Definition: DtOsgObserverObject.h:1380
osg::Vec3d mySavedObserverOffsetVector
Used for switching between track mode and other attached modes.
Definition: DtOsgObserverObject.h:1109
osg::Vec3d myMasterPositionVector
Definition: DtOsgObserverObject.h:1096
bool myExternalSuppressConstrainToTerrain
suppress when told to
Definition: DtOsgObserverObject.h:1404
float myFlashlightAngle
Definition: DtOsgObserverObject.h:1466
bool myHideModelOnAttach
Definition: DtOsgObserverObject.h:1393
DT_DLL_vrfutil double angle(double vec1[3], double vec2[3])
bool myMovedSinceLastHAT
Definition: DtOsgObserverObject.h:1465
bool myLocalModelScalingEnabled
Definition: DtOsgObserverObject.h:1102
bool moving() const
Definition: DtOsgObserverObject.h:1225
Contains makVrv::DtObserverObject class.
bool myChanged
Definition: DtOsgObserverObject.h:1087
void applyRotation(double angle)
Definition: DtOsgObserverObject.h:1250
int myPartAttachment
Definition: DtOsgObserverObject.h:1085
osg::Quat myFinalCameraRotation
This is the combined camera/observer orientation; this is what the DtOsgChannel uses to orient itself...
Definition: DtOsgObserverObject.h:1344
Direction
Definition: DtOsgObserverObject.h:1175
This abstract base class defines the interface for OS-specific keyboard and mouse event listeners...
Definition: DtObserverObject.h:29
MotionState myAttachedObserverState
Definition: DtOsgObserverObject.h:1303
static const double theMaxTerrainRetryTime
Definition: DtOsgObserverObject.h:1069
MotionState myRotatingLevelState
Definition: DtOsgObserverObject.h:1307
osg::Quat myMasterRotation
Definition: DtOsgObserverObject.h:1139
osg::Vec3d myLastSpeedPositionVector
Definition: DtOsgObserverObject.h:1095
boost::unordered_map< DtElementID, bool > ElementVisibilityMap
Definition: DtOsgObserverObject.h:1446
osg::Vec3d myLevelObserverUp
Definition: DtOsgObserverObject.h:1367
DtUniqueID myPendingTerrainPatchId
Definition: DtOsgObserverObject.h:1453
bool rotating() const
Definition: DtOsgObserverObject.h:1275
DtObserverObject::AttachType my3DAttachType
Definition: DtOsgObserverObject.h:1391
double myHeightAboveTerrainTimer
Definition: DtOsgObserverObject.h:1396
double mySceneCenterOffsetY
Definition: DtOsgObserverObject.h:1329
osg::Vec3d myFinalCameraPositionVector
This is the combined camera/observer orientation; this is what the DtOsgChannel uses to orient itself...
Definition: DtOsgObserverObject.h:1348
bool myConstrainToCenter
This variable is true when the bounding radius is too big The reset view will be from far away trying...
Definition: DtOsgObserverObject.h:1166
double myCurvatureAdjustment
Definition: DtOsgObserverObject.h:1464
double myNextGotoTerrainCenterTime
Definition: DtOsgObserverObject.h:1451
static const double theMinViewResolution
Definition: DtOsgObserverObject.h:1075
Angle
Definition: DtOsgObserverObject.h:1240
MotionState myAbsoluteRotatingState
Definition: DtOsgObserverObject.h:1308
osg::Vec3d myObserverRotationalVelocityVector
Definition: DtOsgObserverObject.h:1100
unsigned long long DtUniqueID
Definition: DtUniqueID.h:22
osg::Vec3d myPreviousTerrainCenter
Definition: DtOsgObserverObject.h:1454
bool myMutableHaveDownIntersect
Definition: DtOsgObserverObject.h:1423
bool myForceOrientReset
Definition: DtOsgObserverObject.h:1416
void stop()
Definition: DtOsgObserverObject.h:1208
bool myOrientCameraToTargetConstraint
Definition: DtOsgObserverObject.h:1411
osg::Vec3d myObserverFront
Definition: DtOsgObserverObject.h:1364
osg::Vec3d myObserverWorldNorth
Definition: DtOsgObserverObject.h:1356
MotionState myLevelObserverState
Definition: DtOsgObserverObject.h:1302
bool myLookingTiltRight
Definition: DtOsgObserverObject.h:1339
osg::Vec3d myObserverOffsetVector
Current offset from an attachment, when attached.
Definition: DtOsgObserverObject.h:1106
double myLastTickTime
Definition: DtOsgObserverObject.h:1088
osg::Vec3d myPreviousPositionVector
for backing out if we hit a constraint
Definition: DtOsgObserverObject.h:1432
void clearAdvance()
Definition: DtOsgObserverObject.h:1215
bool moving(Direction d) const
Definition: DtOsgObserverObject.h:1230
osg::Vec3d myEuler
Definition: DtOsgObserverObject.h:1296
osg::Quat myCameraShakeRot
Definition: DtOsgObserverObject.h:1468
osg::Quat myFlashlightRotation
Flashlight orientation offset as a quaternion.
Definition: DtOsgObserverObject.h:1142
osg::Vec3d myViewIntersect
Definition: DtOsgObserverObject.h:1421
osg::Vec3d myLevelObserverMimicRight
Definition: DtOsgObserverObject.h:1381
bool mySyncPending
Definition: DtOsgObserverObject.h:1097
osg::Vec3d myAdvance
This, when scaled, will provide the direction that the observer should move in as the result of tick-...
Definition: DtOsgObserverObject.h:1295
bool myLookingRight
-— Camera
Definition: DtOsgObserverObject.h:1335
osg::Vec3d myAttachedUp
Definition: DtOsgObserverObject.h:1371
DT_DLL_vrfutil double mag(double x[3])
osg::Vec3d myCameraOffset
This is the camera offset wrt to observer.
Definition: DtOsgObserverObject.h:1351
osg::Quat mySavedObserverRotation
This is used for switching between track mode and other attach modes.
Definition: DtOsgObserverObject.h:1145
A DtSceneObject represents an object that can be positioned in the scene by (possibly) attaching it t...
Definition: DtSceneObject.h:41
osg::Vec3d myLevelAttachedRight
Definition: DtOsgObserverObject.h:1377
double myRotationSpeed
Definition: DtOsgObserverObject.h:1320
double myLastAttachedBvolDiameter
Definition: DtOsgObserverObject.h:1428
bool mySyncSuppressed
Definition: DtOsgObserverObject.h:1098
void setMoving(Direction d, bool moving)
Definition: DtOsgObserverObject.h:1235
double myMinLinearSpeed
Definition: DtOsgObserverObject.h:1324
osg::Quat myObserverRotation
This is our ENU observer orientation as a quaternion.
Definition: DtOsgObserverObject.h:1138
Contains DLL export macros.
double myLastAttachBvolOffset
Definition: DtOsgObserverObject.h:1429
MotionState myObserverState
Definition: DtOsgObserverObject.h:1301
osg::Vec3d myObserverLinearVelocityVector
Definition: DtOsgObserverObject.h:1099
float myLocalModelScalingAmount
Definition: DtOsgObserverObject.h:1103
osg::Vec3d myAttachedWorldUp
Definition: DtOsgObserverObject.h:1359
bool stopped()
Definition: DtOsgObserverObject.h:1220
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
std::vector< DtUniqueID > mySecondaryAttachments
Definition: DtOsgObserverObject.h:1084
osg::Vec3d myAttachPosition
Definition: DtOsgObserverObject.h:1426
osg::Vec3d myOrientToPosition
Definition: DtOsgObserverObject.h:1124
bool myOrbitingRight
Definition: DtOsgObserverObject.h:1314
double myLastViewMagnification
Definition: DtOsgObserverObject.h:1444
osg::Vec3d myAttachedPosition
Definition: DtOsgObserverObject.h:1117
double myOrbitSpeed
Definition: DtOsgObserverObject.h:1318
static const double theMaxViewResolution
Definition: DtOsgObserverObject.h:1078
MotionState myLevelAttachedObserverState
Definition: DtOsgObserverObject.h:1304
bool myConstrainToTerrain
Definition: DtOsgObserverObject.h:1398
double myCurrentViewMagnification
Only used in 3D.
Definition: DtOsgObserverObject.h:1443
osg::Vec3d myObserverRight
Definition: DtOsgObserverObject.h:1365
bool myOrbiting
Definition: DtOsgObserverObject.h:1413
osg::Vec3d myCameraFront
Definition: DtOsgObserverObject.h:1388
bool myLookingDown
Definition: DtOsgObserverObject.h:1338
This abstract base class defines the interface for OS-specific keyboard and mouse event listeners...
Definition: DtOsgObserverObject.h:43
osg::Vec3d myLevelObserverPosition
Gravity change in observer position this frame.
Definition: DtOsgObserverObject.h:1115
double myCurrentObserverDistance
largest of the distances currently in play in a given frame.
Definition: DtOsgObserverObject.h:1132
double mySpeedScaleSpeed
Definition: DtOsgObserverObject.h:1326
static const double theObserverBoundingSphere
Definition: DtOsgObserverObject.h:1066
osg::Vec3d myAttachedRight
Definition: DtOsgObserverObject.h:1373
osg::Vec3d & euler()
Definition: DtOsgObserverObject.h:1265
AttachType
Definition: DtObserverObject.h:36
MotionState()
Definition: DtOsgObserverObject.h:1186

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)