VR-Forces 4.7 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) 2016 MAK Technologies, Inc.
3  * All rights reserved.
4  *****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
15 
16 //#include <matrix/vlVector.h>
17 
18 #include <boost/unordered_map.hpp>
19 
20 #include <osg/Matrixd>
21 #include <osg/Vec3d>
22 #include <osg/Vec3>
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 
103 
104  virtual void startMoveObserverRight();
105  virtual void stopMoveObserverRight();
106  virtual void moveObserverRight( double meters );
107 
109 
110 
111  virtual void startMoveObserverForward();
112  virtual void stopMoveObserverForward();
113  virtual void moveObserverForward( double meters );
115 
117 
118 
119  virtual void startMoveObserverUp();
120  virtual void stopMoveObserverUp();
121  virtual void moveObserverUp( double meters );
123 
125 
126 
127  virtual void startMoveObserverLeft();
128  virtual void stopMoveObserverLeft();
129  virtual void moveObserverLeft( double meters );
131 
133 
134 
135  virtual void startMoveObserverBack();
136  virtual void stopMoveObserverBack();
137  virtual void moveObserverBack( double meters );
139 
141 
142 
143  virtual void startMoveObserverDown();
144  virtual void stopMoveObserverDown();
145  virtual void moveObserverDown( double meters );
147 
149 
150 
151 
152  virtual void startMoveLevelObserverRight();
153  virtual void stopMoveLevelObserverRight();
154  virtual void moveLevelObserverRight( double meters );
156 
158 
159 
160 
161  virtual void startMoveLevelObserverForward();
162  virtual void stopMoveLevelObserverForward();
163  virtual void moveLevelObserverForward( double meters );
165 
167 
168 
169 
170  virtual void startMoveLevelObserverUp();
171  virtual void stopMoveLevelObserverUp();
172  virtual void moveLevelObserverUp( double meters );
174 
176 
177 
178 
179  virtual void startMoveLevelObserverLeft();
180  virtual void stopMoveLevelObserverLeft();
181  virtual void moveLevelObserverLeft( double meters );
183 
185 
186 
187 
188  virtual void startMoveLevelObserverBack();
189  virtual void stopMoveLevelObserverBack();
190  virtual void moveLevelObserverBack( double meters );
192 
194 
195 
196  virtual void startMoveLevelObserverDown();
197  virtual void stopMoveLevelObserverDown();
198  virtual void moveLevelObserverDown( double meters );
200 
202 
203 
204  virtual void startMoveAttachedRight();
205  virtual void stopMoveAttachedRight();
206  virtual void moveAttachedRight( double meters );
207 
209 
210 
211  virtual void startMoveAttachedForward();
212  virtual void stopMoveAttachedForward();
213  virtual void moveAttachedForward( double meters );
215 
217 
218 
219  virtual void startMoveAttachedUp();
220  virtual void stopMoveAttachedUp();
221  virtual void moveAttachedUp( double meters );
223 
225 
226 
227  virtual void startMoveAttachedLeft();
228  virtual void stopMoveAttachedLeft();
229  virtual void moveAttachedLeft( double meters );
231 
233 
234 
235  virtual void startMoveAttachedBack();
236  virtual void stopMoveAttachedBack();
237  virtual void moveAttachedBack( double meters );
239 
241 
242 
243  virtual void startMoveAttachedDown();
244  virtual void stopMoveAttachedDown();
245  virtual void moveAttachedDown( double meters );
247 
249 
250 
251 
252  virtual void startMoveLevelAttachedRight();
253  virtual void stopMoveLevelAttachedRight();
254  virtual void moveLevelAttachedRight( double meters );
256 
258 
259 
260 
261  virtual void startMoveLevelAttachedForward();
262  virtual void stopMoveLevelAttachedForward();
263  virtual void moveLevelAttachedForward( double meters );
265 
267 
268 
269 
270  virtual void startMoveLevelAttachedUp();
271  virtual void stopMoveLevelAttachedUp();
272  virtual void moveLevelAttachedUp( double meters );
274 
276 
277 
278 
279  virtual void startMoveLevelAttachedLeft();
280  virtual void stopMoveLevelAttachedLeft();
281  virtual void moveLevelAttachedLeft( double meters );
283 
285 
286 
287 
288  virtual void startMoveLevelAttachedBack();
289  virtual void stopMoveLevelAttachedBack();
290  virtual void moveLevelAttachedBack( double meters );
292 
294 
295 
296  virtual void startMoveLevelAttachedDown();
297  virtual void stopMoveLevelAttachedDown();
298  virtual void moveLevelAttachedDown( double meters );
300 
302 
303 
304  virtual void startMoveAttachedContextRight();
305  virtual void stopMoveAttachedContextRight();
306  virtual void moveAttachedContextRight( double meters );
308 
310 
311 
312  virtual void startMoveAttachedContextForward();
313  virtual void stopMoveAttachedContextForward();
314  virtual void moveAttachedContextForward( double meters );
316 
318 
319 
320  virtual void startMoveAttachedContextUp();
321  virtual void stopMoveAttachedContextUp();
322  virtual void moveAttachedContextUp( double meters );
324 
326 
327 
328  virtual void startMoveAttachedContextLeft();
329  virtual void stopMoveAttachedContextLeft();
330  virtual void moveAttachedContextLeft( double meters );
332 
334 
335 
336  virtual void startMoveAttachedContextBack();
337  virtual void stopMoveAttachedContextBack();
338  virtual void moveAttachedContextBack( double meters );
340 
342 
343  virtual void startMoveAttachedContextDown();
344  virtual void stopMoveAttachedContextDown();
345  virtual void moveAttachedContextDown( double meters );
347 
349 
350 
351  virtual void startYawLeft();
352  virtual void stopYawLeft();
353  virtual void rotateYawLeft(double rads);
355 
357 
358 
359 
360  virtual void startYawRight();
361  virtual void stopYawRight();
362  virtual void rotateYawRight(double rads);
364 
366 
367 
368  virtual void startPitchUp();
369  virtual void stopPitchUp();
370  virtual void rotatePitchUp( double rads );
371  virtual void rotateFlashlightPitchUp( double rads );
373 
375 
376 
377  virtual void startPitchDown();
378  virtual void stopPitchDown();
379  virtual void rotatePitchDown( double rads );
380  virtual void rotateFlashlightPitchDown( double rads );
382 
384 
385 
386  virtual void startRollLeft();
387  virtual void stopRollLeft();
388  virtual void rollLeft(double rads);
390 
392 
393 
394  virtual void startRollRight();
395  virtual void stopRollRight();
396  virtual void rollRight(double rads);
398 
400 
401 
402  virtual void startLevelYawLeft();
403  virtual void stopLevelYawLeft();
405 
407 
408 
409 
410  virtual void startLevelYawRight();
411  virtual void stopLevelYawRight();
413 
415 
416 
417  virtual void startLevelPitchUp();
418  virtual void stopLevelPitchUp();
419  virtual void rotateLevelPitchUp(double rads);
421 
423 
424 
425  virtual void startLevelPitchDown();
426  virtual void stopLevelPitchDown();
427  virtual void rotateLevelPitchDown(double rads);
429 
431 
432 
433  virtual void startLevelRollLeft();
434  virtual void stopLevelRollLeft();
435  virtual void rollLevelLeft(double rads);
437 
439 
440 
441  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 
477 
478  virtual void startOrbitingLeft();
479  virtual void stopOrbitingLeft();
480  virtual void orbitLeft( double rads );
482 
484 
485 
486  virtual void startOrbitingRight();
487  virtual void stopOrbitingRight();
488  virtual void orbitRight( double rads );
490 
492 
493 
494  virtual void startOrbitingUp();
495  virtual void stopOrbitingUp();
496  virtual void orbitUp( double rads );
498 
500 
501 
502  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 );
526 
528  virtual void setAttachedOrientation( double x, double y, double z,
529  double w);
530 
533  void setLocalModelScalingEnabled( bool enabled );
534 
537  void setLocalModelScalingAmount( float amount );
538 
541  virtual void jumpTo( double x, double y, double z );
542 
544  virtual void jumpTo( DtUniqueID elementID );
545 
546  virtual void orientTo( double x, double y, double z );
547 
549  virtual void dragTerrain( double lastX, double lastY, double lastZ,
550  double currX, double currY, double currZ );
551 
552  virtual void dragTerrain2( double myStartDragX, double myStartDragY,
553  double myStartDragZ, int deltaMouseX, int deltaMouseY );
554 
555  virtual void dragGravityUp( double windowUnits );
556  virtual void dragGravityDown( double windowUnits );
557  virtual void dragGravityLeft( double windowUnits );
558  virtual void dragGravityRight( double windowUnits );
559  virtual void scrollObserverForward( int wheelUnits );
560  virtual void scrollObserverBack( int wheelUnits );
561  virtual void scrollLevelObserverForward( int wheelUnits );
562  virtual void scrollLevelObserverBack( int wheelUnits );
563 
564  virtual void scrollFlashlightWider( int wheelUnits );
565  virtual void scrollFlashlightNarrower( int wheelUnits );
566 
568  virtual float flashlightAngle();
569 
570  //{@
572  virtual void startIncreasingViewResolution();
573  virtual void stopIncreasingViewResolution();
574  virtual void increaseViewResolution();
575 
576  virtual void startDecreasingViewResolution();
577  virtual void stopDecreasingViewResolution();
578  virtual void decreaseViewResolution();
579 
580  // Sets the view resolution in meters per pixel.
581  virtual void setViewResolution( double resolution);
582 
583  // Get the current view resolution.
584  virtual double viewResolution() const;
585 
591  virtual void setCurrentViewMagnification( double mag );
592 
594  virtual double currentViewMagnification() const;
595 
597 
598  //
600  //
601 
603  virtual void setOrbitSpeed( double speed );
604 
606  virtual void setLinearSpeed( double speed );
607 
609  virtual void setRotationSpeed( double speed );
610 
612  virtual void setMinLinearSpeed( double minSpeed );
613 
615  virtual void setMaxLinearSpeed( double maxSpeed );
616 
618  virtual void setLinearScaledSpeedGain( double gain );
619 
625  virtual void gotoTerrainCenter( DtUniqueID terrainPatch, bool retry );
626 
628  virtual void resetAttachment();
629 
630  virtual void resetOrientation();
631 
633  virtual void resetCamera();
634  virtual void level();
635 
636  virtual void stopAll();
637 
638  virtual void attachToObjects( const std::vector<DtUniqueID>& elementIds );
639  virtual void setSecondaryAttachment( const std::vector<DtUniqueID>& elementIds );
640  virtual void setLocationTrackAttachment( const osg::Vec3d& location );
641  virtual void setLocationTrackAttachment( double x, double y, double z );
642 
643  virtual void attachToPart( int partId);
644  virtual void detach();
645  virtual void setAttachType( DtObserverObject::AttachType type );
646  virtual void setHideModelOnAttach( bool hide );
647 
651  virtual void setAttachmentHas3DCockpit( bool cockpit );
652 
653  virtual void scaleCurrentAttachments( bool scaled );
654  virtual void setOrientToTargetConstraint( bool orient );
655  virtual void setOrbiting( bool orbit );
656  virtual void setOrientCameraToTargetConstraint( bool orient );
657 
658  virtual void setConstrainToTerrain( bool trueFalse );
659  virtual void setConstrainToCenter( bool trueFalse );
660 
663  virtual void suppressConstrainToTerrain( bool trueFalse );
664 
665  virtual void setSpeedScaling( bool trueFalse );
666 
668  virtual void setSpeedScaledSpeed( double speed );
669 
670  virtual void getLocation( double &x, double &y, double& z ) const;
671 
673  virtual void getOrientation( double& psi, double& theta, double& phi ) const;
674 
676  virtual void getTopographicOrientation( double& psi, double& theta, double& phi ) const;
677 
678  virtual void getOrientation( double& x, double& y, double& z, double& w ) const;
679 
680  virtual void getFlashlightOrientation( double& x, double& y, double& z, double& w ) const;
681 
684  virtual void getObserverPlatformFront(double& x, double& y, double& z) const;
685 
688  virtual void getObserverPlatformUp(double& x, double& y, double& z) const;
689 
692  virtual void getObserverPlatformRight(double& x, double& y, double& z) const;
693 
696  virtual void getObserverFront(double& x, double& y, double& z) const;
697 
699  virtual void getObserverUp(double& x, double& y, double& z) const;
700 
702  virtual void getObserverRight(double& x, double& y, double& z) const;
703 
704  virtual void getCameraUp(double& x, double& y, double& z);
705 
706  virtual void getCameraFront(double& x, double& y, double& z);
707 
708  virtual void getCameraRight(double& x, double& y, double& z);
709 
711  virtual void setCameraShakeRotation(double x, double y, double z, double w);
712 
714  virtual void getCameraShakeRotation(double& x, double& y, double& z, double& w);;
715 
719  virtual double fixed2DAltitude();
720 
723  virtual double heightAboveTerrainFromCurrentZoom();
724 
727  virtual double topographicHeading() const;
728 
730  virtual void getLinearVelocity(double &x, double &y, double &z) const;
731 
733  virtual void getRotationalVelocity( double& x, double& y, double& z) const;
734 
738  virtual void setModeSetting( int setting, bool value );
739 
741  virtual std::vector<DtUniqueID> currentAttachments() const;
742 
745 
746  virtual const osg::Vec3d& locationTrackAttachmentVec3d() const;
747  virtual void getLocationTrackAttachment( double& x, double& y, double& z ) const;
749 
753  virtual DtObserverObject::AttachType attachType3D() const;
754 
758  virtual DtObserverObject::AttachType attachType2D() const;
759 
761  virtual bool attachedObjectHidden() const;
762 
766  virtual bool attachmentHas3DCockpit() const;
767 
770  virtual osg::Vec3d attachedOffsetVector() const;
771 
776  virtual double attachedNearClipOffset() const;
777 
779  virtual double heightAboveTerrain() const;
780  private:
781 
784 
786  DtOsgObserverObject& operator=( const DtOsgObserverObject& );
787 
788  protected:
789 
791  virtual bool shouldOrientToGlobeCenter();
792 
794  virtual void adjustToGlobeCurvature();
795 
797  virtual bool shouldRotateGlobe();
798 
801  virtual double zoomFromCurrentAltitude();
802 
805  virtual double altitudeFromCurrentZoom();
806 
807  virtual void calcObserverWorldVectors();
808  virtual const osg::Vec3d& observerWorldUp() const;
809  virtual const osg::Vec3d& observerWorldNorth() const;
810  virtual const osg::Vec3d& observerWorldEast() const;
811 
812  virtual const osg::Vec3d& attachedWorldUp() const;
813 
814  virtual osg::Vec3d& observerUp();
815  virtual osg::Vec3d& observerFront();
816  virtual osg::Vec3d& observerRight();
817  virtual void observerBasis(osg::Vec3d& up, osg::Vec3d& front, osg::Vec3d& right);
818 
819  virtual osg::Vec3d& attachedUp();
820  virtual osg::Vec3d& attachedFront();
821  virtual osg::Vec3d& attachedRight();
822 
823  virtual osg::Vec3d& attachedOffsetUp();
824  virtual osg::Vec3d& attachedOffsetFront();
825  virtual osg::Vec3d& attachedOffsetRight();
826 
828  virtual osg::Vec3d& levelAttachedUp();
829  virtual osg::Vec3d& levelAttachedFront();
830  virtual osg::Vec3d& levelAttachedRight();
831 
833  virtual osg::Vec3d& levelObserverMimicUp();
834  virtual osg::Vec3d& levelObserverMimicFront();
835  virtual osg::Vec3d& levelObserverMimicRight();
836 
837  virtual osg::Vec3d& cameraUp();
838  virtual osg::Vec3d& cameraFront();
839  virtual osg::Vec3d& cameraRight();
840 
841  virtual osg::Vec3d& levelObserverUp();
842  virtual osg::Vec3d& levelObserverFront();
843  virtual osg::Vec3d& levelObserverRight();
844 
845  virtual void advanceOrbitLeft( double rads );
846  virtual void advanceOrbitRight( double rads );
847  virtual void advanceOrbitUp( double rads );
848  virtual void advanceOrbitDown( double rads );
849 
850  virtual void makeLevelObserverMatrix();
851 
853  virtual void calculateLevelAttachedRotation();
854 
856  virtual void makeLevelObserverMimicMatrix();
857 
861  virtual osg::Vec3d calcWorldPositionChange();
862 
863  virtual osg::Vec3d calcMimicPositionChange();
864 
865  virtual osg::Vec3d calcAttachedPosition(const osg::Quat& attInverse, const osg::Vec3d& attachedAdvance);
866  virtual osg::Vec3d calcAttachedAdvance(const osg::Quat& tetherTrackInverse);
867 
868  virtual osg::Vec3d calcFollowPositionChange();
869  virtual osg::Vec3d calcSpaceFollowPositionChange();
870  virtual osg::Vec3d calcTetherPositionChange();
871  virtual osg::Vec3d calcTetherTrackPositionChange();
872 
873  virtual osg::Vec3d calcTrackPositionChange();
874  virtual osg::Quat calcTetherTrackRotation();
875 
876  virtual osg::Quat calcFlashlightOrientationChange();
877  virtual osg::Quat calcWorldOrientationChange();
878  virtual osg::Quat calcTetherOrientationChange();
879  virtual osg::Quat calcMimicOrientationChange();
880  virtual osg::Quat calcFollowOrientationChange();
881 
882  virtual void setCurrentAttachmentsVisibility( bool visible );
883 
890 
893  virtual void orientTo( const osg::Vec3d& target );
894 
896  virtual void orientCameraTo( const osg::Vec3d& target );
897 
898  virtual TerrainResult getTerrainCenter( const DtUniqueID& patchID, osg::Vec3d& center );
899 
900  virtual DtCoordinateConverter& coordinateConverter();
901  virtual const DtCoordinateConverter& coordinateConverter() const;
902 
903  virtual void initializeAttachment();
904 
905  virtual void getScalingIntersection();
906  virtual void getViewIntersection();
907 
909  virtual double linearSpeed();
910 
912  virtual double speedScalingGain() const;
913 
914  virtual void calcTerrainConstraint(const osg::Vec3d& prev );
915 
921  virtual bool updateAttachPositionAndOrientation();
922 
923  virtual bool getSecondaryAttachPosition( osg::Vec3d& position );
924 
925  virtual void getObserverOffsetVector( double& x, double& y, double& z ) const;
926  virtual void setObserverOffsetVector( double x, double y, double z );
927 
928  virtual void getAttachedRotationOffset( double& x, double& y, double& z, double& w ) const;
929  virtual void setAttachedRotationOffset( double x, double y, double z,
930  double w );
931 
932  virtual void getBoundingVolume( DtSceneObject& sceneObject,
933  osg::Vec3& bvolExtents, osg::Vec3d& bvolCenter );
934 
935  virtual void getBoundingVolume( DtTerrainPatchObject& patchObject,
936  osg::Vec3& bvolExtents, osg::Vec3d& bvolCenter );
937 
938  virtual void setLocation( const osg::Vec3d& location, bool suppress=true );
939 
940  virtual bool isMoving() const;
941  virtual bool isRotating() const;
942 
943  virtual double computeNearClipDistance( DtSceneObject* sceneObject );
944  virtual float computeLocalModelScalingAmount( DtSceneObject* sceneObject );
945 
946  virtual void calcScaledSpeed();
947  virtual bool getTerrainOrPropIntersection( const osg::Vec3d& startPos,
948  const osg::Vec3d& endPos, osg::Vec3d& result ) const;
949 
951  virtual DtSceneObject* findSceneObjectFromElement(const DtElementID& id);
952 
954  virtual DtTerrainPatchObject* findTerrainPatchObjectFromElement( DtElementID id );
955  virtual DtOsgObserverObject* findObserverObjectFromElement( DtElementID id );
956 
957  virtual void getPositionAndOrientation( DtSceneObject& sceneObject, osg::Vec3d& position,
958  osg::Vec3d& orientToPosition, osg::Quat& orientation );
959 
960  virtual void getPositionAndOrientation( DtTerrainPatchObject& patchObject, osg::Vec3d& position,
961  osg::Vec3d& orientToPosition, osg::Quat& orientation );
962 
963  virtual void getPositionAndOrientation( DtOsgObserverObject& observerObject, osg::Vec3d& position,
964  osg::Vec3d& orientToPosition, osg::Quat& orientation );
965 
967  virtual void getPositionFromSceneObject( DtSceneObject& sceneObject, osg::Vec3d& position ) const;
968 
970  virtual void getPositionFromObserverObject( DtOsgObserverObject& observerObject, osg::Vec3d& position ) const;
971 
974  virtual bool getPartPositionOriFromSceneObject( DtSceneObject& sceneObject,
975  int partId, osg::Vec3d& position, osg::Quat& ori ) const;
976 
979  virtual void force2D();
980 
982  virtual void dimensionChanged( bool is2D );
983  virtual void setIs2D( bool is2D );
984 
986  virtual double calculate3DAltitude() const;
987 
989  virtual void calculateAltitude();
990 
993  virtual double zoomFromAltitude( double altitude );
994 
997  virtual double zoomFromHeightAboveTerrain( double hat );
998 
999  virtual double calcEarthRadiusAtLocalCoord( const osg::Vec3d& local ) const;
1000 
1001  // Sends the location of the observer on the master to all others; only used
1002  // if different
1003  virtual void synchronizeLocation( double x, double y, double z );
1004 
1005  // Sends the orientation of the observer on the master to all others; only used
1006  // if different
1007  virtual void synchronizeOrientation( double x, double y, double z, double w );
1008 
1009  virtual void calcHeightAboveTerrain();
1010 
1011  // Utility function that returns the list of channels whose observer is
1012  // this observer
1013  std::list<DtChannel*> findChannels();
1014 
1015  // This is calculated based on channel parameters. It replaces the old
1016  // theZoomAltitudeConstant, which was an approximation
1017  double heightToZoomRatio();
1018 
1019  protected:
1020 
1021  static const double theObserverBoundingSphere;
1023 
1024  static const double theMaxTerrainRetryTime;
1025 
1026  // below this altitude, ignore myConstrainToCenter
1027  static const double theCenterConstrainHeight;
1028 
1029  // Zoom won't get any smaller than this
1030  static const double theMinViewResolution;
1031 
1032  // Zoom won't get any larger than this
1033  static const double theMaxViewResolution;
1034 
1035 
1036  protected:
1037 
1038  std::vector<DtUniqueID> myCurrentAttachments;
1039  std::vector<DtUniqueID> mySecondaryAttachments;
1041 
1044 
1045  //
1047  //
1056 
1059 
1062 
1065 
1068 
1071 
1073 
1075 
1077  osg::Vec3d myDragMove;
1078 
1080 
1081  osg::Vec3d myOrbitAdvance;
1082 
1088 
1091 
1094  osg::Quat myMasterRotation;
1095 
1098 
1101 
1106 
1109 
1112 
1115 
1119 
1120  //bool myGlobeObserverMode;
1122 
1125 
1127  {
1128  public:
1129 
1131  {
1132  Stopped = 0,
1133  Forward = 1,
1134  Backward = 2,
1135  Left = 4,
1136  Right = 8,
1137  Up = 16,
1138  Down = 32
1139  };
1140 
1142  : myState(Stopped)
1143  {
1144  }
1145 
1147  inline void applyMovement(double linearDistance)
1148  {
1149  if(moving(Right)) myAdvance[0] += linearDistance;
1150  if(moving(Left)) myAdvance[0] -= linearDistance;
1151  if(moving(Forward)) myAdvance[1] += linearDistance;
1152  if(moving(Backward)) myAdvance[1] -= linearDistance;
1153  if(moving(Up)) myAdvance[2] += linearDistance;
1154  if(moving(Down)) myAdvance[2] -= linearDistance;
1155  }
1156 
1158  inline const osg::Vec3d& advance() const
1159  {
1160  return myAdvance;
1161  }
1162 
1163  inline void stop()
1164  {
1165  myState = Stopped;
1166  myAdvance.set(0.0,0.0,0.0);
1167  myEuler.set(0.0,0.0,0.0);
1168  }
1169 
1170  inline void clearAdvance()
1171  {
1172  myAdvance.set(0.0,0.0,0.0);
1173  }
1174 
1175  inline bool stopped()
1176  {
1177  return myState == Stopped;
1178  }
1179 
1180  inline bool moving() const
1181  {
1182  return myState != Stopped;
1183  }
1184 
1185  inline bool moving(Direction d) const
1186  {
1187  return (myState & d) != 0;
1188  }
1189 
1190  inline void setMoving(Direction d, bool moving)
1191  {
1192  myState = moving ? myState | d : myState & ~d;
1193  }
1194 
1195  enum Angle
1196  {
1197  YawLeft = 1,
1198  YawRight = 2,
1199  PitchUp = 4,
1200  PitchDown = 8,
1201  RollLeft = 16,
1202  RollRight = 32
1203  };
1204 
1205  inline void applyRotation(double angle)
1206  {
1207  if(rotating(YawRight)) myEuler[0] -= angle;
1208  if(rotating(YawLeft)) myEuler[0] += angle;
1209  if(rotating(PitchUp)) myEuler[1] += angle;
1210  if(rotating(PitchDown)) myEuler[1] -= angle;
1211  if(rotating(RollRight)) myEuler[2] += angle;
1212  if(rotating(RollLeft)) myEuler[2] -= angle;
1213  }
1214 
1215  inline const osg::Vec3d& euler() const
1216  {
1217  return myEuler;
1218  }
1219 
1220  inline osg::Vec3d& euler()
1221  {
1222  return myEuler;
1223  }
1224 
1225  inline void level()
1226  {
1227  myEuler.set(0.0,0.0,0.0);
1228  }
1229 
1230  inline bool rotating() const
1231  {
1232  return myState != Stopped;
1233  }
1234 
1235  inline bool rotating( Angle d ) const
1236  {
1237  return (myState & d) != 0;
1238  }
1239 
1240  inline void setRotating( Angle d, bool rotating )
1241  {
1242  myState = rotating ? myState | d : myState & ~d;
1243  }
1244 
1245  protected:
1246 
1250  osg::Vec3d myAdvance;
1251  osg::Vec3d myEuler;
1252 
1253  unsigned char myState;
1254  };
1255 
1260 
1265 
1267 
1272 
1276 
1282 
1286 
1287  //
1296 
1300 
1304 
1306  osg::Vec3d myCameraOffset;
1308  osg::Quat myCameraRotation;
1309 
1310  osg::Vec3d myObserverWorldUp;
1313 
1314  osg::Vec3d myAttachedWorldUp;
1317 
1318  osg::Vec3d myObserverUp;
1319  osg::Vec3d myObserverFront;
1320  osg::Vec3d myObserverRight;
1321 
1322  osg::Vec3d myLevelObserverUp;
1325 
1326  osg::Vec3d myAttachedUp;
1327  osg::Vec3d myAttachedFront;
1328  osg::Vec3d myAttachedRight;
1329 
1330  osg::Vec3d myLevelAttachedUp;
1333 
1337 
1341 
1342  osg::Vec3d myCameraUp;
1343  osg::Vec3d myCameraFront;
1344  osg::Vec3d myCameraRight;
1345 
1348 
1353 
1355 
1358 
1361 
1370  // force an orientation reset AFTER the next time the observer position is updated
1371  // Needed when making large attach jumps
1373 
1375 
1377  osg::Vec3d myViewIntersect;
1378 
1380  osg::Vec3d myDownIntersect;
1381 
1382  osg::Vec3d myAttachPosition;
1383 
1386 
1390 
1391  double myAltitude;
1392 
1397 
1401 
1402  typedef boost::unordered_map<DtElementID, bool> ElementVisibilityMap;
1404 
1405  // Paged terrain initialization
1412 
1413  // Used for speed scaling, this is the same as myHeightAboveTerrain
1414  // when unattached, but the distance from the attached entity when
1415  // attached
1417 
1418  // curvature adjustment
1422 
1423  osg::Quat myCameraShakeRot;
1424 
1426  };
1427 
1428 }

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)