VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 
78  virtual void getCameraPositionAndOrientation( osg::Vec3d& position,
79  osg::Quat& rotation ) const;
80 
82  static void matrixdToTaitBryan( const osg::Matrixd& mat, DtTaitBryan& tb, bool isWorld2D = false );
83  static double clampUnity( double x );
84 
85 
86  //
87  //
89  //
90  //
91 
93 
94 
95  virtual void startMoveObserverRight();
96  virtual void stopMoveObserverRight();
97  virtual void moveObserverRight( double meters );
98 
100 
101 
102  virtual void startMoveObserverForward();
103  virtual void stopMoveObserverForward();
104  virtual void moveObserverForward( double meters );
106 
108 
109 
110  virtual void startMoveObserverUp();
111  virtual void stopMoveObserverUp();
112  virtual void moveObserverUp( double meters );
114 
116 
117 
118  virtual void startMoveObserverLeft();
119  virtual void stopMoveObserverLeft();
120  virtual void moveObserverLeft( double meters );
122 
124 
125 
126  virtual void startMoveObserverBack();
127  virtual void stopMoveObserverBack();
128  virtual void moveObserverBack( double meters );
130 
132 
133 
134  virtual void startMoveObserverDown();
135  virtual void stopMoveObserverDown();
136  virtual void moveObserverDown( double meters );
138 
140 
141 
142 
143  virtual void startMoveLevelObserverRight();
144  virtual void stopMoveLevelObserverRight();
145  virtual void moveLevelObserverRight( double meters );
147 
149 
150 
151 
152  virtual void startMoveLevelObserverForward();
153  virtual void stopMoveLevelObserverForward();
154  virtual void moveLevelObserverForward( double meters );
156 
158 
159 
160 
161  virtual void startMoveLevelObserverUp();
162  virtual void stopMoveLevelObserverUp();
163  virtual void moveLevelObserverUp( double meters );
165 
167 
168 
169 
170  virtual void startMoveLevelObserverLeft();
171  virtual void stopMoveLevelObserverLeft();
172  virtual void moveLevelObserverLeft( double meters );
174 
176 
177 
178 
179  virtual void startMoveLevelObserverBack();
180  virtual void stopMoveLevelObserverBack();
181  virtual void moveLevelObserverBack( double meters );
183 
185 
186 
187  virtual void startMoveLevelObserverDown();
188  virtual void stopMoveLevelObserverDown();
189  virtual void moveLevelObserverDown( double meters );
191 
193 
194 
195  virtual void startMoveAttachedRight();
196  virtual void stopMoveAttachedRight();
197  virtual void moveAttachedRight( double meters );
198 
200 
201 
202  virtual void startMoveAttachedForward();
203  virtual void stopMoveAttachedForward();
204  virtual void moveAttachedForward( double meters );
206 
208 
209 
210  virtual void startMoveAttachedUp();
211  virtual void stopMoveAttachedUp();
212  virtual void moveAttachedUp( double meters );
214 
216 
217 
218  virtual void startMoveAttachedLeft();
219  virtual void stopMoveAttachedLeft();
220  virtual void moveAttachedLeft( double meters );
222 
224 
225 
226  virtual void startMoveAttachedBack();
227  virtual void stopMoveAttachedBack();
228  virtual void moveAttachedBack( double meters );
230 
232 
233 
234  virtual void startMoveAttachedDown();
235  virtual void stopMoveAttachedDown();
236  virtual void moveAttachedDown( double meters );
238 
240 
241 
242 
243  virtual void startMoveLevelAttachedRight();
244  virtual void stopMoveLevelAttachedRight();
245  virtual void moveLevelAttachedRight( double meters );
247 
249 
250 
251 
252  virtual void startMoveLevelAttachedForward();
253  virtual void stopMoveLevelAttachedForward();
254  virtual void moveLevelAttachedForward( double meters );
256 
258 
259 
260 
261  virtual void startMoveLevelAttachedUp();
262  virtual void stopMoveLevelAttachedUp();
263  virtual void moveLevelAttachedUp( double meters );
265 
267 
268 
269 
270  virtual void startMoveLevelAttachedLeft();
271  virtual void stopMoveLevelAttachedLeft();
272  virtual void moveLevelAttachedLeft( double meters );
274 
276 
277 
278 
279  virtual void startMoveLevelAttachedBack();
280  virtual void stopMoveLevelAttachedBack();
281  virtual void moveLevelAttachedBack( double meters );
283 
285 
286 
287  virtual void startMoveLevelAttachedDown();
288  virtual void stopMoveLevelAttachedDown();
289  virtual void moveLevelAttachedDown( double meters );
291 
293 
294 
295  virtual void startMoveAttachedContextRight();
296  virtual void stopMoveAttachedContextRight();
297  virtual void moveAttachedContextRight( double meters );
299 
301 
302 
303  virtual void startMoveAttachedContextForward();
304  virtual void stopMoveAttachedContextForward();
305  virtual void moveAttachedContextForward( double meters );
307 
309 
310 
311  virtual void startMoveAttachedContextUp();
312  virtual void stopMoveAttachedContextUp();
313  virtual void moveAttachedContextUp( double meters );
315 
317 
318 
319  virtual void startMoveAttachedContextLeft();
320  virtual void stopMoveAttachedContextLeft();
321  virtual void moveAttachedContextLeft( double meters );
323 
325 
326 
327  virtual void startMoveAttachedContextBack();
328  virtual void stopMoveAttachedContextBack();
329  virtual void moveAttachedContextBack( double meters );
331 
333 
334  virtual void startMoveAttachedContextDown();
335  virtual void stopMoveAttachedContextDown();
336  virtual void moveAttachedContextDown( double meters );
338 
340 
341 
342  virtual void startYawLeft();
343  virtual void stopYawLeft();
344  virtual void rotateYawLeft(double rads);
346 
348 
349 
350 
351  virtual void startYawRight();
352  virtual void stopYawRight();
353  virtual void rotateYawRight(double rads);
355 
357 
358 
359  virtual void startPitchUp();
360  virtual void stopPitchUp();
361  virtual void rotatePitchUp( double rads );
362  virtual void rotateFlashlightPitchUp( double rads );
364 
366 
367 
368  virtual void startPitchDown();
369  virtual void stopPitchDown();
370  virtual void rotatePitchDown( double rads );
371  virtual void rotateFlashlightPitchDown( double rads );
373 
375 
376 
377  virtual void startRollLeft();
378  virtual void stopRollLeft();
379  virtual void rollLeft(double rads);
381 
383 
384 
385  virtual void startRollRight();
386  virtual void stopRollRight();
387  virtual void rollRight(double rads);
389 
391 
392 
393  virtual void startLevelYawLeft();
394  virtual void stopLevelYawLeft();
396 
398 
399 
400 
401  virtual void startLevelYawRight();
402  virtual void stopLevelYawRight();
404 
406 
407 
408  virtual void startLevelPitchUp();
409  virtual void stopLevelPitchUp();
410  virtual void rotateLevelPitchUp(double rads);
412 
414 
415 
416  virtual void startLevelPitchDown();
417  virtual void stopLevelPitchDown();
418  virtual void rotateLevelPitchDown(double rads);
420 
422 
423 
424  virtual void startLevelRollLeft();
425  virtual void stopLevelRollLeft();
426  virtual void rollLevelLeft(double rads);
428 
430 
431 
432  virtual void startLevelRollRight();
433  virtual void stopLevelRollRight();
434  virtual void rollLevelRight(double rads);
436 
437  virtual void rotateLevelYawLeft( double rads );
438  virtual void rotateLevelYawRight( double rads );
439  virtual void rotateFlashlightYawLeft( double rads );
440  virtual void rotateFlashlightYawRight( double rads );
441 
442  virtual void startLookLeft();
443  virtual void stopLookLeft();
444  virtual void lookLeft( double rads );
445 
446  virtual void startLookRight();
447  virtual void stopLookRight();
448  virtual void lookRight( double rads );
449 
450  virtual void startLookUp();
451  virtual void stopLookUp();
452  virtual void lookUp( double rads );
453 
454  virtual void startLookDown();
455  virtual void stopLookDown();
456  virtual void lookDown( double rads );
457 
458  virtual void startLookTiltRight();
459  virtual void stopLookTiltRight();
460  virtual void lookTiltRight( double rads );
461 
462  virtual void startLookTiltLeft();
463  virtual void stopLookTiltLeft();
464  virtual void lookTiltLeft( double rads );
465 
467 
468 
469  virtual void startOrbitingLeft();
470  virtual void stopOrbitingLeft();
471  virtual void orbitLeft( double rads );
473 
475 
476 
477  virtual void startOrbitingRight();
478  virtual void stopOrbitingRight();
479  virtual void orbitRight( double rads );
481 
483 
484 
485  virtual void startOrbitingUp();
486  virtual void stopOrbitingUp();
487  virtual void orbitUp( double rads );
489 
491 
492 
493  virtual void startOrbitingDown();
494  virtual void stopOrbitingDown();
495  virtual void orbitDown( double rads );
497 
499  virtual void setLocation( double x, double y, double z);
500 
504  virtual void setAttachedLocation( double x, double y, double z );
505 
507  virtual void setOrientation( double psi, double theta, double phi );
508 
510  virtual void setTopographicOrientation( double psi, double theta, double phi );
511 
513  virtual void setOrientation( double x, double y, double z, double w);
514 
516  virtual void setAttachedOrientation( double psi, double theta, double phi );
517 
519  virtual void setAttachedOrientation( double x, double y, double z,
520  double w);
521 
524  void setLocalModelScalingEnabled( bool enabled );
525 
528  void setLocalModelScalingAmount( float amount );
529 
532  virtual void jumpTo( double x, double y, double z );
533 
535  virtual void jumpTo( DtUniqueID elementID );
536 
537  virtual void orientTo( double x, double y, double z );
538 
540  virtual void dragTerrain( double lastX, double lastY, double lastZ,
541  double currX, double currY, double currZ );
542 
543  virtual void dragTerrain2( double myStartDragX, double myStartDragY,
544  double myStartDragZ, int deltaMouseX, int deltaMouseY );
545 
546  virtual void dragGravityUp( double windowUnits );
547  virtual void dragGravityDown( double windowUnits );
548  virtual void dragGravityLeft( double windowUnits );
549  virtual void dragGravityRight( double windowUnits );
550  virtual void scrollObserverForward( int wheelUnits );
551  virtual void scrollObserverBack( int wheelUnits );
552  virtual void scrollLevelObserverForward( int wheelUnits );
553  virtual void scrollLevelObserverBack( int wheelUnits );
554 
555  virtual void scrollFlashlightWider( int wheelUnits );
556  virtual void scrollFlashlightNarrower( int wheelUnits );
557 
559  virtual float flashlightAngle();
560 
561  //{@
563  virtual void startIncreasingViewResolution();
564  virtual void stopIncreasingViewResolution();
565  virtual void increaseViewResolution();
566 
567  virtual void startDecreasingViewResolution();
568  virtual void stopDecreasingViewResolution();
569  virtual void decreaseViewResolution();
570 
571  // Sets the view resolution in meters per pixel.
572  virtual void setViewResolution( double resolution);
573 
574  // Get the current view resolution.
575  virtual double viewResolution() const;
576 
582  virtual void setCurrentViewMagnification( double mag );
583 
585  virtual double currentViewMagnification() const;
586 
588 
589  //
591  //
592 
594  virtual void setOrbitSpeed( double speed );
595 
597  virtual void setLinearSpeed( double speed );
598 
600  virtual void setRotationSpeed( double speed );
601 
603  virtual void setMinLinearSpeed( double minSpeed );
604 
606  virtual void setMaxLinearSpeed( double maxSpeed );
607 
609  virtual void setLinearScaledSpeedGain( double gain );
610 
616  virtual void gotoTerrainCenter( DtUniqueID terrainPatch, bool retry );
617 
619  virtual void resetAttachment();
620 
621  virtual void resetOrientation();
622 
624  virtual void resetCamera();
625  virtual void level();
626 
627  virtual void stopAll();
628 
629  virtual void attachToObjects( const std::vector<DtUniqueID>& elementIds );
630  virtual void setSecondaryAttachment( const std::vector<DtUniqueID>& elementIds );
631  virtual void setLocationTrackAttachment( const osg::Vec3d& location );
632  virtual void setLocationTrackAttachment( double x, double y, double z );
633 
634  virtual void attachToPart( int partId);
635  virtual void detach();
636  virtual void setAttachType( DtObserverObject::AttachType type );
637  virtual void setHideModelOnAttach( bool hide );
638 
642  virtual void setAttachmentHas3DCockpit( bool cockpit );
643 
644  virtual void scaleCurrentAttachments( bool scaled );
645  virtual void setOrientToTargetConstraint( bool orient );
646  virtual void setOrbiting( bool orbit );
647  virtual void setOrientCameraToTargetConstraint( bool orient );
648 
649  virtual void setConstrainToTerrain( bool trueFalse );
650  virtual void setConstrainToCenter( bool trueFalse );
651 
654  virtual void suppressConstrainToTerrain( bool trueFalse );
655 
656  virtual void setSpeedScaling( bool trueFalse );
657 
659  virtual void setSpeedScaledSpeed( double speed );
660 
661  virtual void getLocation( double &x, double &y, double& z ) const;
662 
664  virtual void getOrientation( double& psi, double& theta, double& phi ) const;
665 
667  virtual void getTopographicOrientation( double& psi, double& theta, double& phi ) const;
668 
669  virtual void getOrientation( double& x, double& y, double& z, double& w ) const;
670 
671  virtual void getFlashlightOrientation( double& x, double& y, double& z, double& w ) const;
672 
675  virtual void getObserverPlatformFront(double& x, double& y, double& z) const;
676 
679  virtual void getObserverPlatformUp(double& x, double& y, double& z) const;
680 
683  virtual void getObserverPlatformRight(double& x, double& y, double& z) const;
684 
687  virtual void getObserverFront(double& x, double& y, double& z) const;
688 
690  virtual void getObserverUp(double& x, double& y, double& z) const;
691 
693  virtual void getObserverRight(double& x, double& y, double& z) const;
694 
695  virtual void getCameraUp(double& x, double& y, double& z);
696 
697  virtual void getCameraFront(double& x, double& y, double& z);
698 
699  virtual void getCameraRight(double& x, double& y, double& z);
700 
702  virtual void setCameraShakeRotation(double x, double y, double z, double w);
703 
705  virtual void getCameraShakeRotation(double& x, double& y, double& z, double& w);;
706 
710  virtual double fixed2DAltitude();
711 
714  virtual double heightAboveTerrainFromCurrentZoom();
715 
718  virtual double topographicHeading() const;
719 
721  virtual void getLinearVelocity(double &x, double &y, double &z) const;
722 
724  virtual void getRotationalVelocity( double& x, double& y, double& z) const;
725 
729  virtual void setModeSetting( int setting, bool value );
730 
732  virtual std::vector<DtUniqueID> currentAttachments() const;
733 
736 
737  virtual const osg::Vec3d& locationTrackAttachmentVec3d() const;
738  virtual void getLocationTrackAttachment( double& x, double& y, double& z ) const;
740 
744  virtual DtObserverObject::AttachType attachType3D() const;
745 
749  virtual DtObserverObject::AttachType attachType2D() const;
750 
752  virtual bool attachedObjectHidden() const;
753 
757  virtual bool attachmentHas3DCockpit() const;
758 
761  virtual osg::Vec3d attachedOffsetVector() const;
762 
767  virtual double attachedNearClipOffset() const;
768 
770  virtual double heightAboveTerrain() const;
771  private:
772 
775 
777  DtOsgObserverObject& operator=( const DtOsgObserverObject& );
778 
779  protected:
780 
782  virtual bool shouldOrientToGlobeCenter();
783 
785  virtual void adjustToGlobeCurvature();
786 
788  virtual bool shouldRotateGlobe();
789 
792  virtual double zoomFromCurrentAltitude();
793 
796  virtual double altitudeFromCurrentZoom();
797 
798  virtual void calcObserverWorldVectors();
799  virtual const osg::Vec3d& observerWorldUp() const;
800  virtual const osg::Vec3d& observerWorldNorth() const;
801  virtual const osg::Vec3d& observerWorldEast() const;
802 
803  virtual const osg::Vec3d& attachedWorldUp() const;
804 
805  virtual osg::Vec3d& observerUp();
806  virtual osg::Vec3d& observerFront();
807  virtual osg::Vec3d& observerRight();
808  virtual void observerBasis(osg::Vec3d& up, osg::Vec3d& front, osg::Vec3d& right);
809 
810  virtual osg::Vec3d& attachedUp();
811  virtual osg::Vec3d& attachedFront();
812  virtual osg::Vec3d& attachedRight();
813 
814  virtual osg::Vec3d& attachedOffsetUp();
815  virtual osg::Vec3d& attachedOffsetFront();
816  virtual osg::Vec3d& attachedOffsetRight();
817 
819  virtual osg::Vec3d& levelAttachedUp();
820  virtual osg::Vec3d& levelAttachedFront();
821  virtual osg::Vec3d& levelAttachedRight();
822 
824  virtual osg::Vec3d& levelObserverMimicUp();
825  virtual osg::Vec3d& levelObserverMimicFront();
826  virtual osg::Vec3d& levelObserverMimicRight();
827 
828  virtual osg::Vec3d& cameraUp();
829  virtual osg::Vec3d& cameraFront();
830  virtual osg::Vec3d& cameraRight();
831 
832  virtual osg::Vec3d& levelObserverUp();
833  virtual osg::Vec3d& levelObserverFront();
834  virtual osg::Vec3d& levelObserverRight();
835 
836  virtual void advanceOrbitLeft( double rads );
837  virtual void advanceOrbitRight( double rads );
838  virtual void advanceOrbitUp( double rads );
839  virtual void advanceOrbitDown( double rads );
840 
841  virtual void makeLevelObserverMatrix();
842 
844  virtual void calculateLevelAttachedRotation();
845 
847  virtual void makeLevelObserverMimicMatrix();
848 
852  virtual osg::Vec3d calcWorldPositionChange();
853 
854  virtual osg::Vec3d calcMimicPositionChange();
855 
856  virtual osg::Vec3d calcAttachedPosition(const osg::Quat& attInverse, const osg::Vec3d& attachedAdvance);
857  virtual osg::Vec3d calcAttachedAdvance(const osg::Quat& tetherTrackInverse);
858 
859  virtual osg::Vec3d calcFollowPositionChange();
860  virtual osg::Vec3d calcSpaceFollowPositionChange();
861  virtual osg::Vec3d calcTetherPositionChange();
862  virtual osg::Vec3d calcTetherTrackPositionChange();
863 
864  virtual osg::Vec3d calcTrackPositionChange();
865  virtual osg::Quat calcTetherTrackRotation();
866 
867  virtual osg::Quat calcFlashlightOrientationChange();
868  virtual osg::Quat calcWorldOrientationChange();
869  virtual osg::Quat calcTetherOrientationChange();
870  virtual osg::Quat calcMimicOrientationChange();
871  virtual osg::Quat calcFollowOrientationChange();
872 
873  virtual void setCurrentAttachmentsVisibility( bool visible );
874 
881 
884  virtual void orientTo( const osg::Vec3d& target );
885 
887  virtual void orientCameraTo( const osg::Vec3d& target );
888 
889  virtual TerrainResult getTerrainCenter( const DtUniqueID& patchID, osg::Vec3d& center );
890 
891  virtual DtCoordinateConverter& coordinateConverter();
892  virtual const DtCoordinateConverter& coordinateConverter() const;
893 
894  virtual void initializeAttachment();
895 
896  virtual void getScalingIntersection();
897  virtual void getViewIntersection();
898 
900  virtual double linearSpeed();
901 
903  virtual double speedScalingGain() const;
904 
905  virtual void calcTerrainConstraint(const osg::Vec3d& prev );
906 
912  virtual bool updateAttachPositionAndOrientation();
913 
914  virtual bool getSecondaryAttachPosition( osg::Vec3d& position );
915 
916  virtual void getObserverOffsetVector( double& x, double& y, double& z ) const;
917  virtual void setObserverOffsetVector( double x, double y, double z );
918 
919  virtual void getAttachedRotationOffset( double& x, double& y, double& z, double& w ) const;
920  virtual void setAttachedRotationOffset( double x, double y, double z,
921  double w );
922 
923  virtual void getBoundingVolume( DtSceneObject& sceneObject,
924  osg::Vec3& bvolExtents, osg::Vec3d& bvolCenter );
925 
926  virtual void getBoundingVolume( DtTerrainPatchObject& patchObject,
927  osg::Vec3& bvolExtents, osg::Vec3d& bvolCenter );
928 
929  virtual void setLocation( const osg::Vec3d& location, bool suppress=true );
930 
931  virtual bool isMoving() const;
932  virtual bool isRotating() const;
933 
934  virtual double computeNearClipDistance( DtSceneObject* sceneObject );
935  virtual float computeLocalModelScalingAmount( DtSceneObject* sceneObject );
936 
937  virtual void calcScaledSpeed();
938  virtual bool getTerrainOrPropIntersection( const osg::Vec3d& startPos,
939  const osg::Vec3d& endPos, osg::Vec3d& result ) const;
940 
942  virtual DtSceneObject* findSceneObjectFromElement(const DtElementID& id);
943 
945  virtual DtTerrainPatchObject* findTerrainPatchObjectFromElement( DtElementID id );
946  virtual DtOsgObserverObject* findObserverObjectFromElement( DtElementID id );
947 
948  virtual void getPositionAndOrientation( DtSceneObject& sceneObject, osg::Vec3d& position,
949  osg::Vec3d& orientToPosition, osg::Quat& orientation );
950 
951  virtual void getPositionAndOrientation( DtTerrainPatchObject& patchObject, osg::Vec3d& position,
952  osg::Vec3d& orientToPosition, osg::Quat& orientation );
953 
954  virtual void getPositionAndOrientation( DtOsgObserverObject& observerObject, osg::Vec3d& position,
955  osg::Vec3d& orientToPosition, osg::Quat& orientation );
956 
958  virtual void getPositionFromSceneObject( DtSceneObject& sceneObject, osg::Vec3d& position ) const;
959 
961  virtual void getPositionFromObserverObject( DtOsgObserverObject& observerObject, osg::Vec3d& position ) const;
962 
965  virtual bool getPartPositionOriFromSceneObject( DtSceneObject& sceneObject,
966  int partId, osg::Vec3d& position, osg::Quat& ori ) const;
967 
970  virtual void force2D();
971 
973  virtual void dimensionChanged( bool is2D );
974  virtual void setIs2D( bool is2D );
975 
977  virtual double calculate3DAltitude() const;
978 
980  virtual void calculateAltitude();
981 
984  virtual double zoomFromAltitude( double altitude );
985 
988  virtual double zoomFromHeightAboveTerrain( double hat );
989 
990  virtual double calcEarthRadiusAtLocalCoord( const osg::Vec3d& local ) const;
991 
992  // Sends the location of the observer on the master to all others; only used
993  // if different
994  virtual void synchronizeLocation( double x, double y, double z );
995 
996  // Sends the orientation of the observer on the master to all others; only used
997  // if different
998  virtual void synchronizeOrientation( double x, double y, double z, double w );
999 
1000  virtual void calcHeightAboveTerrain();
1001 
1002  // Utility function that returns the list of channels whose observer is
1003  // this observer
1004  std::list<DtChannel*> findChannels();
1005 
1006  // This is calculated based on channel parameters. It replaces the old
1007  // theZoomAltitudeConstant, which was an approximation
1008  double heightToZoomRatio();
1009 
1010  protected:
1011 
1012  static const double theObserverBoundingSphere;
1014 
1015  static const double theMaxTerrainRetryTime;
1016 
1017  // below this altitude, ignore myConstrainToCenter
1018  static const double theCenterConstrainHeight;
1019 
1020  // Zoom won't get any smaller than this
1021  static const double theMinViewResolution;
1022 
1023  // Zoom won't get any larger than this
1024  static const double theMaxViewResolution;
1025 
1026 
1027  protected:
1028 
1029  std::vector<DtUniqueID> myCurrentAttachments;
1030  std::vector<DtUniqueID> mySecondaryAttachments;
1032 
1035 
1036  //
1038  //
1047 
1050 
1053 
1056 
1059 
1062 
1064 
1066 
1068  osg::Vec3d myDragMove;
1069 
1071 
1072  osg::Vec3d myOrbitAdvance;
1073 
1079 
1082 
1085  osg::Quat myMasterRotation;
1086 
1089 
1092 
1097 
1100 
1103 
1106 
1110 
1111  //bool myGlobeObserverMode;
1113 
1116 
1118  {
1119  public:
1120 
1122  {
1123  Stopped = 0,
1124  Forward = 1,
1125  Backward = 2,
1126  Left = 4,
1127  Right = 8,
1128  Up = 16,
1129  Down = 32
1130  };
1131 
1133  : myState(Stopped)
1134  {
1135  }
1136 
1138  inline void applyMovement(double linearDistance)
1139  {
1140  if(moving(Right)) myAdvance[0] += linearDistance;
1141  if(moving(Left)) myAdvance[0] -= linearDistance;
1142  if(moving(Forward)) myAdvance[1] += linearDistance;
1143  if(moving(Backward)) myAdvance[1] -= linearDistance;
1144  if(moving(Up)) myAdvance[2] += linearDistance;
1145  if(moving(Down)) myAdvance[2] -= linearDistance;
1146  }
1147 
1149  inline const osg::Vec3d& advance() const
1150  {
1151  return myAdvance;
1152  }
1153 
1154  inline void stop()
1155  {
1156  myState = Stopped;
1157  myAdvance.set(0.0,0.0,0.0);
1158  myEuler.set(0.0,0.0,0.0);
1159  }
1160 
1161  inline void clearAdvance()
1162  {
1163  myAdvance.set(0.0,0.0,0.0);
1164  }
1165 
1166  inline bool stopped()
1167  {
1168  return myState == Stopped;
1169  }
1170 
1171  inline bool moving() const
1172  {
1173  return myState != Stopped;
1174  }
1175 
1176  inline bool moving(Direction d) const
1177  {
1178  return (myState & d) != 0;
1179  }
1180 
1181  inline void setMoving(Direction d, bool moving)
1182  {
1183  myState = moving ? myState | d : myState & ~d;
1184  }
1185 
1186  enum Angle
1187  {
1188  YawLeft = 1,
1189  YawRight = 2,
1190  PitchUp = 4,
1191  PitchDown = 8,
1192  RollLeft = 16,
1193  RollRight = 32
1194  };
1195 
1196  inline void applyRotation(double angle)
1197  {
1198  if(rotating(YawRight)) myEuler[0] -= angle;
1199  if(rotating(YawLeft)) myEuler[0] += angle;
1200  if(rotating(PitchUp)) myEuler[1] += angle;
1201  if(rotating(PitchDown)) myEuler[1] -= angle;
1202  if(rotating(RollRight)) myEuler[2] += angle;
1203  if(rotating(RollLeft)) myEuler[2] -= angle;
1204  }
1205 
1206  inline const osg::Vec3d& euler() const
1207  {
1208  return myEuler;
1209  }
1210 
1211  inline osg::Vec3d& euler()
1212  {
1213  return myEuler;
1214  }
1215 
1216  inline void level()
1217  {
1218  myEuler.set(0.0,0.0,0.0);
1219  }
1220 
1221  inline bool rotating() const
1222  {
1223  return myState != Stopped;
1224  }
1225 
1226  inline bool rotating( Angle d ) const
1227  {
1228  return (myState & d) != 0;
1229  }
1230 
1231  inline void setRotating( Angle d, bool rotating )
1232  {
1233  myState = rotating ? myState | d : myState & ~d;
1234  }
1235 
1236  protected:
1237 
1241  osg::Vec3d myAdvance;
1242  osg::Vec3d myEuler;
1243 
1244  unsigned char myState;
1245  };
1246 
1251 
1256 
1258 
1263 
1267 
1273 
1277 
1278  //
1287 
1291 
1295 
1297  osg::Vec3d myCameraOffset;
1299  osg::Quat myCameraRotation;
1300 
1301  osg::Vec3d myObserverWorldUp;
1304 
1305  osg::Vec3d myAttachedWorldUp;
1308 
1309  osg::Vec3d myObserverUp;
1310  osg::Vec3d myObserverFront;
1311  osg::Vec3d myObserverRight;
1312 
1313  osg::Vec3d myLevelObserverUp;
1316 
1317  osg::Vec3d myAttachedUp;
1318  osg::Vec3d myAttachedFront;
1319  osg::Vec3d myAttachedRight;
1320 
1321  osg::Vec3d myLevelAttachedUp;
1324 
1328 
1332 
1333  osg::Vec3d myCameraUp;
1334  osg::Vec3d myCameraFront;
1335  osg::Vec3d myCameraRight;
1336 
1339 
1344 
1346 
1349 
1352 
1361  // force an orientation reset AFTER the next time the observer position is updated
1362  // Needed when making large attach jumps
1364 
1366 
1368  osg::Vec3d myViewIntersect;
1369 
1371  osg::Vec3d myDownIntersect;
1372 
1373  osg::Vec3d myAttachPosition;
1374 
1377 
1381 
1382  double myAltitude;
1383 
1388 
1392 
1393  typedef boost::unordered_map<DtElementID, bool> ElementVisibilityMap;
1395 
1396  // Paged terrain initialization
1403 
1404  // Used for speed scaling, this is the same as myHeightAboveTerrain
1405  // when unattached, but the distance from the attached entity when
1406  // attached
1408 
1409  // curvature adjustment
1413 
1414  osg::Quat myCameraShakeRot;
1415 
1417  };
1418 
1419 }

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)