VR-Forces Development_Version 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();
345 
347 
348 
349 
350  virtual void startYawRight();
351  virtual void stopYawRight();
353 
355 
356 
357  virtual void startPitchUp();
358  virtual void stopPitchUp();
359  virtual void rotatePitchUp( double rads );
360  virtual void rotateFlashlightPitchUp( double rads );
362 
364 
365 
366  virtual void startPitchDown();
367  virtual void stopPitchDown();
368  virtual void rotatePitchDown( double rads );
369  virtual void rotateFlashlightPitchDown( double rads );
371 
373 
374 
375  virtual void startRollLeft();
376  virtual void stopRollLeft();
378 
380 
381 
382  virtual void startRollRight();
383  virtual void stopRollRight();
385 
387 
388 
389  virtual void startLevelYawLeft();
390  virtual void stopLevelYawLeft();
392 
394 
395 
396 
397  virtual void startLevelYawRight();
398  virtual void stopLevelYawRight();
400 
402 
403 
404  virtual void startLevelPitchUp();
405  virtual void stopLevelPitchUp();
407 
409 
410 
411  virtual void startLevelPitchDown();
412  virtual void stopLevelPitchDown();
414 
416 
417 
418  virtual void startLevelRollLeft();
419  virtual void stopLevelRollLeft();
421 
423 
424 
425  virtual void startLevelRollRight();
426  virtual void stopLevelRollRight();
428 
429  virtual void rotateLevelYawLeft( double rads );
430  virtual void rotateLevelYawRight( double rads );
431  virtual void rotateFlashlightYawLeft( double rads );
432  virtual void rotateFlashlightYawRight( double rads );
433 
434  virtual void startLookLeft();
435  virtual void stopLookLeft();
436  virtual void lookLeft( double rads );
437 
438  virtual void startLookRight();
439  virtual void stopLookRight();
440  virtual void lookRight( double rads );
441 
442  virtual void startLookUp();
443  virtual void stopLookUp();
444  virtual void lookUp( double rads );
445 
446  virtual void startLookDown();
447  virtual void stopLookDown();
448  virtual void lookDown( double rads );
449 
450  virtual void startLookTiltRight();
451  virtual void stopLookTiltRight();
452  virtual void lookTiltRight( double rads );
453 
454  virtual void startLookTiltLeft();
455  virtual void stopLookTiltLeft();
456  virtual void lookTiltLeft( double rads );
457 
459 
460 
461  virtual void startOrbitingLeft();
462  virtual void stopOrbitingLeft();
463  virtual void orbitLeft( double rads );
465 
467 
468 
469  virtual void startOrbitingRight();
470  virtual void stopOrbitingRight();
471  virtual void orbitRight( double rads );
473 
475 
476 
477  virtual void startOrbitingUp();
478  virtual void stopOrbitingUp();
479  virtual void orbitUp( double rads );
481 
483 
484 
485  virtual void startOrbitingDown();
486  virtual void stopOrbitingDown();
487  virtual void orbitDown( double rads );
489 
491  virtual void setLocation( double x, double y, double z);
492 
496  virtual void setAttachedLocation( double x, double y, double z );
497 
499  virtual void setOrientation( double psi, double theta, double phi );
500 
502  virtual void setTopographicOrientation( double psi, double theta, double phi );
503 
505  virtual void setOrientation( double x, double y, double z, double w);
506 
508  virtual void setAttachedOrientation( double psi, double theta, double phi );
509 
511  virtual void setAttachedOrientation( double x, double y, double z,
512  double w);
513 
516  void setLocalModelScalingEnabled( bool enabled );
517 
520  void setLocalModelScalingAmount( float amount );
521 
524  virtual void jumpTo( double x, double y, double z );
525 
527  virtual void jumpTo( DtUniqueID elementID );
528 
529  virtual void orientTo( double x, double y, double z );
530 
532  virtual void dragTerrain( double lastX, double lastY, double lastZ,
533  double currX, double currY, double currZ );
534 
535  virtual void dragTerrain2( double myStartDragX, double myStartDragY,
536  double myStartDragZ, int deltaMouseX, int deltaMouseY );
537 
538  virtual void dragGravityUp( double windowUnits );
539  virtual void dragGravityDown( double windowUnits );
540  virtual void dragGravityLeft( double windowUnits );
541  virtual void dragGravityRight( double windowUnits );
542  virtual void scrollObserverForward( int wheelUnits );
543  virtual void scrollObserverBack( int wheelUnits );
544  virtual void scrollLevelObserverForward( int wheelUnits );
545  virtual void scrollLevelObserverBack( int wheelUnits );
546 
547  virtual void scrollFlashlightWider( int wheelUnits );
548  virtual void scrollFlashlightNarrower( int wheelUnits );
549 
551  virtual float flashlightAngle();
552 
553  //{@
555  virtual void startIncreasingViewResolution();
556  virtual void stopIncreasingViewResolution();
557  virtual void increaseViewResolution();
558 
559  virtual void startDecreasingViewResolution();
560  virtual void stopDecreasingViewResolution();
561  virtual void decreaseViewResolution();
562 
563  // Sets the view resolution in meters per pixel.
564  virtual void setViewResolution( double resolution);
565 
566  // Get the current view resolution.
567  virtual double viewResolution() const;
568 
574  virtual void setCurrentViewMagnification( double mag );
575 
577  virtual double currentViewMagnification() const;
578 
580 
581  //
583  //
584 
586  virtual void setOrbitSpeed( double speed );
587 
589  virtual void setLinearSpeed( double speed );
590 
592  virtual void setRotationSpeed( double speed );
593 
595  virtual void setMinLinearSpeed( double minSpeed );
596 
598  virtual void setMaxLinearSpeed( double maxSpeed );
599 
601  virtual void setLinearScaledSpeedGain( double gain );
602 
608  virtual void gotoTerrainCenter( DtUniqueID terrainPatch, bool retry );
609 
611  virtual void resetAttachment();
612 
613  virtual void resetOrientation();
614 
616  virtual void resetCamera();
617  virtual void level();
618 
619  virtual void stopAll();
620 
621  virtual void attachToObjects( const std::vector<DtUniqueID>& elementIds );
622  virtual void setSecondaryAttachment( const std::vector<DtUniqueID>& elementIds );
623  virtual void setLocationTrackAttachment( const osg::Vec3d& location );
624  virtual void setLocationTrackAttachment( double x, double y, double z );
625 
626  virtual void attachToPart( int partId);
627  virtual void detach();
628  virtual void setAttachType( DtObserverObject::AttachType type );
629  virtual void setHideModelOnAttach( bool hide );
630 
634  virtual void setAttachmentHas3DCockpit( bool cockpit );
635 
636  virtual void scaleCurrentAttachments( bool scaled );
637  virtual void setOrientToTargetConstraint( bool orient );
638  virtual void setOrbiting( bool orbit );
639  virtual void setOrientCameraToTargetConstraint( bool orient );
640 
641  virtual void setConstrainToTerrain( bool trueFalse );
642  virtual void setConstrainToCenter( bool trueFalse );
643 
646  virtual void suppressConstrainToTerrain( bool trueFalse );
647 
648  virtual void setSpeedScaling( bool trueFalse );
649 
651  virtual void setSpeedScaledSpeed( double speed );
652 
653  virtual void getLocation( double &x, double &y, double& z ) const;
654 
656  virtual void getOrientation( double& psi, double& theta, double& phi ) const;
657 
659  virtual void getTopographicOrientation( double& psi, double& theta, double& phi ) const;
660 
661  virtual void getOrientation( double& x, double& y, double& z, double& w ) const;
662 
663  virtual void getFlashlightOrientation( double& x, double& y, double& z, double& w ) const;
664 
665  virtual void getCameraUp(double& x, double& y, double& z);
666 
667  virtual void getCameraFront(double& x, double& y, double& z);
668 
669  virtual void getCameraRight(double& x, double& y, double& z);
670 
672  virtual void setCameraShakeRotation(double x, double y, double z, double w);
673 
675  virtual void getCameraShakeRotation(double& x, double& y, double& z, double& w);;
676 
680  virtual double fixed2DAltitude();
681 
684  virtual double heightAboveTerrainFromCurrentZoom();
685 
688  virtual double topographicHeading() const;
689 
691  virtual void getLinearVelocity(double &x, double &y, double &z) const;
692 
694  virtual void getRotationalVelocity( double& x, double& y, double& z) const;
695 
699  virtual void setModeSetting( int setting, bool value );
700 
702  virtual std::vector<DtUniqueID> currentAttachments() const;
703 
706 
707  virtual const osg::Vec3d& locationTrackAttachmentVec3d() const;
708  virtual void getLocationTrackAttachment( double& x, double& y, double& z ) const;
710 
714  virtual DtObserverObject::AttachType attachType3D() const;
715 
719  virtual DtObserverObject::AttachType attachType2D() const;
720 
722  virtual bool attachedObjectHidden() const;
723 
727  virtual bool attachmentHas3DCockpit() const;
728 
731  virtual osg::Vec3d attachedOffsetVector() const;
732 
737  virtual double attachedNearClipOffset() const;
738 
740  virtual double heightAboveTerrain() const;
741  private:
742 
745 
747  DtOsgObserverObject& operator=( const DtOsgObserverObject& );
748 
749  protected:
750 
752  virtual bool shouldOrientToGlobeCenter();
753 
755  virtual void adjustToGlobeCurvature();
756 
758  virtual bool shouldRotateGlobe();
759 
762  virtual double zoomFromCurrentAltitude();
763 
766  virtual double altitudeFromCurrentZoom();
767 
768  virtual void calcObserverWorldVectors();
769  virtual const osg::Vec3d& observerWorldUp() const;
770  virtual const osg::Vec3d& observerWorldNorth() const;
771  virtual const osg::Vec3d& observerWorldEast() const;
772 
773  virtual const osg::Vec3d& attachedWorldUp() const;
774 
775  virtual osg::Vec3d& observerUp();
776  virtual osg::Vec3d& observerFront();
777  virtual osg::Vec3d& observerRight();
778  virtual void observerBasis(osg::Vec3d& up, osg::Vec3d& front, osg::Vec3d& right);
779 
780  virtual osg::Vec3d& attachedUp();
781  virtual osg::Vec3d& attachedFront();
782  virtual osg::Vec3d& attachedRight();
783 
784  virtual osg::Vec3d& attachedOffsetUp();
785  virtual osg::Vec3d& attachedOffsetFront();
786  virtual osg::Vec3d& attachedOffsetRight();
787 
789  virtual osg::Vec3d& levelAttachedUp();
790  virtual osg::Vec3d& levelAttachedFront();
791  virtual osg::Vec3d& levelAttachedRight();
792 
794  virtual osg::Vec3d& levelObserverMimicUp();
795  virtual osg::Vec3d& levelObserverMimicFront();
796  virtual osg::Vec3d& levelObserverMimicRight();
797 
798  virtual osg::Vec3d& cameraUp();
799  virtual osg::Vec3d& cameraFront();
800  virtual osg::Vec3d& cameraRight();
801 
802  virtual osg::Vec3d& levelObserverUp();
803  virtual osg::Vec3d& levelObserverFront();
804  virtual osg::Vec3d& levelObserverRight();
805 
806  virtual void advanceOrbitLeft( double rads );
807  virtual void advanceOrbitRight( double rads );
808  virtual void advanceOrbitUp( double rads );
809  virtual void advanceOrbitDown( double rads );
810 
811  virtual void makeLevelObserverMatrix();
812 
814  virtual void calculateLevelAttachedRotation();
815 
817  virtual void makeLevelObserverMimicMatrix();
818 
822  virtual osg::Vec3d calcWorldPositionChange();
823 
824  virtual osg::Vec3d calcMimicPositionChange();
825 
826  virtual osg::Vec3d calcAttachedPosition(const osg::Quat& attInverse, const osg::Vec3d& attachedAdvance);
827  virtual osg::Vec3d calcAttachedAdvance(osg::Quat tetherTrackInverse);
828 
829  virtual osg::Vec3d calcFollowPositionChange();
830  virtual osg::Vec3d calcSpaceFollowPositionChange();
831  virtual osg::Vec3d calcTetherPositionChange();
832  virtual osg::Vec3d calcTetherTrackPositionChange();
833 
834  virtual osg::Vec3d calcTrackPositionChange();
835  virtual osg::Quat calcTetherTrackRotation();
836 
837  virtual osg::Quat calcFlashlightOrientationChange();
838  virtual osg::Quat calcWorldOrientationChange();
839  virtual osg::Quat calcTetherOrientationChange();
840  virtual osg::Quat calcMimicOrientationChange();
841  virtual osg::Quat calcFollowOrientationChange();
842 
843  virtual void setCurrentAttachmentsVisibility( bool visible );
844 
851 
854  virtual void orientTo( const osg::Vec3d& target );
855 
857  virtual void orientCameraTo( const osg::Vec3d& target );
858 
859  virtual TerrainResult getTerrainCenter( const DtUniqueID& patchID, osg::Vec3d& center );
860 
861  virtual DtCoordinateConverter& coordinateConverter();
862  virtual const DtCoordinateConverter& coordinateConverter() const;
863 
864  virtual void initializeAttachment();
865 
866  virtual void getScalingIntersection();
867  virtual void getViewIntersection();
868 
870  virtual double linearSpeed();
871 
873  virtual double speedScalingGain() const;
874 
875  virtual void calcTerrainConstraint( osg::Vec3d prev );
876 
882  virtual bool updateAttachPositionAndOrientation();
883 
884  virtual bool getSecondaryAttachPosition( osg::Vec3d& position );
885 
886  virtual void getObserverOffsetVector( double& x, double& y, double& z ) const;
887  virtual void setObserverOffsetVector( double x, double y, double z );
888 
889  virtual void getAttachedRotationOffset( double& x, double& y, double& z, double& w ) const;
890  virtual void setAttachedRotationOffset( double x, double y, double z,
891  double w );
892 
893  virtual void getBoundingVolume( DtSceneObject& sceneObject,
894  osg::Vec3& bvolExtents, osg::Vec3d& bvolCenter );
895 
896  virtual void getBoundingVolume( DtTerrainPatchObject& patchObject,
897  osg::Vec3& bvolExtents, osg::Vec3d& bvolCenter );
898 
899  virtual void setLocation( const osg::Vec3d& location, bool suppress=true );
900 
901  virtual bool isMoving() const;
902  virtual bool isRotating() const;
903 
904  virtual double computeNearClipDistance( DtSceneObject* sceneObject );
905  virtual float computeLocalModelScalingAmount( DtSceneObject* sceneObject );
906 
907  virtual void calcScaledSpeed();
908  virtual bool getTerrainOrPropIntersection( const osg::Vec3d& startPos,
909  const osg::Vec3d& endPos, osg::Vec3d& result ) const;
910 
912  virtual DtSceneObject* findSceneObjectFromElement(const DtElementID& id);
913 
915  virtual DtTerrainPatchObject* findTerrainPatchObjectFromElement( const DtElementID& id );
916 
917  virtual void getPositionAndOrientation( DtSceneObject& sceneObject, osg::Vec3d& position,
918  osg::Vec3d& orientToPosition, osg::Quat& orientation );
919 
920  virtual void getPositionAndOrientation( DtTerrainPatchObject& patchObject, osg::Vec3d& position,
921  osg::Vec3d& orientToPosition, osg::Quat& orientation );
922 
924  virtual void getPositionFromSceneObject( DtSceneObject& sceneObject, osg::Vec3d& position ) const;
925 
928  virtual bool getPartPositionOriFromSceneObject( DtSceneObject& sceneObject,
929  int partId, osg::Vec3d& position, osg::Quat& ori ) const;
930 
933  virtual void force2D();
934 
936  virtual void dimensionChanged( bool is2D );
937  virtual void setIs2D( bool is2D );
938 
940  virtual double calculate3DAltitude() const;
941 
943  virtual void calculateAltitude();
944 
947  virtual double zoomFromAltitude( double altitude );
948 
951  virtual double zoomFromHeightAboveTerrain( double hat );
952 
953  virtual double calcEarthRadiusAtLocalCoord( const osg::Vec3d& local ) const;
954 
955  // Sends the location of the observer on the master to all others; only used
956  // if different
957  virtual void synchronizeLocation( double x, double y, double z );
958 
959  // Sends the orientation of the observer on the master to all others; only used
960  // if different
961  virtual void synchronizeOrientation( double x, double y, double z, double w );
962 
963  virtual void calcHeightAboveTerrain();
964 
965  // Utility function that returns the list of channels whose observer is
966  // this observer
967  std::list<DtChannel*> findChannels();
968 
969  // This is calculated based on channel parameters. It replaces the old
970  // theZoomAltitudeConstant, which was an approximation
971  double heightToZoomRatio();
972 
973  protected:
974 
975  static const double theObserverBoundingSphere;
977 
978  static const double theMaxTerrainRetryTime;
979 
980  // below this altitude, ignore myConstrainToCenter
981  static const double theCenterConstrainHeight;
982 
983  // Zoom won't get any smaller than this
984  static const double theMinViewResolution;
985 
986  // Zoom won't get any larger than this
987  static const double theMaxViewResolution;
988 
989 
990  protected:
991 
992  std::vector<DtUniqueID> myCurrentAttachments;
993  std::vector<DtUniqueID> mySecondaryAttachments;
995 
996  bool myChanged;
998 
999  //
1001  //
1010 
1013 
1016 
1019 
1022 
1025 
1027 
1029 
1031  osg::Vec3d myDragMove;
1032 
1034 
1035  osg::Vec3d myOrbitAdvance;
1036 
1042 
1045 
1048  osg::Quat myMasterRotation;
1049 
1052 
1055 
1060 
1063 
1066 
1069 
1073 
1074  //bool myGlobeObserverMode;
1076 
1079 
1081  {
1082  public:
1083 
1085  {
1086  Stopped = 0,
1087  Forward = 1,
1088  Backward = 2,
1089  Left = 4,
1090  Right = 8,
1091  Up = 16,
1092  Down = 32
1093  };
1094 
1096  : myState(Stopped)
1097  {
1098  }
1099 
1101  inline void applyMovement(double linearDistance)
1102  {
1103  if(moving(Right)) myAdvance[0] += linearDistance;
1104  if(moving(Left)) myAdvance[0] -= linearDistance;
1105  if(moving(Forward)) myAdvance[1] += linearDistance;
1106  if(moving(Backward)) myAdvance[1] -= linearDistance;
1107  if(moving(Up)) myAdvance[2] += linearDistance;
1108  if(moving(Down)) myAdvance[2] -= linearDistance;
1109  }
1110 
1112  inline const osg::Vec3d& advance() const
1113  {
1114  return myAdvance;
1115  }
1116 
1117  inline void stop()
1118  {
1119  myState = Stopped;
1120  myAdvance.set(0.0,0.0,0.0);
1121  myEuler.set(0.0,0.0,0.0);
1122  }
1123 
1124  inline void clearAdvance()
1125  {
1126  myAdvance.set(0.0,0.0,0.0);
1127  }
1128 
1129  inline bool stopped()
1130  {
1131  return myState == Stopped;
1132  }
1133 
1134  inline bool moving() const
1135  {
1136  return myState != Stopped;
1137  }
1138 
1139  inline bool moving(Direction d) const
1140  {
1141  return (myState & d) != 0;
1142  }
1143 
1144  inline void setMoving(Direction d, bool moving)
1145  {
1146  myState = moving ? myState | d : myState & ~d;
1147  }
1148 
1149  enum Angle
1150  {
1151  YawLeft = 1,
1152  YawRight = 2,
1153  PitchUp = 4,
1154  PitchDown = 8,
1155  RollLeft = 16,
1156  RollRight = 32
1157  };
1158 
1159  inline void applyRotation(double angle)
1160  {
1161  if(rotating(YawRight)) myEuler[0] -= angle;
1162  if(rotating(YawLeft)) myEuler[0] += angle;
1163  if(rotating(PitchUp)) myEuler[1] += angle;
1164  if(rotating(PitchDown)) myEuler[1] -= angle;
1165  if(rotating(RollRight)) myEuler[2] += angle;
1166  if(rotating(RollLeft)) myEuler[2] -= angle;
1167  }
1168 
1169  inline const osg::Vec3d& euler() const
1170  {
1171  return myEuler;
1172  }
1173 
1174  inline osg::Vec3d& euler()
1175  {
1176  return myEuler;
1177  }
1178 
1179  inline void level()
1180  {
1181  myEuler.set(0.0,0.0,0.0);
1182  }
1183 
1184  inline bool rotating() const
1185  {
1186  return myState != Stopped;
1187  }
1188 
1189  inline bool rotating( Angle d ) const
1190  {
1191  return (myState & d) != 0;
1192  }
1193 
1194  inline void setRotating( Angle d, bool rotating )
1195  {
1196  myState = rotating ? myState | d : myState & ~d;
1197  }
1198 
1199  protected:
1200 
1204  osg::Vec3d myAdvance;
1205  osg::Vec3d myEuler;
1206 
1207  unsigned char myState;
1208  };
1209 
1214 
1219 
1221 
1226 
1230 
1236 
1240 
1241  //
1250 
1254 
1258 
1260  osg::Vec3d myCameraOffset;
1262  osg::Quat myCameraRotation;
1263 
1264  osg::Vec3d myObserverWorldUp;
1267 
1268  osg::Vec3d myAttachedWorldUp;
1271 
1272  osg::Vec3d myObserverUp;
1273  osg::Vec3d myObserverFront;
1274  osg::Vec3d myObserverRight;
1275 
1276  osg::Vec3d myLevelObserverUp;
1279 
1280  osg::Vec3d myAttachedUp;
1281  osg::Vec3d myAttachedFront;
1282  osg::Vec3d myAttachedRight;
1283 
1284  osg::Vec3d myLevelAttachedUp;
1287 
1291 
1295 
1296  osg::Vec3d myCameraUp;
1297  osg::Vec3d myCameraFront;
1298  osg::Vec3d myCameraRight;
1299 
1302 
1307 
1309 
1312 
1315 
1324  // force an orientation reset AFTER the next time the observer position is updated
1325  // Needed when making large attach jumps
1327 
1329 
1331  osg::Vec3d myViewIntersect;
1332 
1334  osg::Vec3d myDownIntersect;
1335 
1336  osg::Vec3d myAttachPosition;
1337 
1340 
1344 
1345  double myAltitude;
1346 
1351 
1355 
1356  typedef boost::unordered_map<DtElementID, bool> ElementVisibilityMap;
1358 
1359  // Paged terrain initialization
1366 
1367  // Used for speed scaling, this is the same as myHeightAboveTerrain
1368  // when unattached, but the distance from the attached entity when
1369  // attached
1371 
1372  // curvature adjustment
1376 
1377  osg::Quat myCameraShakeRot;
1378 
1380  };
1381 
1382 }

Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)