VR-Forces 4.3.1 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) 2013 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 class DtVector;
28 
29 namespace osg
30 {
31  class Node;
32 }
33 
34 namespace makVrv
35 {
36  class DtChannel;
37  class DtOsgChannel;
39  class DtSceneObject;
40  class DtTerrainPatchObject;
41  class DtAgentUpdateResolverInterface;
42 
47  {
48 
49  public:
50 
52  {
53  TerrainResultNoData = 0,
55  TerrainResultComplete
56  };
57 
59  DtOsgObserverObject( DtDe& de, DtUniqueID id, const std::string& name="" );
60 
62  virtual ~DtOsgObserverObject();
63 
65  virtual void tick( double simTime );
66 
68  virtual void tickAttachment();
69 
72  virtual void setModelSet( int modelSet );
73 
75  virtual double altitude() const;
76 
77  virtual void setNameAndRegister( const std::string& name );
78 
79  virtual void getCameraPositionAndOrientation( osg::Vec3d& position,
80  osg::Quat& rotation ) const;
81 
83  static void matrixdToTaitBryan( const osg::Matrixd& mat, DtTaitBryan& tb, bool isWorld2D = false );
84  static double clampUnity( double x );
85 
86 
87  //
88  //
90  //
91  //
92 
94 
95 
96  virtual void startMoveObserverRight();
97  virtual void stopMoveObserverRight();
98  virtual void moveObserverRight( double meters );
99 
101 
102 
103  virtual void startMoveObserverForward();
104  virtual void stopMoveObserverForward();
105  virtual void moveObserverForward( double meters );
107 
109 
110 
111  virtual void startMoveObserverUp();
112  virtual void stopMoveObserverUp();
113  virtual void moveObserverUp( double meters );
115 
117 
118 
119  virtual void startMoveObserverLeft();
120  virtual void stopMoveObserverLeft();
121  virtual void moveObserverLeft( double meters );
123 
125 
126 
127  virtual void startMoveObserverBack();
128  virtual void stopMoveObserverBack();
129  virtual void moveObserverBack( double meters );
131 
133 
134 
135  virtual void startMoveObserverDown();
136  virtual void stopMoveObserverDown();
137  virtual void moveObserverDown( double meters );
139 
141 
142 
143 
144  virtual void startMoveLevelObserverRight();
145  virtual void stopMoveLevelObserverRight();
146  virtual void moveLevelObserverRight( double meters );
148 
150 
151 
152 
153  virtual void startMoveLevelObserverForward();
154  virtual void stopMoveLevelObserverForward();
155  virtual void moveLevelObserverForward( double meters );
157 
159 
160 
161 
162  virtual void startMoveLevelObserverUp();
163  virtual void stopMoveLevelObserverUp();
164  virtual void moveLevelObserverUp( double meters );
166 
168 
169 
170 
171  virtual void startMoveLevelObserverLeft();
172  virtual void stopMoveLevelObserverLeft();
173  virtual void moveLevelObserverLeft( double meters );
175 
177 
178 
179 
180  virtual void startMoveLevelObserverBack();
181  virtual void stopMoveLevelObserverBack();
182  virtual void moveLevelObserverBack( double meters );
184 
186 
187 
188  virtual void startMoveLevelObserverDown();
189  virtual void stopMoveLevelObserverDown();
190  virtual void moveLevelObserverDown( double meters );
192 
194 
195 
196  virtual void startMoveAttachedRight();
197  virtual void stopMoveAttachedRight();
198  virtual void moveAttachedRight( double meters );
199 
201 
202 
203  virtual void startMoveAttachedForward();
204  virtual void stopMoveAttachedForward();
205  virtual void moveAttachedForward( double meters );
207 
209 
210 
211  virtual void startMoveAttachedUp();
212  virtual void stopMoveAttachedUp();
213  virtual void moveAttachedUp( double meters );
215 
217 
218 
219  virtual void startMoveAttachedLeft();
220  virtual void stopMoveAttachedLeft();
221  virtual void moveAttachedLeft( double meters );
223 
225 
226 
227  virtual void startMoveAttachedBack();
228  virtual void stopMoveAttachedBack();
229  virtual void moveAttachedBack( double meters );
231 
233 
234 
235  virtual void startMoveAttachedDown();
236  virtual void stopMoveAttachedDown();
237  virtual void moveAttachedDown( double meters );
239 
241 
242 
243 
244  virtual void startMoveLevelAttachedRight();
245  virtual void stopMoveLevelAttachedRight();
246  virtual void moveLevelAttachedRight( double meters );
248 
250 
251 
252 
253  virtual void startMoveLevelAttachedForward();
254  virtual void stopMoveLevelAttachedForward();
255  virtual void moveLevelAttachedForward( double meters );
257 
259 
260 
261 
262  virtual void startMoveLevelAttachedUp();
263  virtual void stopMoveLevelAttachedUp();
264  virtual void moveLevelAttachedUp( double meters );
266 
268 
269 
270 
271  virtual void startMoveLevelAttachedLeft();
272  virtual void stopMoveLevelAttachedLeft();
273  virtual void moveLevelAttachedLeft( double meters );
275 
277 
278 
279 
280  virtual void startMoveLevelAttachedBack();
281  virtual void stopMoveLevelAttachedBack();
282  virtual void moveLevelAttachedBack( double meters );
284 
286 
287 
288  virtual void startMoveLevelAttachedDown();
289  virtual void stopMoveLevelAttachedDown();
290  virtual void moveLevelAttachedDown( double meters );
292 
294 
295 
296  virtual void startMoveAttachedContextRight();
297  virtual void stopMoveAttachedContextRight();
298  virtual void moveAttachedContextRight( double meters );
300 
302 
303 
304  virtual void startMoveAttachedContextForward();
305  virtual void stopMoveAttachedContextForward();
306  virtual void moveAttachedContextForward( double meters );
308 
310 
311 
312  virtual void startMoveAttachedContextUp();
313  virtual void stopMoveAttachedContextUp();
314  virtual void moveAttachedContextUp( double meters );
316 
318 
319 
320  virtual void startMoveAttachedContextLeft();
321  virtual void stopMoveAttachedContextLeft();
322  virtual void moveAttachedContextLeft( double meters );
324 
326 
327 
328  virtual void startMoveAttachedContextBack();
329  virtual void stopMoveAttachedContextBack();
330  virtual void moveAttachedContextBack( double meters );
332 
334 
335  virtual void startMoveAttachedContextDown();
336  virtual void stopMoveAttachedContextDown();
337  virtual void moveAttachedContextDown( double meters );
339 
341 
342 
343  virtual void startYawLeft();
344  virtual void stopYawLeft();
346 
348 
349 
350 
351  virtual void startYawRight();
352  virtual void stopYawRight();
354 
356 
357 
358  virtual void startPitchUp();
359  virtual void stopPitchUp();
360  virtual void rotatePitchUp( double rads );
361  virtual void rotateFlashlightPitchUp( double rads );
363 
365 
366 
367  virtual void startPitchDown();
368  virtual void stopPitchDown();
369  virtual void rotatePitchDown( double rads );
370  virtual void rotateFlashlightPitchDown( double rads );
372 
374 
375 
376  virtual void startRollLeft();
377  virtual void stopRollLeft();
379 
381 
382 
383  virtual void startRollRight();
384  virtual void stopRollRight();
386 
388 
389 
390  virtual void startLevelYawLeft();
391  virtual void stopLevelYawLeft();
393 
395 
396 
397 
398  virtual void startLevelYawRight();
399  virtual void stopLevelYawRight();
401 
403 
404 
405  virtual void startLevelPitchUp();
406  virtual void stopLevelPitchUp();
408 
410 
411 
412  virtual void startLevelPitchDown();
413  virtual void stopLevelPitchDown();
415 
417 
418 
419  virtual void startLevelRollLeft();
420  virtual void stopLevelRollLeft();
422 
424 
425 
426  virtual void startLevelRollRight();
427  virtual void stopLevelRollRight();
429 
430  virtual void rotateLevelYawLeft( double rads );
431  virtual void rotateLevelYawRight( double rads );
432  virtual void rotateFlashlightYawLeft( double rads );
433  virtual void rotateFlashlightYawRight( double rads );
434 
435  virtual void startLookLeft();
436  virtual void stopLookLeft();
437  virtual void lookLeft( double rads );
438 
439  virtual void startLookRight();
440  virtual void stopLookRight();
441  virtual void lookRight( double rads );
442 
443  virtual void startLookUp();
444  virtual void stopLookUp();
445  virtual void lookUp( double rads );
446 
447  virtual void startLookDown();
448  virtual void stopLookDown();
449  virtual void lookDown( double rads );
450 
451  virtual void startLookTiltRight();
452  virtual void stopLookTiltRight();
453  virtual void lookTiltRight( double rads );
454 
455  virtual void startLookTiltLeft();
456  virtual void stopLookTiltLeft();
457  virtual void lookTiltLeft( double rads );
458 
460 
461 
462  virtual void startOrbitingLeft();
463  virtual void stopOrbitingLeft();
464  virtual void orbitLeft( double rads );
466 
468 
469 
470  virtual void startOrbitingRight();
471  virtual void stopOrbitingRight();
472  virtual void orbitRight( double rads );
474 
476 
477 
478  virtual void startOrbitingUp();
479  virtual void stopOrbitingUp();
480  virtual void orbitUp( double rads );
482 
484 
485 
486  virtual void startOrbitingDown();
487  virtual void stopOrbitingDown();
488  virtual void orbitDown( double rads );
490 
492  virtual void setLocation( double x, double y, double z);
493 
497  virtual void setAttachedLocation( double x, double y, double z );
498 
500  virtual void setOrientation( double psi, double theta, double phi );
501 
503  virtual void setTopographicOrientation( double psi, double theta, double phi );
504 
506  virtual void setOrientation( double x, double y, double z, double w);
507 
509  virtual void setAttachedOrientation( double psi, double theta, double phi );
510 
512  virtual void setAttachedOrientation( double x, double y, double z,
513  double w);
514 
517  void setLocalModelScalingEnabled( bool enabled );
518 
521  void setLocalModelScalingAmount( float amount );
522 
525  virtual void jumpTo( double x, double y, double z );
526 
528  virtual void jumpTo( DtUniqueID elementID );
529 
530  virtual void orientTo( double x, double y, double z );
531 
533  virtual void dragTerrain( double lastX, double lastY, double lastZ,
534  double currX, double currY, double currZ );
535 
536  virtual void dragTerrain2( double myStartDragX, double myStartDragY,
537  double myStartDragZ, int deltaMouseX, int deltaMouseY );
538 
539  virtual void dragGravityUp( double windowUnits );
540  virtual void dragGravityDown( double windowUnits );
541  virtual void dragGravityLeft( double windowUnits );
542  virtual void dragGravityRight( double windowUnits );
543  virtual void scrollObserverForward( int wheelUnits );
544  virtual void scrollObserverBack( int wheelUnits );
545  virtual void scrollLevelObserverForward( int wheelUnits );
546  virtual void scrollLevelObserverBack( int wheelUnits );
547 
548  virtual void scrollFlashlightWider( int wheelUnits );
549  virtual void scrollFlashlightNarrower( int wheelUnits );
550 
552  virtual float flashlightAngle();
553 
554  //{@
556  virtual void startIncreasingViewResolution();
557  virtual void stopIncreasingViewResolution();
558  virtual void increaseViewResolution();
559 
560  virtual void startDecreasingViewResolution();
561  virtual void stopDecreasingViewResolution();
562  virtual void decreaseViewResolution();
563 
564  // Sets the view resolution in meters per pixel.
565  virtual void setViewResolution( double resolution);
566 
567  // Get the current view resolution.
568  virtual double viewResolution() const;
569 
571  virtual void setViewMagnification( double mag );
572 
574  virtual double viewMagnification() const;
575 
577 
578  //
580  //
581 
583  virtual void setOrbitSpeed( double speed );
584 
586  virtual void setLinearSpeed( double speed );
587 
589  virtual void setRotationSpeed( double speed );
590 
592  virtual void setMinLinearSpeed( double minSpeed );
593 
595  virtual void setLinearScaledSpeedGain( double gain );
596 
602  virtual void gotoTerrainCenter( DtUniqueID terrainPatch, bool retry );
603 
605  virtual void resetAttachment();
606 
607  virtual void resetOrientation();
608 
610  virtual void resetCamera();
611  virtual void level();
612 
613  virtual void stopAll();
614 
615  virtual void attachToObjects( const std::vector<DtUniqueID>& elementIds );
616  virtual void setSecondaryAttachment( const std::vector<DtUniqueID>& elementIds );
617  virtual void attachToPart( int partId);
618  virtual void detach();
619  virtual void setAttachType( DtObserverObject::AttachType type );
620  virtual void setHideModelOnAttach( bool hide );
621 
625  virtual void setAttachmentHas3DCockpit( bool cockpit );
626 
627  virtual void scaleCurrentAttachments( bool scaled );
628  virtual void setOrientToTargetConstraint( bool orient );
629  virtual void setOrbiting( bool orbit );
630  virtual void setOrientCameraToTargetConstraint( bool orient );
631 
632  virtual void setConstrainToTerrain( bool trueFalse );
633  virtual void setConstrainToCenter( bool trueFalse );
634 
637  virtual void suppressConstrainToTerrain( bool trueFalse );
638 
639  virtual void setSpeedScaling( bool trueFalse );
640 
642  virtual void setSpeedScaledSpeed( double speed );
643 
644  virtual void getLocation( double &x, double &y, double& z ) const;
645 
647  virtual void getOrientation( double& psi, double& theta, double& phi ) const;
648 
650  virtual void getTopographicOrientation( double& psi, double& theta, double& phi ) const;
651 
652  virtual void getOrientation( double& x, double& y, double& z, double& w ) const;
653 
654  virtual void getFlashlightOrientation( double& x, double& y, double& z, double& w ) const;
655 
656  virtual void getCameraUp(double& x, double& y, double& z);
657 
658  virtual void getCameraFront(double& x, double& y, double& z);
659 
660  virtual void getCameraRight(double& x, double& y, double& z);
661 
663  virtual void setCameraShakeRotation(double x, double y, double z, double w);
664 
666  virtual void getCameraShakeRotation(double& x, double& y, double& z, double& w);;
667 
671  virtual double fixed2DAltitude();
672 
675  virtual double heightAboveTerrainFromCurrentZoom();
676 
679  virtual double topographicHeading() const;
680 
682  virtual void getLinearVelocity(double &x, double &y, double &z) const;
683 
685  virtual void getRotationalVelocity( double& x, double& y, double& z) const;
686 
690  virtual void setModeSetting( int setting, bool value );
691 
693  virtual std::vector<DtUniqueID> currentAttachments() const;
694 
698  virtual DtObserverObject::AttachType attachType3D() const;
699 
703  virtual DtObserverObject::AttachType attachType2D() const;
704 
706  virtual bool attachedObjectHidden() const;
707 
711  virtual bool attachmentHas3DCockpit() const;
712 
715  virtual osg::Vec3d attachedOffsetVector() const;
716 
721  virtual double attachedNearClipOffset() const;
722 
724  virtual double heightAboveTerrain() const;
725  private:
726 
729 
731  DtOsgObserverObject& operator=( const DtOsgObserverObject& );
732 
733  protected:
734 
736  virtual bool shouldOrientToGlobeCenter();
737 
739  virtual void adjustToGlobeCurvature();
740 
742  virtual bool shouldRotateGlobe();
743 
746  virtual double zoomFromCurrentAltitude();
747 
750  virtual double altitudeFromCurrentZoom();
751 
752  virtual void calcObserverWorldVectors();
753  virtual const osg::Vec3d& observerWorldUp() const;
754  virtual const osg::Vec3d& observerWorldNorth() const;
755  virtual const osg::Vec3d& observerWorldEast() const;
756 
757  virtual const osg::Vec3d& attachedWorldUp() const;
758 
759  virtual osg::Vec3d& observerUp();
760  virtual osg::Vec3d& observerFront();
761  virtual osg::Vec3d& observerRight();
762  virtual void observerBasis(osg::Vec3d& up, osg::Vec3d& front, osg::Vec3d& right);
763 
764  virtual osg::Vec3d& attachedUp();
765  virtual osg::Vec3d& attachedFront();
766  virtual osg::Vec3d& attachedRight();
767 
768  virtual osg::Vec3d& attachedOffsetUp();
769  virtual osg::Vec3d& attachedOffsetFront();
770  virtual osg::Vec3d& attachedOffsetRight();
771 
773  virtual osg::Vec3d& levelAttachedUp();
774  virtual osg::Vec3d& levelAttachedFront();
775  virtual osg::Vec3d& levelAttachedRight();
776 
778  virtual osg::Vec3d& levelObserverMimicUp();
779  virtual osg::Vec3d& levelObserverMimicFront();
780  virtual osg::Vec3d& levelObserverMimicRight();
781 
782  virtual osg::Vec3d& cameraUp();
783  virtual osg::Vec3d& cameraFront();
784  virtual osg::Vec3d& cameraRight();
785 
786  virtual osg::Vec3d& levelObserverUp();
787  virtual osg::Vec3d& levelObserverFront();
788  virtual osg::Vec3d& levelObserverRight();
789 
790  virtual void advanceOrbitLeft( double rads );
791  virtual void advanceOrbitRight( double rads );
792  virtual void advanceOrbitUp( double rads );
793  virtual void advanceOrbitDown( double rads );
794 
795  virtual void makeLevelObserverMatrix();
796 
798  virtual void calculateLevelAttachedRotation();
799 
801  virtual void makeLevelObserverMimicMatrix();
802 
806  virtual osg::Vec3d calcWorldPositionChange();
807 
808  virtual osg::Vec3d calcMimicPositionChange();
809 
810  virtual osg::Vec3d calcAttachedPosition(const osg::Quat& attInverse, const osg::Vec3d& attachedAdvance);
811  virtual osg::Vec3d calcAttachedAdvance(osg::Quat tetherTrackInverse);
812 
813  virtual osg::Vec3d calcFollowPositionChange();
814  virtual osg::Vec3d calcSpaceFollowPositionChange();
815  virtual osg::Vec3d calcTetherPositionChange();
816  virtual osg::Vec3d calcTetherTrackPositionChange();
817 
818  virtual osg::Vec3d calcTrackPositionChange();
819  virtual osg::Quat calcTetherTrackRotation();
820 
821  virtual osg::Quat calcFlashlightOrientationChange();
822  virtual osg::Quat calcWorldOrientationChange();
823  virtual osg::Quat calcTetherOrientationChange();
824  virtual osg::Quat calcMimicOrientationChange();
825  virtual osg::Quat calcFollowOrientationChange();
826 
827  virtual void setCurrentAttachmentsVisibility( bool visible );
828 
835 
838  virtual void orientTo( const osg::Vec3d& target );
839 
841  virtual void orientCameraTo( const osg::Vec3d& target );
842 
843  virtual TerrainResult getTerrainCenter( const DtUniqueID& patchID, osg::Vec3d& center );
844 
845  virtual DtCoordinateConverter& coordinateConverter();
846  virtual const DtCoordinateConverter& coordinateConverter() const;
847 
848  virtual void initializeAttachment();
849 
850  virtual void getScalingIntersection();
851  virtual void getViewIntersection();
852 
854  virtual double linearSpeed();
855 
857  virtual double speedScalingGain() const;
858 
859  virtual void calcTerrainConstraint( osg::Vec3d prev );
860 
866  virtual bool updateAttachPositionAndOrientation();
867 
868  virtual bool getSecondaryAttachPosition( osg::Vec3d& position );
869 
870  virtual void getObserverOffsetVector( double& x, double& y, double& z ) const;
871  virtual void setObserverOffsetVector( double x, double y, double z );
872 
873  virtual void getAttachedRotationOffset( double& x, double& y, double& z, double& w ) const;
874  virtual void setAttachedRotationOffset( double x, double y, double z,
875  double w );
876 
877  virtual void getBoundingVolume( DtSceneObject& sceneObject,
878  osg::Vec3& bvolExtents, osg::Vec3d& bvolCenter );
879 
880  virtual void getBoundingVolume( DtTerrainPatchObject& patchObject,
881  osg::Vec3& bvolExtents, osg::Vec3d& bvolCenter );
882 
883  virtual void setLocation( const osg::Vec3d& location, bool suppress=true );
884 
885  virtual bool isMoving() const;
886  virtual bool isRotating() const;
887 
888  virtual double computeNearClipDistance( DtSceneObject* sceneObject );
889  virtual float computeLocalModelScalingAmount( DtSceneObject* sceneObject );
890 
891  virtual void calcScaledSpeed();
892  virtual bool getTerrainOrPropIntersection( const osg::Vec3d& startPos,
893  const osg::Vec3d& endPos, osg::Vec3d& result ) const;
894 
896  virtual DtSceneObject* findSceneObjectFromElement(const DtElementID& id);
897 
899  virtual DtTerrainPatchObject* findTerrainPatchObjectFromElement( const DtElementID& id );
900 
901  virtual void getPositionAndOrientation( DtSceneObject& sceneObject, osg::Vec3d& position,
902  osg::Vec3d& orientToPosition, osg::Quat& orientation );
903 
904  virtual void getPositionAndOrientation( DtTerrainPatchObject& patchObject, osg::Vec3d& position,
905  osg::Vec3d& orientToPosition, osg::Quat& orientation );
906 
908  virtual void getPositionFromSceneObject( DtSceneObject& sceneObject, osg::Vec3d& position ) const;
909 
912  virtual bool getPartPositionOriFromSceneObject( DtSceneObject& sceneObject,
913  int partId, osg::Vec3d& position, osg::Quat& ori ) const;
914 
917  virtual void force2D();
918 
920  virtual void dimensionChanged( bool is2D );
921  virtual void setIs2D( bool is2D );
922 
924  virtual double calculate3DAltitude() const;
925 
927  virtual void calculateAltitude();
928 
931  virtual double zoomFromAltitude( double altitude );
932 
935  virtual double zoomFromHeightAboveTerrain( double hat );
936 
937  virtual double calcEarthRadiusAtLocalCoord( const osg::Vec3d& local ) const;
938 
939  // Sends the location of the observer on the master to all others; only used
940  // if different
941  virtual void synchronizeLocation( double x, double y, double z );
942 
943  // Sends the orientation of the observer on the master to all others; only used
944  // if different
945  virtual void synchronizeOrientation( double x, double y, double z, double w );
946 
947  virtual void calcHeightAboveTerrain();
948 
949  // Utility function that returns the list of channels whose observer is
950  // this observer
951  std::list<DtChannel*> findChannels();
952 
953  // This is calculated based on channel parameters. It replaces the old
954  // theZoomAltitudeConstant, which was an approximation
955  double heightToZoomRatio();
956 
957  protected:
958 
959  static const double theObserverBoundingSphere;
961 
962  static const double theMaxTerrainRetryTime;
963 
964  // below this altitude, ignore myConstrainToCenter
965  static const double theCenterConstrainHeight;
966 
967  // Zoom won't get any smaller than this
968  static const double theMinViewResolution;
969 
970  // Zoom won't get any larger than this
971  static const double theMaxViewResolution;
972 
973 
974  protected:
975 
976  std::vector<DtUniqueID> myCurrentAttachments;
977  std::vector<DtUniqueID> mySecondaryAttachments;
979 
980  bool myChanged;
982 
983  //
985  //
994 
997 
1000 
1003 
1006 
1009 
1011 
1013 
1015  osg::Vec3d myDragMove;
1016 
1018 
1019  osg::Vec3d myOrbitAdvance;
1020 
1026 
1029 
1032  osg::Quat myMasterRotation;
1033 
1036 
1039 
1044 
1047 
1050 
1053 
1057 
1058  //bool myGlobeObserverMode;
1061 
1064 
1066  {
1067  public:
1068 
1070  {
1071  Stopped = 0,
1072  Forward = 1,
1073  Backward = 2,
1074  Left = 4,
1075  Right = 8,
1076  Up = 16,
1077  Down = 32
1078  };
1079 
1081  : myState(Stopped)
1082  {
1083  }
1084 
1086  inline void applyMovement(double linearDistance)
1087  {
1088  if(moving(Right)) myAdvance[0] += linearDistance;
1089  if(moving(Left)) myAdvance[0] -= linearDistance;
1090  if(moving(Forward)) myAdvance[1] += linearDistance;
1091  if(moving(Backward)) myAdvance[1] -= linearDistance;
1092  if(moving(Up)) myAdvance[2] += linearDistance;
1093  if(moving(Down)) myAdvance[2] -= linearDistance;
1094  }
1095 
1097  inline const osg::Vec3d& advance() const
1098  {
1099  return myAdvance;
1100  }
1101 
1102  inline void stop()
1103  {
1104  myState = Stopped;
1105  myAdvance.set(0.0,0.0,0.0);
1106  myEuler.set(0.0,0.0,0.0);
1107  }
1108 
1109  inline void clearAdvance()
1110  {
1111  myAdvance.set(0.0,0.0,0.0);
1112  }
1113 
1114  inline bool stopped()
1115  {
1116  return myState == Stopped;
1117  }
1118 
1119  inline bool moving() const
1120  {
1121  return myState != Stopped;
1122  }
1123 
1124  inline bool moving(Direction d) const
1125  {
1126  return (myState & d) != 0;
1127  }
1128 
1129  inline void setMoving(Direction d, bool moving)
1130  {
1131  myState = moving ? myState | d : myState & ~d;
1132  }
1133 
1134  enum Angle
1135  {
1136  YawLeft = 1,
1137  YawRight = 2,
1138  PitchUp = 4,
1139  PitchDown = 8,
1140  RollLeft = 16,
1141  RollRight = 32
1142  };
1143 
1144  inline void applyRotation(double angle)
1145  {
1146  if(rotating(YawRight)) myEuler[0] -= angle;
1147  if(rotating(YawLeft)) myEuler[0] += angle;
1148  if(rotating(PitchUp)) myEuler[1] += angle;
1149  if(rotating(PitchDown)) myEuler[1] -= angle;
1150  if(rotating(RollRight)) myEuler[2] += angle;
1151  if(rotating(RollLeft)) myEuler[2] -= angle;
1152  }
1153 
1154  inline const osg::Vec3d& euler() const
1155  {
1156  return myEuler;
1157  }
1158 
1159  inline osg::Vec3d& euler()
1160  {
1161  return myEuler;
1162  }
1163 
1164  inline void level()
1165  {
1166  myEuler.set(0.0,0.0,0.0);
1167  }
1168 
1169  inline bool rotating() const
1170  {
1171  return myState != Stopped;
1172  }
1173 
1174  inline bool rotating( Angle d ) const
1175  {
1176  return (myState & d) != 0;
1177  }
1178 
1179  inline void setRotating( Angle d, bool rotating )
1180  {
1181  myState = rotating ? myState | d : myState & ~d;
1182  }
1183 
1184  protected:
1185 
1189  osg::Vec3d myAdvance;
1190  osg::Vec3d myEuler;
1191 
1192  unsigned char myState;
1193  };
1194 
1199 
1204 
1206 
1211 
1215 
1221 
1225 
1226  //
1235 
1239 
1243 
1245  osg::Vec3d myCameraOffset;
1247  osg::Quat myCameraRotation;
1248 
1249  osg::Vec3d myObserverWorldUp;
1252 
1253  osg::Vec3d myAttachedWorldUp;
1256 
1257  osg::Vec3d myObserverUp;
1258  osg::Vec3d myObserverFront;
1259  osg::Vec3d myObserverRight;
1260 
1261  osg::Vec3d myLevelObserverUp;
1264 
1265  osg::Vec3d myAttachedUp;
1266  osg::Vec3d myAttachedFront;
1267  osg::Vec3d myAttachedRight;
1268 
1269  osg::Vec3d myLevelAttachedUp;
1272 
1276 
1280 
1281  osg::Vec3d myCameraUp;
1282  osg::Vec3d myCameraFront;
1283  osg::Vec3d myCameraRight;
1284 
1287 
1292 
1294 
1297 
1300 
1309  // force an orientation reset AFTER the next time the observer position is updated
1310  // Needed when making large attach jumps
1312 
1314 
1316  osg::Vec3d myViewIntersect;
1317 
1319  osg::Vec3d myDownIntersect;
1320 
1321  osg::Vec3d myAttachPosition;
1322 
1325 
1329 
1330  double myAltitude;
1331 
1336 
1340 
1341  typedef boost::unordered_map<DtElementID, bool> ElementVisibilityMap;
1343 
1344  // Paged terrain initialization
1351 
1352  // Used for speed scaling, this is the same as myHeightAboveTerrain
1353  // when unattached, but the distance from the attached entity when
1354  // attached
1356 
1357  // curvature adjustment
1361 
1362  osg::Quat myCameraShakeRot;
1363  };
1364 
1365 }

Document ID: Generated on Wed Jul 29 00:55:00 EDT 2015 from SVN revision 155257
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)