osg::FlyNavigator Class Reference
[Navigators]

Navigator for simple fly model. See Fly Navigator for a description. More...

#include <OSGFlyNavigator.h>

Inheritance diagram for osg::FlyNavigator:

osg::WalkNavigator

List of all members.

Public Member Functions

Constructors


 FlyNavigator ()
Destructors


virtual ~FlyNavigator ()
Get


MatrixgetMatrix (void)
Pnt3fgetFrom (void)
Pnt3fgetAt (void)
Vec3fgetUp (void)
Set


void setFrom (Pnt3f new_from)
void setAt (Pnt3f new_at)
void setUp (Vec3f new_up)
void set (Pnt3f new_from, Pnt3f new_at, Vec3f new_up)
void set (Matrix new_matrix)
Flyer Transformations


void rotate (Real32 deltaX, Real32 deltaY)
Real32 forward (Real32 step)
Real32 right (Real32 step)

Protected Attributes

Members


Pnt3f _rFrom
Pnt3f _rAt
Vec3f _vUp
Matrix _tMatrix


Detailed Description

The FlyNavigator models a simple flying navigation model, see Fly Navigator for a description.

Definition at line 55 of file OSGFlyNavigator.h.


Constructor & Destructor Documentation

FlyNavigator::FlyNavigator (  ) 

Definition at line 83 of file OSGFlyNavigator.cpp.

References _rAt, _rFrom, _tMatrix, _vUp, and osg::TransformationMatrix< ValueTypeT >::setIdentity().

00084 {
00085     _rFrom  .setValues(0,0,0);
00086     _rAt    .setValues(0,0,1);
00087     _vUp    .setValues(0,1,0);
00088     _tMatrix.setIdentity();
00089 }

FlyNavigator::~FlyNavigator (  )  [virtual]

Definition at line 94 of file OSGFlyNavigator.cpp.

00095 {
00096 }


Member Function Documentation

Matrix & FlyNavigator::getMatrix ( void   ) 

Get the current transformation matrix.

Definition at line 102 of file OSGFlyNavigator.cpp.

References _rAt, _rFrom, _tMatrix, _vUp, and osg::MatrixLookAt().

Referenced by osg::Navigator::getMatrix().

00103 {
00104     MatrixLookAt(_tMatrix,_rFrom,_rAt,_vUp);
00105     return _tMatrix;
00106 }

Pnt3f & FlyNavigator::getFrom ( void   ) 

Get the from point.

Definition at line 110 of file OSGFlyNavigator.cpp.

References _rFrom.

Referenced by osg::Navigator::getFrom().

00111 {
00112     return _rFrom;
00113 }

Pnt3f & FlyNavigator::getAt ( void   ) 

Get the at point.

Definition at line 117 of file OSGFlyNavigator.cpp.

References _rAt.

Referenced by osg::Navigator::getAt().

00118 {
00119     return _rAt;
00120 }

Vec3f & FlyNavigator::getUp ( void   ) 

Get the up vector.

Definition at line 124 of file OSGFlyNavigator.cpp.

References _vUp.

Referenced by osg::Navigator::getUp().

00125 {
00126     return _vUp;
00127 }

void FlyNavigator::setFrom ( Pnt3f  new_from  ) 

Set the from point, the point where the viewer is (i.e the center of all transformations).

Definition at line 135 of file OSGFlyNavigator.cpp.

References _rFrom.

Referenced by osg::Navigator::setFrom().

00136 {
00137     _rFrom=new_from;
00138 }

void FlyNavigator::setAt ( Pnt3f  new_At  ) 

Sets the target point at which the viewer is looking.

Definition at line 142 of file OSGFlyNavigator.cpp.

References _rAt.

Referenced by osg::Navigator::setAt().

00143 {
00144     _rAt=new_At;
00145 }

void FlyNavigator::setUp ( Vec3f  new_up  ) 

Sets the up vector, i.e. the direction that point up on the screen.

Definition at line 149 of file OSGFlyNavigator.cpp.

References _vUp.

Referenced by osg::Navigator::setUp().

00150 {
00151     _vUp=new_up;
00152 }

void FlyNavigator::set ( Pnt3f  new_from,
Pnt3f  new_At,
Vec3f  new_up 
)

Set the position and the orientation at once.

Definition at line 156 of file OSGFlyNavigator.cpp.

References _rAt, _rFrom, and _vUp.

Referenced by osg::Navigator::set().

00157 {
00158     _rFrom=new_from;
00159     _rAt=new_At;
00160     _vUp=new_up;
00161 }

void FlyNavigator::set ( Matrix  new_matrix  ) 

Set the position and the orientation at once using a matrix.

Definition at line 165 of file OSGFlyNavigator.cpp.

References _rAt, _rFrom, and _vUp.

00166 {
00167     _rFrom= (Pnt3f) new_matrix[3];
00168     _rAt  = (Pnt3f)(new_matrix[3] - new_matrix[2]);
00169     _vUp  = (Vec3f) new_matrix[1];
00170     set(_rFrom, _rAt, _vUp);
00171 }

void FlyNavigator::rotate ( Real32  deltaX,
Real32  deltaY 
)

Rotate the viewer deltaX around the up axis and deltaY around the left/right axis. deltaX and deltaY should be between -Pi and Pi.

Reimplemented in osg::WalkNavigator.

Definition at line 178 of file OSGFlyNavigator.cpp.

References _rAt, _rFrom, _vUp, osg::VectorInterface< ValueTypeT, StorageInterfaceT >::crossThis(), osg::QuaternionBase< ValueTypeT >::getValue(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::normalize(), osg::TransformationMatrix< ValueTypeT >::setIdentity(), osg::TransformationMatrix< ValueTypeT >::setTranslate(), and osg::QuaternionBase< ValueTypeT >::setValueAsAxisRad().

Referenced by osg::Navigator::keyPress(), osg::Navigator::moveTo(), and osg::WalkNavigator::rotate().

00179 {
00180     // rotate around the up vector
00181     Matrix final,temp;
00182     Quaternion q;
00183 
00184     q.setValueAsAxisRad(_vUp,-deltaX);
00185     q.getValue(temp);
00186 
00187     final.setIdentity();
00188     final.setTranslate(_rFrom);
00189     final.mult(temp);
00190 
00191     temp.setIdentity();
00192     temp.setTranslate(-_rFrom[0],-_rFrom[1],-_rFrom[2]);
00193 
00194     final.mult(temp);
00195     final.multMatrixPnt(_rAt);
00196 
00197     // rotate around the side vector
00198     Vec3f lv = _rAt-_rFrom;
00199     lv.normalize();
00200 
00201     Vec3f sv = lv;
00202     sv.crossThis(_vUp);
00203     sv.normalize();
00204     q.setValueAsAxisRad(sv,-deltaY);
00205     q.getValue(temp);
00206 
00207     final.setIdentity();
00208     final.setTranslate(_rFrom);
00209     final.mult(temp);
00210 
00211     temp.setIdentity();
00212     temp.setTranslate(-_rFrom[0],-_rFrom[1],-_rFrom[2]);
00213 
00214     final.mult(temp);
00215     final.multMatrixPnt(_rAt);
00216 }

Real32 FlyNavigator::forward ( Real32  step  ) 

Flies forward, i.e. translation step units along the view vector.

Reimplemented in osg::WalkNavigator.

Definition at line 220 of file OSGFlyNavigator.cpp.

References _rAt, _rFrom, osg::TransformationMatrix< ValueTypeT >::multMatrixPnt(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::normalize(), osg::TransformationMatrix< ValueTypeT >::setIdentity(), and osg::TransformationMatrix< ValueTypeT >::setTranslate().

Referenced by osg::Navigator::buttonPress(), osg::Navigator::keyPress(), osg::Navigator::moveTo(), and osg::Navigator::setDistance().

00221 {
00222     Vec3f lv;
00223     lv = _rFrom-_rAt;
00224     lv.normalize();
00225     lv *= (step);
00226     Matrix transl;
00227     transl.setIdentity();
00228     transl.setTranslate(lv);
00229     transl.multMatrixPnt(_rAt);
00230     transl.multMatrixPnt(_rFrom);
00231     return 0.0;
00232 }

Real32 FlyNavigator::right ( Real32  step  ) 

Strafes to the right, i.e. translates along the side vector.

Reimplemented in osg::WalkNavigator.

Definition at line 236 of file OSGFlyNavigator.cpp.

References _rAt, _rFrom, _vUp, osg::VectorInterface< ValueTypeT, StorageInterfaceT >::crossThis(), osg::TransformationMatrix< ValueTypeT >::multMatrixPnt(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::normalize(), osg::TransformationMatrix< ValueTypeT >::setIdentity(), and osg::TransformationMatrix< ValueTypeT >::setTranslate().

Referenced by osg::Navigator::keyPress().

00237 {
00238     Vec3f sv;
00239     sv = _rFrom-_rAt;
00240     sv.crossThis(_vUp);
00241     sv.normalize();
00242     sv *= (step);
00243     Matrix transl;
00244     transl.setIdentity();
00245     transl.setTranslate(sv);
00246     transl.multMatrixPnt(_rAt);
00247     transl.multMatrixPnt(_rFrom);
00248     return 0.0;
00249 }


Member Data Documentation

The from point, i.e. the viewer position.

Definition at line 109 of file OSGFlyNavigator.h.

Referenced by FlyNavigator(), osg::WalkNavigator::forward(), forward(), getFrom(), getMatrix(), osg::WalkNavigator::right(), right(), rotate(), set(), and setFrom().

The at point, i.e. the target position.

Definition at line 110 of file OSGFlyNavigator.h.

Referenced by FlyNavigator(), osg::WalkNavigator::forward(), forward(), getAt(), getMatrix(), osg::WalkNavigator::right(), right(), rotate(), set(), and setAt().

The transformation matrix for this navigator.

Definition at line 112 of file OSGFlyNavigator.h.

Referenced by FlyNavigator(), and getMatrix().


The documentation for this class was generated from the following files:

Generated on Mon Mar 17 11:21:34 2008 for OpenSG by  doxygen 1.5.5