VR-Forces 4.10 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) 2020 MAK Technologies, Inc.
3  * All rights reserved.
4  *****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
14 
16 
17 #include <boost/unordered_map.hpp>
18 
19 #include <osg/Matrixd>
20 #include <osg/Vec3d>
21 #include <osg/Vec3>
22 #include <osg/Node>
23 
24 #include <list>
25 
26 class DtTaitBryan;
27 
28 namespace osg
29 {
30  class Node;
31 }
32 
33 namespace makVrv
34 {
35  class DtChannel;
36  class DtOsgChannel;
37  class DtCoordinateConverter;
38  class DtSceneObject;
39  class DtTerrainPatchObject;
40  class DtAgentUpdateResolverInterface;
41 
46  {
47 
48  public:
49 
51  {
52  TerrainResultNoData = 0,
54  TerrainResultComplete
55  };
56 
58  DtOsgObserverObject( DtDe& de, DtUniqueID id, const std::string& name="" );
59 
61  virtual ~DtOsgObserverObject();
62 
64  virtual void tick( double simTime );
65 
67  virtual void tickAttachment();
68 
71  virtual void setModelSet( int modelSet );
72 
74  virtual double altitude() const;
75 
76  virtual void setNameAndRegister( const std::string& name );
77 
83  virtual void setCameraPositionAndOrientation( const osg::Vec3d& position,
84  const osg::Quat& rotation );
85 
86  virtual void getCameraPositionAndOrientation( osg::Vec3d& position,
87  osg::Quat& rotation ) const;
88 
89 
91  static void matrixdToTaitBryan( const osg::Matrixd& mat, DtTaitBryan& tb, bool isWorld2D = false );
92  static double clampUnity( double x );
93 
94 
95  //
96  //
98  //
99  //
100 
102  virtual void startMoveObserverRight();
105  virtual void stopMoveObserverRight();
106  virtual void moveObserverRight( double meters );
107 
109  virtual void startMoveObserverForward();
112  virtual void stopMoveObserverForward();
113  virtual void moveObserverForward( double meters );
115 
117  virtual void startMoveObserverUp();
120  virtual void stopMoveObserverUp();
121  virtual void moveObserverUp( double meters );
123 
125  virtual void startMoveObserverLeft();
128  virtual void stopMoveObserverLeft();
129  virtual void moveObserverLeft( double meters );
131 
133  virtual void startMoveObserverBack();
136  virtual void stopMoveObserverBack();
137  virtual void moveObserverBack( double meters );
139 
141  virtual void startMoveObserverDown();
144  virtual void stopMoveObserverDown();
145  virtual void moveObserverDown( double meters );
147 
149  virtual void startMoveLevelObserverRight();
153  virtual void stopMoveLevelObserverRight();
154  virtual void moveLevelObserverRight( double meters );
156 
158  virtual void startMoveLevelObserverForward();
162  virtual void stopMoveLevelObserverForward();
163  virtual void moveLevelObserverForward( double meters );
165 
167  virtual void startMoveLevelObserverUp();
171  virtual void stopMoveLevelObserverUp();
172  virtual void moveLevelObserverUp( double meters );
174 
176  virtual void startMoveLevelObserverLeft();
180  virtual void stopMoveLevelObserverLeft();
181  virtual void moveLevelObserverLeft( double meters );
183 
185  virtual void startMoveLevelObserverBack();
189  virtual void stopMoveLevelObserverBack();
190  virtual void moveLevelObserverBack( double meters );
192 
194  virtual void startMoveLevelObserverDown();
197  virtual void stopMoveLevelObserverDown();
198  virtual void moveLevelObserverDown( double meters );
200 
202  virtual void startMoveAttachedRight();
205  virtual void stopMoveAttachedRight();
206  virtual void moveAttachedRight( double meters );
207 
209  virtual void startMoveAttachedForward();
212  virtual void stopMoveAttachedForward();
213  virtual void moveAttachedForward( double meters );
215 
217  virtual void startMoveAttachedUp();
220  virtual void stopMoveAttachedUp();
221  virtual void moveAttachedUp( double meters );
223 
225  virtual void startMoveAttachedLeft();
228  virtual void stopMoveAttachedLeft();
229  virtual void moveAttachedLeft( double meters );
231 
233  virtual void startMoveAttachedBack();
236  virtual void stopMoveAttachedBack();
237  virtual void moveAttachedBack( double meters );
239 
241  virtual void startMoveAttachedDown();
244  virtual void stopMoveAttachedDown();
245  virtual void moveAttachedDown( double meters );
247 
249  virtual void startMoveLevelAttachedRight();
253  virtual void stopMoveLevelAttachedRight();
254  virtual void moveLevelAttachedRight( double meters );
256 
258  virtual void startMoveLevelAttachedForward();
262  virtual void stopMoveLevelAttachedForward();
263  virtual void moveLevelAttachedForward( double meters );
265 
267  virtual void startMoveLevelAttachedUp();
271  virtual void stopMoveLevelAttachedUp();
272  virtual void moveLevelAttachedUp( double meters );
274 
276  virtual void startMoveLevelAttachedLeft();
280  virtual void stopMoveLevelAttachedLeft();
281  virtual void moveLevelAttachedLeft( double meters );
283 
285  virtual void startMoveLevelAttachedBack();
289  virtual void stopMoveLevelAttachedBack();
290  virtual void moveLevelAttachedBack( double meters );
292 
294  virtual void startMoveLevelAttachedDown();
297  virtual void stopMoveLevelAttachedDown();
298  virtual void moveLevelAttachedDown( double meters );
300 
302  virtual void startMoveAttachedContextRight();
305  virtual void stopMoveAttachedContextRight();
306  virtual void moveAttachedContextRight( double meters );
308 
310  virtual void startMoveAttachedContextForward();
313  virtual void stopMoveAttachedContextForward();
314  virtual void moveAttachedContextForward( double meters );
316 
318  virtual void startMoveAttachedContextUp();
321  virtual void stopMoveAttachedContextUp();
322  virtual void moveAttachedContextUp( double meters );
324 
326  virtual void startMoveAttachedContextLeft();
329  virtual void stopMoveAttachedContextLeft();
330  virtual void moveAttachedContextLeft( double meters );
332 
334  virtual void startMoveAttachedContextBack();
337  virtual void stopMoveAttachedContextBack();
338  virtual void moveAttachedContextBack( double meters );
340 
342  virtual void startMoveAttachedContextDown();
344  virtual void stopMoveAttachedContextDown();
345  virtual void moveAttachedContextDown( double meters );
347 
349  virtual void startYawLeft();
352  virtual void stopYawLeft();
353  virtual void rotateYawLeft(double rads);
355 
357  virtual void startYawRight();
361  virtual void stopYawRight();
362  virtual void rotateYawRight(double rads);
364 
366  virtual void startPitchUp();
369  virtual void stopPitchUp();
370  virtual void rotatePitchUp( double rads );
371  virtual void rotateFlashlightPitchUp( double rads );
373 
375  virtual void startPitchDown();
378  virtual void stopPitchDown();
379  virtual void rotatePitchDown( double rads );
380  virtual void rotateFlashlightPitchDown( double rads );
382 
384  virtual void startRollLeft();
387  virtual void stopRollLeft();
388  virtual void rollLeft(double rads);
390 
392  virtual void startRollRight();
395  virtual void stopRollRight();
396  virtual void rollRight(double rads);
398 
400  virtual void startLevelYawLeft();
403  virtual void stopLevelYawLeft();
405 
407  virtual void startLevelYawRight();
411  virtual void stopLevelYawRight();
413 
415  virtual void startLevelPitchUp();
418  virtual void stopLevelPitchUp();
419  virtual void rotateLevelPitchUp(double rads);
421 
423  virtual void startLevelPitchDown();
426  virtual void stopLevelPitchDown();
427  virtual void rotateLevelPitchDown(double rads);
429 
431  virtual void startLevelRollLeft();
434  virtual void stopLevelRollLeft();
435  virtual void rollLevelLeft(double rads);
437 
439  virtual void startLevelRollRight();
442  virtual void stopLevelRollRight();
443  virtual void rollLevelRight(double rads);
445 
446  virtual void rotateLevelYawLeft( double rads );
447  virtual void rotateLevelYawRight( double rads );
448  virtual void rotateFlashlightYawLeft( double rads );
449  virtual void rotateFlashlightYawRight( double rads );
450 
451  virtual void startLookLeft();
452  virtual void stopLookLeft();
453  virtual void lookLeft( double rads );
454 
455  virtual void startLookRight();
456  virtual void stopLookRight();
457  virtual void lookRight( double rads );
458 
459  virtual void startLookUp();
460  virtual void stopLookUp();
461  virtual void lookUp( double rads );
462 
463  virtual void startLookDown();
464  virtual void stopLookDown();
465  virtual void lookDown( double rads );
466 
467  virtual void startLookTiltRight();
468  virtual void stopLookTiltRight();
469  virtual void lookTiltRight( double rads );
470 
471  virtual void startLookTiltLeft();
472  virtual void stopLookTiltLeft();
473  virtual void lookTiltLeft( double rads );
474 
476  virtual void startOrbitingLeft();
479  virtual void stopOrbitingLeft();
480  virtual void orbitLeft( double rads );
482 
484  virtual void startOrbitingRight();
487  virtual void stopOrbitingRight();
488  virtual void orbitRight( double rads );
490 
492  virtual void startOrbitingUp();
495  virtual void stopOrbitingUp();
496  virtual void orbitUp( double rads );
498 
500  virtual void startOrbitingDown();
503  virtual void stopOrbitingDown();
504  virtual void orbitDown( double rads );
506 
508  virtual void setLocation( double x, double y, double z);
509 
513  virtual void setAttachedLocation( double x, double y, double z );
514 
516  virtual void setOrientation( double psi, double theta, double phi );
517 
519  virtual void setTopographicOrientation( double psi, double theta, double phi );
520 
522  virtual void setOrientation( double x, double y, double z, double w);
523 
525  virtual void setAttachedOrientation( double psi, double theta, double phi ) override;
526  virtual void setAttachedYaw(double psi) override;
527  virtual void setAttachedPitch(double theta) override;
528  virtual void setAttachedRoll(double phi) override;
529  virtual void getAttachedOrientation(double& psi, double& theta, double& phi) const override;
530 
532  virtual void setAttachedOrientation( double x, double y, double z,
533  double w);
534 
537  void setLocalModelScalingEnabled( bool enabled );
538 
541  void setLocalModelScalingAmount( float amount );
542 
545  virtual void jumpTo( double x, double y, double z );
546 
548  virtual void jumpTo( DtUniqueID elementID );
549 
550  virtual void orientTo( double x, double y, double z );
551 
553  virtual void dragTerrain( double lastX, double lastY, double lastZ,
554  double currX, double currY, double currZ );
555 
556  virtual void dragTerrain2( double myStartDragX, double myStartDragY,
557  double myStartDragZ, int deltaMouseX, int deltaMouseY );
558 
559  virtual void dragGravityUp( double windowUnits );
560  virtual void dragGravityDown( double windowUnits );
561  virtual void dragGravityLeft( double windowUnits );
562  virtual void dragGravityRight( double windowUnits );
563  virtual void scrollObserverForward( int wheelUnits );
564  virtual void scrollObserverBack( int wheelUnits );
565  virtual void scrollLevelObserverForward( int wheelUnits );
566  virtual void scrollLevelObserverBack( int wheelUnits );
567 
568  virtual void scrollFlashlightWider( int wheelUnits );
569  virtual void scrollFlashlightNarrower( int wheelUnits );
570 
572  virtual float flashlightAngle();
573 
574  //{@
576  virtual void startIncreasingViewResolution();
577  virtual void stopIncreasingViewResolution();
578  virtual void increaseViewResolution();
579 
580  virtual void startDecreasingViewResolution();
581  virtual void stopDecreasingViewResolution();
582  virtual void decreaseViewResolution();
583 
584  // Sets the view resolution in meters per pixel.
585  virtual void setViewResolution( double resolution);
586 
587  // Get the current view resolution.
588  virtual double viewResolution() const;
589 
595  virtual void setCurrentViewMagnification( double mag );
596 
598  virtual double currentViewMagnification() const;
599 
601 
602  //
604  //
605 
607  virtual void setOrbitSpeed( double speed );
608 
610  virtual void setLinearSpeed( double speed );
611 
613  virtual void setRotationSpeed( double speed );
614 
616  virtual void setMinLinearSpeed( double minSpeed );
617 
619  virtual void setMaxLinearSpeed( double maxSpeed );
620 
622  virtual void setLinearScaledSpeedGain( double gain );
623 
629  virtual void gotoTerrainCenter( DtUniqueID terrainPatch, bool retry );
630 
632  virtual void resetAttachment();
633 
634  virtual void resetOrientation();
635 
637  virtual void resetCamera();
638  virtual void level();
639 
640  virtual void stopAll();
641 
642  virtual void attachToObjects( const std::vector<DtUniqueID>& elementIds );
643  virtual void setSecondaryAttachment( const std::vector<DtUniqueID>& elementIds );
644  virtual void setLocationTrackAttachment( const osg::Vec3d& location );
645  virtual void setLocationTrackAttachment( double x, double y, double z );
646 
647  virtual void attachToPart( int partId);
648  virtual void detach();
649  virtual void setAttachType( DtObserverObject::AttachType type );
650  virtual void setHideModelOnAttach( bool hide );
651 
655  virtual void setAttachmentHas3DCockpit( bool cockpit );
656 
657  virtual void scaleCurrentAttachments( bool scaled );
658  virtual void setOrientToTargetConstraint( bool orient );
659  virtual void setOrbiting( bool orbit );
660  virtual void setOrientCameraToTargetConstraint( bool orient );
661 
662  virtual void setConstrainToTerrain( bool trueFalse );
663  virtual void setConstrainToCenter( bool trueFalse );
664 
667  virtual void suppressConstrainToTerrain( bool trueFalse );
668 
669  virtual void setSpeedScaling( bool trueFalse );
670 
672  virtual void setSpeedScaledSpeed( double speed );
673 
675  virtual void getLocation(double &x, double &y, double& z) const;
677  virtual void getObserverPosition(double &x, double &y, double& z) const;
678  virtual void getEffectiveLocation(double &x, double &y, double& z) const;
680 
682  virtual void getObserverCameraPosition(double& x, double& y, double& z) const;
683 
685  virtual void getOrientation( double& psi, double& theta, double& phi ) const;
686 
689  virtual void getObserverCameraOrientation(double& psi, double& theta, double& phi, bool includeShake) const;
690 
692  virtual void getTopographicOrientation( double& psi, double& theta, double& phi ) const;
693 
694  virtual void getOrientation( double& x, double& y, double& z, double& w ) const;
695 
696  virtual void getFlashlightOrientation( double& x, double& y, double& z, double& w ) const;
697 
700  virtual void getObserverPlatformFront(double& x, double& y, double& z) const;
701 
704  virtual void getObserverPlatformUp(double& x, double& y, double& z) const;
705 
708  virtual void getObserverPlatformRight(double& x, double& y, double& z) const;
709 
712  virtual void getObserverCameraFront(double& x, double& y, double& z, bool includeShake) const;
713 
715  virtual void getObserverCameraUp(double& x, double& y, double& z, bool includeShake) const;
716 
718  virtual void getObserverCameraRight(double& x, double& y, double& z, bool includeShake) const;
719 
720  virtual void getCameraUp(double& x, double& y, double& z);
721 
722  virtual void getCameraFront(double& x, double& y, double& z);
723 
724  virtual void getCameraRight(double& x, double& y, double& z);
725 
727  virtual void setCameraShakeRotation(double x, double y, double z, double w);
728 
730  virtual void getCameraShakeRotation(double& x, double& y, double& z, double& w);;
731 
734 // virtual double calculate2DAltitude();
735 
736 
739  virtual double heightAboveTerrainFromCurrentZoom(double magnification = 1.) const;
740 
744  virtual double altitudeFromCurrentZoom(double magnification=1.) const;
745 
748  virtual double zoomFromHeightAboveTerrain(double hat, double magnification=1) const;
749 
752  virtual double zoomFromAltitude(double altitude, double magnification=1.) const;
753 
754 
758  virtual double zoomFromCurrentAltitude() const;
759 
762  virtual double topographicHeading() const;
763 
765  virtual void getLinearVelocity(double &x, double &y, double &z) const;
766 
768  virtual void getRotationalVelocity( double& x, double& y, double& z) const;
769 
773  virtual void setModeSetting( int setting, bool value );
774 
777  virtual void setNorthType(DtObserverObject::NorthType northType);
778 
780  virtual std::vector<DtUniqueID> currentAttachments() const;
781 
784 
785  virtual const osg::Vec3d& locationTrackAttachmentVec3d() const;
786  virtual void getLocationTrackAttachment( double& x, double& y, double& z ) const;
788 
792  virtual DtObserverObject::AttachType attachType3D() const;
793 
797  virtual DtObserverObject::AttachType attachType2D() const;
798 
800  virtual bool attachedObjectHidden() const;
801 
805  virtual bool attachmentHas3DCockpit() const;
806 
809  virtual osg::Vec3d attachedOffsetVector() const;
810 
815  virtual double attachedNearClipOffset() const;
816 
818  virtual double heightAboveTerrain() const;
819 
821  virtual double heightOfTerrain() const;
822  private:
823 
826 
828  DtOsgObserverObject& operator=( const DtOsgObserverObject& );
829 
830  protected:
831 
833  virtual bool shouldOrientToGlobeCenter();
834 
836  virtual void adjustToGlobeCurvature();
837 
839  virtual bool shouldRotateGlobe();
840 
841  virtual void calcObserverWorldVectors();
842  virtual const osg::Vec3d& observerWorldUp() const;
843  virtual const osg::Vec3d& observerWorldNorth() const;
844  virtual const osg::Vec3d& observerWorldEast() const;
845 
846  virtual const osg::Vec3d& attachedWorldUp() const;
847 
848  virtual osg::Vec3d& observerUp();
849  virtual osg::Vec3d& observerFront();
850  virtual osg::Vec3d& observerRight();
851  virtual void observerBasis(osg::Vec3d& up, osg::Vec3d& front, osg::Vec3d& right);
852 
853  virtual osg::Vec3d& attachedUp();
854  virtual osg::Vec3d& attachedFront();
855  virtual osg::Vec3d& attachedRight();
856 
857  virtual osg::Vec3d& attachedOffsetUp();
858  virtual osg::Vec3d& attachedOffsetFront();
859  virtual osg::Vec3d& attachedOffsetRight();
860 
862  virtual osg::Vec3d& levelAttachedUp();
863  virtual osg::Vec3d& levelAttachedFront();
864  virtual osg::Vec3d& levelAttachedRight();
865 
867  virtual osg::Vec3d& levelObserverMimicUp();
868  virtual osg::Vec3d& levelObserverMimicFront();
869  virtual osg::Vec3d& levelObserverMimicRight();
870 
871  virtual osg::Vec3d& cameraUp();
872  virtual osg::Vec3d& cameraFront();
873  virtual osg::Vec3d& cameraRight();
874 
875  virtual osg::Vec3d& levelObserverUp();
876  virtual osg::Vec3d& levelObserverFront();
877  virtual osg::Vec3d& levelObserverRight();
878 
879  virtual void advanceOrbitLeft( double rads );
880  virtual void advanceOrbitRight( double rads );
881  virtual void advanceOrbitUp( double rads );
882  virtual void advanceOrbitDown( double rads );
883 
884  virtual void makeLevelObserverMatrix();
885 
887  virtual void calculateLevelAttachedRotation();
888 
890  virtual void makeLevelObserverMimicMatrix();
891 
895  virtual osg::Vec3d calcWorldPositionChange();
896 
897  virtual osg::Vec3d calcMimicPositionChange();
898 
899  virtual osg::Vec3d calcAttachedPosition(const osg::Quat& attInverse, const osg::Vec3d& attachedAdvance);
900  virtual osg::Vec3d calcAttachedAdvance(const osg::Quat& tetherTrackInverse);
901 
902  virtual osg::Vec3d calcFollowPositionChange();
903  virtual osg::Vec3d calcSpaceFollowPositionChange();
904  virtual osg::Vec3d calcTetherPositionChange();
905  virtual osg::Vec3d calcTetherTrackPositionChange();
906 
907  virtual osg::Vec3d calcTrackPositionChange();
908  virtual osg::Quat calcTetherTrackRotation();
909 
910  virtual osg::Quat calcFlashlightOrientationChange();
911  virtual osg::Quat calcWorldOrientationChange();
912  virtual osg::Quat calcTetherOrientationChange();
913  virtual osg::Quat calcMimicOrientationChange();
914  virtual osg::Quat calcFollowOrientationChange();
915 
916  virtual void setCurrentAttachmentsVisibility( bool visible );
917 
924 
927  virtual void orientTo( const osg::Vec3d& target );
928 
930  virtual void orientCameraTo( const osg::Vec3d& target );
931 
932  virtual TerrainResult getTerrainCenter( const DtUniqueID& patchID, osg::Vec3d& center );
933 
934  virtual DtCoordinateConverter& coordinateConverter();
935  virtual const DtCoordinateConverter& coordinateConverter() const;
936 
937  virtual void initializeAttachment();
938 
939  virtual const osg::Vec3d& scalingIntersection() const;
940  virtual void getViewIntersection();
941 
943  virtual double linearSpeed();
944 
946  virtual double speedScalingGain() const;
947 
948  virtual void calcTerrainConstraint(const osg::Vec3d& prev );
949 
955  virtual bool updateAttachPositionAndOrientation();
956 
957  virtual bool getSecondaryAttachPosition( osg::Vec3d& position );
958 
959  virtual void getObserverOffsetVector( double& x, double& y, double& z ) const;
960  virtual void setObserverOffsetVector( double x, double y, double z );
961 
964 
965  virtual void getCameraFromParentOffsetVector( double& x, double& y, double& z ) const;
966  virtual void getCameraFromParentRotationOffset( double& x, double& y, double& z, double& w ) const;
968 
969  virtual void getAttachedRotationOffset( double& x, double& y, double& z, double& w ) const;
970  virtual void setAttachedRotationOffset( double x, double y, double z,
971  double w );
972 
973  virtual void getBoundingVolume( DtSceneObject& sceneObject,
974  osg::Vec3& bvolExtents, osg::Vec3d& bvolCenter );
975 
976  virtual void getBoundingVolume( DtTerrainPatchObject& patchObject,
977  osg::Vec3& bvolExtents, osg::Vec3d& bvolCenter );
978 
979  virtual void setLocation( const osg::Vec3d& location, bool suppress=true );
980 
981  virtual bool isMoving() const;
982  virtual bool isRotating() const;
983 
984  virtual double computeNearClipDistance( DtSceneObject* sceneObject );
985  virtual float computeLocalModelScalingAmount( DtSceneObject* sceneObject );
986 
987  virtual void calcScaledSpeed();
988  virtual bool getTerrainOrPropIntersection( const osg::Vec3d& startPos,
989  const osg::Vec3d& endPos, osg::Vec3d& result, const osg::Node::NodeMask mask = ~DtOsgNodeFlags::FlagSupportOff) const;
990 
992  virtual DtSceneObject* findSceneObjectFromElement(const DtElementID& id);
993 
995  virtual DtTerrainPatchObject* findTerrainPatchObjectFromElement( DtElementID id );
996  virtual DtOsgObserverObject* findObserverObjectFromElement( DtElementID id );
997 
998  virtual void getPositionAndOrientation( DtSceneObject& sceneObject, osg::Vec3d& position,
999  osg::Vec3d& orientToPosition, osg::Quat& orientation );
1000 
1001  virtual void getPositionAndOrientation( DtTerrainPatchObject& patchObject, osg::Vec3d& position,
1002  osg::Vec3d& orientToPosition, osg::Quat& orientation );
1003 
1004  virtual void getPositionAndOrientation( DtOsgObserverObject& observerObject, osg::Vec3d& position,
1005  osg::Vec3d& orientToPosition, osg::Quat& orientation );
1006 
1008  virtual void getPositionFromSceneObject( DtSceneObject& sceneObject, osg::Vec3d& position ) const;
1009 
1011  virtual void getPositionFromObserverObject( DtOsgObserverObject& observerObject, osg::Vec3d& position ) const;
1012 
1015  virtual bool getPartPositionOriFromSceneObject( DtSceneObject& sceneObject,
1016  int partId, osg::Vec3d& position, osg::Quat& ori ) const;
1017 
1020  virtual void force2D();
1021 
1023  virtual void dimensionChanged( bool is2D );
1024  virtual void setIs2D( bool is2D );
1025 
1027  virtual double calculate3DAltitude() const;
1028 
1030  virtual void calculateAltitude();
1031 
1032  // Sends the location of the observer on the master to all others; only used
1033  // if different
1034  virtual void synchronizeLocation( double x, double y, double z );
1035 
1036  // Sends the orientation of the observer on the master to all others; only used
1037  // if different
1038  virtual void synchronizeOrientation( double x, double y, double z, double w );
1039 
1055  virtual void calcHeightAboveTerrain(bool force=false);
1056 
1058  std::list<DtChannel*> findChannels();
1061  std::list<const DtChannel*> findChannels() const;
1063 
1072  double frustumPixelHeight() const;
1073 
1074  protected:
1075 
1076  static const double theObserverBoundingSphere;
1078 
1079  static const double theMaxTerrainRetryTime;
1080 
1081  // below this altitude, ignore myConstrainToCenter
1082  static const double theCenterConstrainHeight;
1083 
1084  // Zoom won't get any smaller than this
1085  static const double theMinViewResolution;
1086 
1087  // Zoom won't get any larger than this
1088  static const double theMaxViewResolution;
1089 
1090 
1091  protected:
1092 
1093  std::vector<DtUniqueID> myCurrentAttachments;
1094  std::vector<DtUniqueID> mySecondaryAttachments;
1096 
1099 
1100  //
1102  //
1111 
1114 
1117 
1120 
1123 
1126 
1128 
1130 
1132  osg::Vec3d myDragMove;
1133 
1135 
1136  osg::Vec3d myOrbitAdvance;
1137 
1143 
1146 
1149  osg::Quat myMasterRotation;
1150 
1153 
1156 
1161 
1164 
1167 
1170 
1174 
1175  //bool myGlobeObserverMode;
1177 
1180 
1182  {
1183  public:
1184 
1186  {
1187  Stopped = 0,
1188  Forward = 1,
1189  Backward = 2,
1190  Left = 4,
1191  Right = 8,
1192  Up = 16,
1193  Down = 32
1194  };
1195 
1197  : myState(Stopped)
1198  {
1199  }
1200 
1202  inline void applyMovement(double linearDistance)
1203  {
1204  if(moving(Right)) myAdvance[0] += linearDistance;
1205  if(moving(Left)) myAdvance[0] -= linearDistance;
1206  if(moving(Forward)) myAdvance[1] += linearDistance;
1207  if(moving(Backward)) myAdvance[1] -= linearDistance;
1208  if(moving(Up)) myAdvance[2] += linearDistance;
1209  if(moving(Down)) myAdvance[2] -= linearDistance;
1210  }
1211 
1213  inline const osg::Vec3d& advance() const
1214  {
1215  return myAdvance;
1216  }
1217 
1218  inline void stop()
1219  {
1220  myState = Stopped;
1221  myAdvance.set(0.0,0.0,0.0);
1222  myEuler.set(0.0,0.0,0.0);
1223  }
1224 
1225  inline void clearAdvance()
1226  {
1227  myAdvance.set(0.0,0.0,0.0);
1228  }
1229 
1230  inline bool stopped()
1231  {
1232  return myState == Stopped;
1233  }
1234 
1235  inline bool moving() const
1236  {
1237  return myState != Stopped;
1238  }
1239 
1240  inline bool moving(Direction d) const
1241  {
1242  return (myState & d) != 0;
1243  }
1244 
1245  inline void setMoving(Direction d, bool moving)
1246  {
1247  myState = moving ? myState | d : myState & ~d;
1248  }
1249 
1250  enum Angle
1251  {
1252  YawLeft = 1,
1253  YawRight = 2,
1254  PitchUp = 4,
1255  PitchDown = 8,
1256  RollLeft = 16,
1257  RollRight = 32
1258  };
1259 
1260  inline void applyRotation(double angle)
1261  {
1262  if(rotating(YawRight)) myEuler[0] -= angle;
1263  if(rotating(YawLeft)) myEuler[0] += angle;
1264  if(rotating(PitchUp)) myEuler[1] += angle;
1265  if(rotating(PitchDown)) myEuler[1] -= angle;
1266  if(rotating(RollRight)) myEuler[2] += angle;
1267  if(rotating(RollLeft)) myEuler[2] -= angle;
1268  }
1269 
1270  inline const osg::Vec3d& euler() const
1271  {
1272  return myEuler;
1273  }
1274 
1275  inline osg::Vec3d& euler()
1276  {
1277  return myEuler;
1278  }
1279 
1280  inline void level()
1281  {
1282  myEuler.set(0.0,0.0,0.0);
1283  }
1284 
1285  inline bool rotating() const
1286  {
1287  return myState != Stopped;
1288  }
1289 
1290  inline bool rotating( Angle d ) const
1291  {
1292  return (myState & d) != 0;
1293  }
1294 
1295  inline void setRotating( Angle d, bool rotating )
1296  {
1297  myState = rotating ? myState | d : myState & ~d;
1298  }
1299 
1300  protected:
1301 
1305  osg::Vec3d myAdvance;
1306  osg::Vec3d myEuler;
1307 
1308  unsigned char myState;
1309  };
1310 
1315 
1320 
1322 
1327 
1331 
1337 
1341 
1342  //
1351 
1355 
1359 
1361  osg::Vec3d myCameraOffset;
1363  osg::Quat myCameraRotation;
1364 
1365  osg::Vec3d myObserverWorldUp;
1368 
1369  osg::Vec3d myAttachedWorldUp;
1372 
1373  osg::Vec3d myObserverUp;
1374  osg::Vec3d myObserverFront;
1375  osg::Vec3d myObserverRight;
1376 
1377  osg::Vec3d myLevelObserverUp;
1380 
1381  osg::Vec3d myAttachedUp;
1382  osg::Vec3d myAttachedFront;
1383  osg::Vec3d myAttachedRight;
1384 
1385  osg::Vec3d myLevelAttachedUp;
1388 
1392 
1396 
1397  osg::Vec3d myCameraUp;
1398  osg::Vec3d myCameraFront;
1399  osg::Vec3d myCameraRight;
1400 
1402 
1407 
1409 
1412 
1415 
1424  // force an orientation reset AFTER the next time the observer position is updated
1425  // Needed when making large attach jumps
1427 
1429 
1431  osg::Vec3d myViewIntersect;
1432 
1434  mutable osg::Vec3d myMutableDownIntersect;
1435 
1436  osg::Vec3d myAttachPosition;
1437 
1440 
1444 
1445  double myAltitude;
1446 
1451 
1455 
1456  typedef boost::unordered_map<DtElementID, bool> ElementVisibilityMap;
1458 
1459  // Paged terrain initialization
1467 
1468  // Used for speed scaling, this is the same as myHeightAboveTerrain
1469  // when unattached, but the distance from the attached entity when
1470  // attached
1472 
1473  // curvature adjustment
1477 
1478  osg::Quat myCameraShakeRot;
1479 
1481  };
1482 
1483 }
osg::Quat myCameraRotation
This is the camera (wrt the observer) as a quaternion.
Definition: DtOsgObserverObject.h:1363
osg::Vec3d myDragMove
Change in world position due to drag.
Definition: DtOsgObserverObject.h:1132
osg::Vec3d myMutableDownIntersect
Definition: DtOsgObserverObject.h:1434
Definition: DtOsgObserverObject.h:53
bool myHaveViewIntersect
Definition: DtOsgObserverObject.h:1430
void setRotating(Angle d, bool rotating)
Definition: DtOsgObserverObject.h:1295
ElementVisibilityMap myPendingVisibilityState
Definition: DtOsgObserverObject.h:1457
bool myAttachmentHas3DCockpit
Definition: DtOsgObserverObject.h:1404
osg::Vec3d myLevelObserverMimicUp
Definition: DtOsgObserverObject.h:1389
osg::Vec3d myAttachedWorldEast
Definition: DtOsgObserverObject.h:1371
int myOrientToTargetConstraint
This is an int rather than a bool because we increment/decrement it, much like a reference pointer...
Definition: DtOsgObserverObject.h:1420
osg::Vec3d myObserverUp
Definition: DtOsgObserverObject.h:1373
double myHeightOfTerrain
Definition: DtOsgObserverObject.h:1466
std::vector< DtUniqueID > myCurrentAttachments
Definition: DtOsgObserverObject.h:1093
double myStartGotoTerrainCenterTime
Definition: DtOsgObserverObject.h:1462
static const unsigned int FlagSupportOff
Is this node part of support (whether or not other scene objects can ground clamp to this model) ...
Definition: DtOsgNodeTraversalFlags.h:22
osg::Quat my2DTo3DCachedRotation
Definition: DtOsgObserverObject.h:1169
osg::Quat myLevelAttachedRotation
Definition: DtOsgObserverObject.h:1163
osg::Vec3d myAttachedOffsetUp
Definition: DtOsgObserverObject.h:1393
osg::Vec3d myAttachedOffsetRight
Definition: DtOsgObserverObject.h:1395
osg::Vec3d myOrbitAdvance
Definition: DtOsgObserverObject.h:1136
DtCoordinateConverter is the base class for &#39;local (cig) to geocentric&#39; converters.
Definition: DtCoordinateConverter.h:25
osg::Vec3d myCameraRight
Definition: DtOsgObserverObject.h:1399
osg::Vec3d myCameraUp
Definition: DtOsgObserverObject.h:1397
double myHeightAboveTerrain
Definition: DtOsgObserverObject.h:1465
double myMaxLinearSpeed
Need just these, for terrain scaling.
Definition: DtOsgObserverObject.h:1333
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
double myLinearSpeed
Definition: DtOsgObserverObject.h:1329
This form is used for doing level (&#39;flying carpet&#39;) style movements.
Definition: DtOsgObserverObject.h:1181
osg::Vec3d myLevelAttachedFront
Definition: DtOsgObserverObject.h:1386
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:1323
osg::Vec3d myObserverPosition
Change in observer position this frame.
Definition: DtOsgObserverObject.h:1122
Contains makVrv:DtOsgNodeTraversalFlags class.
MotionState myFlashlightRotatingState
Definition: DtOsgObserverObject.h:1321
osg::Vec3d myLocationAttachPoint
Definition: DtOsgObserverObject.h:1480
osg::Vec3d my2DTo3DCachedObserverOffsetVector
Definition: DtOsgObserverObject.h:1168
osg::Vec3d myLevelAttachedPosition
Definition: DtOsgObserverObject.h:1129
double mySceneCenterOffsetX
Definition: DtOsgObserverObject.h:1338
void level()
Definition: DtOsgObserverObject.h:1280
bool mySpeedScaling
Definition: DtOsgObserverObject.h:1405
bool myViewResolutionDecreasingState
Definition: DtOsgObserverObject.h:1449
osg::Vec3d myLevelObserverFront
Definition: DtOsgObserverObject.h:1378
double myViewResolution
Definition: DtOsgObserverObject.h:1450
bool myLookingUp
Definition: DtOsgObserverObject.h:1347
osg::Vec3d myAttachedOffsetFront
Definition: DtOsgObserverObject.h:1394
osg::Matrixd myLevelObserverRotationMatrix
Definition: DtOsgObserverObject.h:1166
bool myOrbitingUp
Definition: DtOsgObserverObject.h:1325
static const double theCenterConstrainHeight
Definition: DtOsgObserverObject.h:1082
void applyMovement(double linearDistance)
Update the advance based upon the movement.
Definition: DtOsgObserverObject.h:1202
TerrainResult
Definition: DtOsgObserverObject.h:50
bool myOrbitingDown
Definition: DtOsgObserverObject.h:1326
bool myInternalSuppressConstrainToTerrain
suppress when jumping...
Definition: DtOsgObserverObject.h:1411
osg::Vec3d myObserverWorldUp
Definition: DtOsgObserverObject.h:1365
bool rotating(Angle d) const
Definition: DtOsgObserverObject.h:1290
osg::Vec3d myAttachedWorldNorth
Definition: DtOsgObserverObject.h:1370
osg::Vec3d myLevelObserverRight
Definition: DtOsgObserverObject.h:1379
bool myHaveTerrainPivot
Definition: DtOsgObserverObject.h:1428
const osg::Vec3d & advance() const
Get the current movement advance.
Definition: DtOsgObserverObject.h:1213
osg::Vec3d myAttachedFront
Definition: DtOsgObserverObject.h:1382
osg::Vec3d myLevelAttachedUp
Definition: DtOsgObserverObject.h:1385
osg::Quat myAttachedRotationOffset
My Attached rotation offset.
Definition: DtOsgObserverObject.h:1145
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:1160
DtUniqueID DtElementID
The ElementID is a specific type of unique ID used to represent VR-Vantage uniquely defined elements...
Definition: DtUniqueID.h:23
double mySpeedScaleHeightEquivalent
Definition: DtOsgObserverObject.h:1471
MotionState myAbsoluteLevelRotatingState
Definition: DtOsgObserverObject.h:1319
unsigned char myState
Definition: DtOsgObserverObject.h:1308
bool myLookingTiltLeft
Definition: DtOsgObserverObject.h:1350
double myLinearScaledSpeedGain
Definition: DtOsgObserverObject.h:1335
osg::Vec3d myObserverPositionVector
— Observer
Definition: DtOsgObserverObject.h:1104
bool myLookingLeft
Definition: DtOsgObserverObject.h:1346
osg::Vec3d myPreviousOffsetVector
Definition: DtOsgObserverObject.h:1443
bool myGotoTerrainCenterPending
Definition: DtOsgObserverObject.h:1460
A DtTerrainPatchObject contains the methods for loading a file as a terrain.
Definition: DtTerrainPatchObject.h:37
static const double theHeightAboveTerrainUpdatePeriod
Definition: DtOsgObserverObject.h:1077
bool myOrientToOnReset
Definition: DtOsgObserverObject.h:1422
bool myViewResolutionIncreasingState
note, this is only calculated if myConstrainToCenter is true
Definition: DtOsgObserverObject.h:1448
osg::Vec3d myObserverWorldEast
Definition: DtOsgObserverObject.h:1367
double mySceneCenterOffsetZ
Definition: DtOsgObserverObject.h:1340
MotionState myRotatingState
Definition: DtOsgObserverObject.h:1316
const osg::Vec3d & euler() const
Definition: DtOsgObserverObject.h:1270
osg::Matrixd myLevelObserverMimicRotationMatrix
Definition: DtOsgObserverObject.h:1165
double myAltitude
Definition: DtOsgObserverObject.h:1445
osg::Quat myAttachedRotation
Definition: DtOsgObserverObject.h:1162
osg::Vec3d myLevelObserverMimicFront
Definition: DtOsgObserverObject.h:1390
osg::Vec3d mySavedObserverOffsetVector
Used for switching between track mode and other attached modes.
Definition: DtOsgObserverObject.h:1119
osg::Vec3d myMasterPositionVector
Definition: DtOsgObserverObject.h:1106
bool myExternalSuppressConstrainToTerrain
suppress when told to
Definition: DtOsgObserverObject.h:1414
float myFlashlightAngle
Definition: DtOsgObserverObject.h:1476
bool myHideModelOnAttach
Definition: DtOsgObserverObject.h:1403
DT_DLL_vrfutil double angle(double vec1[3], double vec2[3])
bool myMovedSinceLastHAT
Definition: DtOsgObserverObject.h:1475
bool myLocalModelScalingEnabled
Definition: DtOsgObserverObject.h:1112
bool moving() const
Definition: DtOsgObserverObject.h:1235
Contains makVrv::DtObserverObject class.
bool myChanged
Definition: DtOsgObserverObject.h:1097
void applyRotation(double angle)
Definition: DtOsgObserverObject.h:1260
int myPartAttachment
Definition: DtOsgObserverObject.h:1095
osg::Quat myFinalCameraRotation
This is the combined camera/observer orientation; this is what the DtOsgChannel uses to orient itself...
Definition: DtOsgObserverObject.h:1354
Direction
Definition: DtOsgObserverObject.h:1185
This abstract base class defines the interface for OS-specific keyboard and mouse event listeners...
Definition: DtObserverObject.h:29
MotionState myAttachedObserverState
Definition: DtOsgObserverObject.h:1313
static const double theMaxTerrainRetryTime
Definition: DtOsgObserverObject.h:1079
MotionState myRotatingLevelState
Definition: DtOsgObserverObject.h:1317
osg::Quat myMasterRotation
Definition: DtOsgObserverObject.h:1149
osg::Vec3d myLastSpeedPositionVector
Definition: DtOsgObserverObject.h:1105
boost::unordered_map< DtElementID, bool > ElementVisibilityMap
Definition: DtOsgObserverObject.h:1456
osg::Vec3d myLevelObserverUp
Definition: DtOsgObserverObject.h:1377
DtUniqueID myPendingTerrainPatchId
Definition: DtOsgObserverObject.h:1463
bool rotating() const
Definition: DtOsgObserverObject.h:1285
DtObserverObject::AttachType my3DAttachType
Definition: DtOsgObserverObject.h:1401
NorthType
Definition: DtObserverObject.h:56
double myHeightAboveTerrainTimer
Definition: DtOsgObserverObject.h:1406
double mySceneCenterOffsetY
Definition: DtOsgObserverObject.h:1339
osg::Vec3d myFinalCameraPositionVector
This is the combined camera/observer orientation; this is what the DtOsgChannel uses to orient itself...
Definition: DtOsgObserverObject.h:1358
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:1176
double myCurvatureAdjustment
Definition: DtOsgObserverObject.h:1474
double myNextGotoTerrainCenterTime
Definition: DtOsgObserverObject.h:1461
static const double theMinViewResolution
Definition: DtOsgObserverObject.h:1085
Angle
Definition: DtOsgObserverObject.h:1250
MotionState myAbsoluteRotatingState
Definition: DtOsgObserverObject.h:1318
osg::Vec3d myObserverRotationalVelocityVector
Definition: DtOsgObserverObject.h:1110
unsigned long long DtUniqueID
Definition: DtUniqueID.h:19
osg::Vec3d myPreviousTerrainCenter
Definition: DtOsgObserverObject.h:1464
bool myMutableHaveDownIntersect
Definition: DtOsgObserverObject.h:1433
bool myForceOrientReset
Definition: DtOsgObserverObject.h:1426
void stop()
Definition: DtOsgObserverObject.h:1218
bool myOrientCameraToTargetConstraint
Definition: DtOsgObserverObject.h:1421
osg::Vec3d myObserverFront
Definition: DtOsgObserverObject.h:1374
osg::Vec3d myObserverWorldNorth
Definition: DtOsgObserverObject.h:1366
MotionState myLevelObserverState
Definition: DtOsgObserverObject.h:1312
bool myLookingTiltRight
Definition: DtOsgObserverObject.h:1349
osg::Vec3d myObserverOffsetVector
Current offset from an attachment, when attached.
Definition: DtOsgObserverObject.h:1116
double myLastTickTime
Definition: DtOsgObserverObject.h:1098
osg::Vec3d myPreviousPositionVector
for backing out if we hit a constraint
Definition: DtOsgObserverObject.h:1442
void clearAdvance()
Definition: DtOsgObserverObject.h:1225
bool moving(Direction d) const
Definition: DtOsgObserverObject.h:1240
osg::Vec3d myEuler
Definition: DtOsgObserverObject.h:1306
osg::Quat myCameraShakeRot
Definition: DtOsgObserverObject.h:1478
osg::Quat myFlashlightRotation
Flashlight orientation offset as a quaternion.
Definition: DtOsgObserverObject.h:1152
osg::Vec3d myViewIntersect
Definition: DtOsgObserverObject.h:1431
osg::Vec3d myLevelObserverMimicRight
Definition: DtOsgObserverObject.h:1391
bool mySyncPending
Definition: DtOsgObserverObject.h:1107
osg::Vec3d myAdvance
This, when scaled, will provide the direction that the observer should move in as the result of tick-...
Definition: DtOsgObserverObject.h:1305
bool myLookingRight
-— Camera
Definition: DtOsgObserverObject.h:1345
osg::Vec3d myAttachedUp
Definition: DtOsgObserverObject.h:1381
DT_DLL_vrfutil double mag(double x[3])
osg::Vec3d myCameraOffset
This is the camera offset wrt to observer.
Definition: DtOsgObserverObject.h:1361
osg::Quat mySavedObserverRotation
This is used for switching between track mode and other attach modes.
Definition: DtOsgObserverObject.h:1155
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:1387
double myRotationSpeed
Definition: DtOsgObserverObject.h:1330
double myLastAttachedBvolDiameter
Definition: DtOsgObserverObject.h:1438
bool mySyncSuppressed
Definition: DtOsgObserverObject.h:1108
void setMoving(Direction d, bool moving)
Definition: DtOsgObserverObject.h:1245
double myMinLinearSpeed
Definition: DtOsgObserverObject.h:1334
osg::Quat myObserverRotation
This is our ENU observer orientation as a quaternion.
Definition: DtOsgObserverObject.h:1148
Contains DLL export macros.
double myLastAttachBvolOffset
Definition: DtOsgObserverObject.h:1439
MotionState myObserverState
Definition: DtOsgObserverObject.h:1311
osg::Vec3d myObserverLinearVelocityVector
Definition: DtOsgObserverObject.h:1109
float myLocalModelScalingAmount
Definition: DtOsgObserverObject.h:1113
osg::Vec3d myAttachedWorldUp
Definition: DtOsgObserverObject.h:1369
bool stopped()
Definition: DtOsgObserverObject.h:1230
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
std::vector< DtUniqueID > mySecondaryAttachments
Definition: DtOsgObserverObject.h:1094
osg::Vec3d myAttachPosition
Definition: DtOsgObserverObject.h:1436
osg::Vec3d myOrientToPosition
Definition: DtOsgObserverObject.h:1134
bool myOrbitingRight
Definition: DtOsgObserverObject.h:1324
double myLastViewMagnification
Definition: DtOsgObserverObject.h:1454
osg::Vec3d myAttachedPosition
Definition: DtOsgObserverObject.h:1127
double myOrbitSpeed
Definition: DtOsgObserverObject.h:1328
static const double theMaxViewResolution
Definition: DtOsgObserverObject.h:1088
MotionState myLevelAttachedObserverState
Definition: DtOsgObserverObject.h:1314
bool myConstrainToTerrain
Definition: DtOsgObserverObject.h:1408
double myCurrentViewMagnification
Only used in 3D.
Definition: DtOsgObserverObject.h:1453
osg::Vec3d myObserverRight
Definition: DtOsgObserverObject.h:1375
bool myOrbiting
Definition: DtOsgObserverObject.h:1423
osg::Vec3d myCameraFront
Definition: DtOsgObserverObject.h:1398
bool myLookingDown
Definition: DtOsgObserverObject.h:1348
This abstract base class defines the interface for OS-specific keyboard and mouse event listeners...
Definition: DtOsgObserverObject.h:45
osg::Vec3d myLevelObserverPosition
Gravity change in observer position this frame.
Definition: DtOsgObserverObject.h:1125
double myCurrentObserverDistance
largest of the distances currently in play in a given frame.
Definition: DtOsgObserverObject.h:1142
double mySpeedScaleSpeed
Definition: DtOsgObserverObject.h:1336
static const double theObserverBoundingSphere
Definition: DtOsgObserverObject.h:1076
osg::Vec3d myAttachedRight
Definition: DtOsgObserverObject.h:1383
osg::Vec3d & euler()
Definition: DtOsgObserverObject.h:1275
AttachType
Definition: DtObserverObject.h:36
MotionState()
Definition: DtOsgObserverObject.h:1196

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)