#include <OSGWalkNavigator.h>

Public Member Functions | |
Constructors | |
| WalkNavigator () | |
Destructors | |
| ~WalkNavigator () | |
Set | |
| void | setGround (NodePtr &new_ground) |
| void | setWorld (NodePtr &new_world) |
| void | setGroundDistance (Real32 groundDistance) |
| void | setMinWallDistance (Real32 wallDistance) |
| void | setPersonDimensions (Real32 height, Real32 width, Real32 fatness) |
Walker Transformations | |
| void | rotate (Real32 deltaX, Real32 deltaY) |
| Real32 | forward (Real32 step) |
| Real32 | right (Real32 step) |
Get | |
| Matrix & | getMatrix (void) |
| Pnt3f & | getFrom (void) |
| Pnt3f & | getAt (void) |
| Vec3f & | getUp (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) |
Protected Attributes | |
Members | |
| Pnt3f | _rFrom |
| Pnt3f | _rAt |
| Vec3f | _vUp |
| Matrix | _tMatrix |
Private Attributes | |
Members | |
| NodePtr | _ground |
| NodePtr | _world |
| Real32 | _groundDistance |
| Real32 | _wallDistance |
| Real32 | _height |
| Real32 | _width |
| Real32 | _fatness |
| IntersectAction * | _act |
Definition at line 50 of file OSGWalkNavigator.h.
| WalkNavigator::WalkNavigator | ( | ) |
Constructor
Definition at line 63 of file OSGWalkNavigator.cpp.
References _act, and osg::IntersectAction::create().
00063 : FlyNavigator(), 00064 _ground(NullFC), 00065 _world(NullFC), 00066 _groundDistance(0.75), 00067 _wallDistance(0.1), 00068 _height(0.85), 00069 _width(0.5), 00070 _fatness(0.5) 00071 { 00072 _act = IntersectAction::create(); 00073 }
| WalkNavigator::~WalkNavigator | ( | ) |
Destructor
Definition at line 80 of file OSGWalkNavigator.cpp.
References _act.
00081 { 00082 delete _act; 00083 }
| void WalkNavigator::setGround | ( | NodePtr & | new_ground | ) |
Definition at line 92 of file OSGWalkNavigator.cpp.
References _ground.
Referenced by osg::Navigator::setViewport().
00093 { 00094 _ground=new_ground; 00095 }
| void WalkNavigator::setWorld | ( | NodePtr & | new_world | ) |
Definition at line 97 of file OSGWalkNavigator.cpp.
References _world.
Referenced by osg::Navigator::setViewport().
00098 { 00099 _world=new_world; 00100 }
| void WalkNavigator::setGroundDistance | ( | Real32 | groundDistance | ) |
Definition at line 102 of file OSGWalkNavigator.cpp.
References _groundDistance.
00103 { 00104 _groundDistance=groundDistance; 00105 }
| void WalkNavigator::setMinWallDistance | ( | Real32 | wallDistance | ) |
Definition at line 107 of file OSGWalkNavigator.cpp.
References _wallDistance.
00108 { 00109 _wallDistance=wallDistance; 00110 }
makes a rotation
Reimplemented from osg::FlyNavigator.
Definition at line 124 of file OSGWalkNavigator.cpp.
References osg::FlyNavigator::rotate().
Referenced by osg::Navigator::keyPress(), and osg::Navigator::moveTo().
00125 { 00126 FlyNavigator::rotate(deltaX, deltaY); 00127 }
"walks" forward
Reimplemented from osg::FlyNavigator.
Definition at line 132 of file OSGWalkNavigator.cpp.
References _act, _fatness, _ground, _groundDistance, _height, osg::FlyNavigator::_rAt, osg::FlyNavigator::_rFrom, osg::FlyNavigator::_vUp, _wallDistance, _world, osg::Action::apply(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::crossThis(), osg::IntersectAction::didHit(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::dot(), osg::IntersectAction::getHitT(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::normalize(), osg::IntersectAction::setLine(), and osg::Line::setValue().
Referenced by osg::Navigator::buttonPress(), osg::Navigator::keyPress(), osg::Navigator::moveTo(), and osg::Navigator::setDistance().
00133 { 00134 Vec3f lv = _rFrom - _rAt; 00135 lv.normalize(); 00136 00137 Vec3f upn = _vUp; 00138 upn.normalize(); 00139 00140 Vec3f mv = lv - upn.dot(lv)*upn; 00141 mv.normalize(); 00142 00143 //side vector symbolizes shoulders 00144 Vec3f sv = mv; 00145 sv.crossThis(upn); 00146 sv.normalize(); 00147 00148 Pnt3f rFrom = _rFrom + step*mv; 00149 Pnt3f rAt = _rAt + step*mv; 00150 00151 Real32 dist; 00152 Line line(rFrom, -upn); 00153 00154 //keep the walker at a constant distance from the ground 00155 _act->setLine(line); 00156 _act->apply(_ground); 00157 00158 if (_act->didHit()) { 00159 dist = _act->getHitT(); 00160 if (dist >= _height) { 00161 rFrom = rFrom + (_groundDistance-dist+_height)*upn; 00162 rAt = rAt + (_groundDistance-dist+_height)*upn; 00163 } 00164 else return 0.0; //can't jump so high 00165 } 00166 00167 //finally check if the move is correct or not 00168 00169 line.setValue(_rFrom, mv); 00170 _act->setLine(line); 00171 _act->apply(_world); 00172 00173 if (_act->didHit()) { 00174 dist = _act->getHitT(); 00175 if (dist <= (rFrom-_rFrom).length()+_fatness+_wallDistance) 00176 return 0.0; //running against a wall 00177 } 00178 00179 //move was ok, store new values 00180 _rFrom = rFrom; 00181 _rAt = rAt; 00182 return step; 00183 }
turns the viewer right or left
Reimplemented from osg::FlyNavigator.
Definition at line 188 of file OSGWalkNavigator.cpp.
References _act, _fatness, _ground, _groundDistance, _height, osg::FlyNavigator::_rAt, osg::FlyNavigator::_rFrom, osg::FlyNavigator::_vUp, _wallDistance, _world, osg::Action::apply(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::crossThis(), osg::IntersectAction::didHit(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::dot(), osg::IntersectAction::getHitT(), osg::VectorInterface< ValueTypeT, StorageInterfaceT >::normalize(), osg::IntersectAction::setLine(), and osg::Line::setValue().
Referenced by osg::Navigator::keyPress().
00189 { 00190 // Int16 sign = (step >= 0) ? -1 : 1; 00191 // Real32 angle = 0.19634954f; 00192 // 00193 // //rotate around the up vector 00194 // FlyNavigator::rotate(sign*angle, 0); 00195 // return step; 00196 00197 Vec3f lv = _rFrom - _rAt; 00198 lv.normalize(); 00199 00200 Vec3f upn = _vUp; 00201 upn.normalize(); 00202 00203 Vec3f mv = lv - upn.dot(lv)*upn; 00204 mv.normalize(); 00205 00206 //side vector symbolizes shoulders 00207 Vec3f sv = mv; 00208 sv.crossThis(upn); 00209 sv.normalize(); 00210 00211 Pnt3f rFrom = _rFrom + step*sv; 00212 Pnt3f rAt = _rAt + step*sv; 00213 00214 Real32 dist; 00215 Line line(rFrom, -upn); 00216 00217 //keep the walker at a constant distance from the ground 00218 _act->setLine(line); 00219 _act->apply(_ground); 00220 00221 if (_act->didHit()) { 00222 dist = _act->getHitT(); 00223 if (dist >= _height) { 00224 rFrom = rFrom + (_groundDistance-dist+_height)*upn; 00225 rAt = rAt + (_groundDistance-dist+_height)*upn; 00226 } 00227 else return 0.0; //can't jump so high 00228 } 00229 00230 //finally check if the move is correct or not 00231 00232 line.setValue(_rFrom, sv); 00233 _act->setLine(line); 00234 _act->apply(_world); 00235 00236 if (_act->didHit()) { 00237 dist = _act->getHitT(); 00238 if (dist <= (rFrom-_rFrom).length()+_fatness+_wallDistance) 00239 return 0.0; //running against a wall 00240 } 00241 00242 //move was ok, store new values 00243 _rFrom = rFrom; 00244 _rAt = rAt; 00245 return step; 00246 }
| Matrix & FlyNavigator::getMatrix | ( | void | ) | [inherited] |
Get the current transformation matrix.
Definition at line 102 of file OSGFlyNavigator.cpp.
References osg::FlyNavigator::_rAt, osg::FlyNavigator::_rFrom, osg::FlyNavigator::_tMatrix, osg::FlyNavigator::_vUp, and osg::MatrixLookAt().
Referenced by osg::Navigator::getMatrix().
| Pnt3f & FlyNavigator::getFrom | ( | void | ) | [inherited] |
Get the from point.
Definition at line 110 of file OSGFlyNavigator.cpp.
References osg::FlyNavigator::_rFrom.
Referenced by osg::Navigator::getFrom().
00111 { 00112 return _rFrom; 00113 }
| Pnt3f & FlyNavigator::getAt | ( | void | ) | [inherited] |
Get the at point.
Definition at line 117 of file OSGFlyNavigator.cpp.
References osg::FlyNavigator::_rAt.
Referenced by osg::Navigator::getAt().
00118 { 00119 return _rAt; 00120 }
| Vec3f & FlyNavigator::getUp | ( | void | ) | [inherited] |
Get the up vector.
Definition at line 124 of file OSGFlyNavigator.cpp.
References osg::FlyNavigator::_vUp.
Referenced by osg::Navigator::getUp().
00125 { 00126 return _vUp; 00127 }
| void FlyNavigator::setFrom | ( | Pnt3f | new_from | ) | [inherited] |
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 osg::FlyNavigator::_rFrom.
Referenced by osg::Navigator::setFrom().
00136 { 00137 _rFrom=new_from; 00138 }
| void FlyNavigator::setAt | ( | Pnt3f | new_At | ) | [inherited] |
Sets the target point at which the viewer is looking.
Definition at line 142 of file OSGFlyNavigator.cpp.
References osg::FlyNavigator::_rAt.
Referenced by osg::Navigator::setAt().
00143 { 00144 _rAt=new_At; 00145 }
| void FlyNavigator::setUp | ( | Vec3f | new_up | ) | [inherited] |
Sets the up vector, i.e. the direction that point up on the screen.
Definition at line 149 of file OSGFlyNavigator.cpp.
References osg::FlyNavigator::_vUp.
Referenced by osg::Navigator::setUp().
00150 { 00151 _vUp=new_up; 00152 }
Set the position and the orientation at once.
Definition at line 156 of file OSGFlyNavigator.cpp.
References osg::FlyNavigator::_rAt, osg::FlyNavigator::_rFrom, and osg::FlyNavigator::_vUp.
Referenced by osg::Navigator::set().
| void FlyNavigator::set | ( | Matrix | new_matrix | ) | [inherited] |
Set the position and the orientation at once using a matrix.
Definition at line 165 of file OSGFlyNavigator.cpp.
References osg::FlyNavigator::_rAt, osg::FlyNavigator::_rFrom, and osg::FlyNavigator::_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 }
NodePtr osg::WalkNavigator::_ground [private] |
Definition at line 101 of file OSGWalkNavigator.h.
Referenced by forward(), right(), and setGround().
NodePtr osg::WalkNavigator::_world [private] |
Definition at line 102 of file OSGWalkNavigator.h.
Referenced by forward(), right(), and setWorld().
Real32 osg::WalkNavigator::_groundDistance [private] |
Definition at line 104 of file OSGWalkNavigator.h.
Referenced by forward(), right(), and setGroundDistance().
Real32 osg::WalkNavigator::_wallDistance [private] |
Definition at line 105 of file OSGWalkNavigator.h.
Referenced by forward(), right(), and setMinWallDistance().
Real32 osg::WalkNavigator::_height [private] |
Definition at line 106 of file OSGWalkNavigator.h.
Referenced by forward(), right(), and setPersonDimensions().
Real32 osg::WalkNavigator::_width [private] |
Real32 osg::WalkNavigator::_fatness [private] |
Definition at line 108 of file OSGWalkNavigator.h.
Referenced by forward(), right(), and setPersonDimensions().
IntersectAction* osg::WalkNavigator::_act [private] |
Definition at line 110 of file OSGWalkNavigator.h.
Referenced by forward(), right(), WalkNavigator(), and ~WalkNavigator().
osg::FlyNavigator::_rFrom [protected, inherited] |
The from point, i.e. the viewer position.
Definition at line 109 of file OSGFlyNavigator.h.
Referenced by osg::FlyNavigator::FlyNavigator(), forward(), osg::FlyNavigator::forward(), osg::FlyNavigator::getFrom(), osg::FlyNavigator::getMatrix(), right(), osg::FlyNavigator::right(), osg::FlyNavigator::rotate(), osg::FlyNavigator::set(), and osg::FlyNavigator::setFrom().
osg::FlyNavigator::_rAt [protected, inherited] |
The at point, i.e. the target position.
Definition at line 110 of file OSGFlyNavigator.h.
Referenced by osg::FlyNavigator::FlyNavigator(), forward(), osg::FlyNavigator::forward(), osg::FlyNavigator::getAt(), osg::FlyNavigator::getMatrix(), right(), osg::FlyNavigator::right(), osg::FlyNavigator::rotate(), osg::FlyNavigator::set(), and osg::FlyNavigator::setAt().
osg::FlyNavigator::_vUp [protected, inherited] |
The up vector.
Definition at line 111 of file OSGFlyNavigator.h.
Referenced by osg::FlyNavigator::FlyNavigator(), forward(), osg::FlyNavigator::getMatrix(), osg::FlyNavigator::getUp(), right(), osg::FlyNavigator::right(), osg::FlyNavigator::rotate(), osg::FlyNavigator::set(), and osg::FlyNavigator::setUp().
osg::FlyNavigator::_tMatrix [protected, inherited] |
The transformation matrix for this navigator.
Definition at line 112 of file OSGFlyNavigator.h.
Referenced by osg::FlyNavigator::FlyNavigator(), and osg::FlyNavigator::getMatrix().
1.5.5