00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef INPUT_HUMAN_MATRIX_GETTER_H
00028 #define INPUT_HUMAN_MATRIX_GETTER_H
00029
00030 #include <PVLE/Export.h>
00031 #include <PVLE/Util/Util.h>
00032 #include <PVLE/Input/MatrixGetter.h>
00033 #include <PVLE/Input/ControlMapper.h>
00034
00035
00040 class PVLE_EXPORT HumanMatrixGetter : public MatrixGetter, public ControlHandler {
00041 public:
00042 HumanMatrixGetter() : EyePos(100,0,10), Dir(-1,0,0), Up(0,0,1), MovingSpeed(50) {}
00043
00044 virtual bool handleEvent(NetControlEvent * pEvent, TNL::EventConnection * pConnection) { return false; }
00045 virtual void handleFrame(double elapsed);
00046
00048 void setByFrame(const osg::Vec3 & EyePos, const osg::Vec3 & Dir, const osg::Vec3 & Up) {
00049 this->EyePos = EyePos;
00050 this->Dir = Dir;
00051 this->Up = Up;
00052
00053 this->Dir.normalize();
00054 this->Up.normalize();
00055 }
00056
00057 virtual osg::Matrix getMatrix() const { return osg::Matrix::inverse(getInverseMatrix()); }
00058 virtual osg::Matrix getInverseMatrix() const { return osg::Matrix::lookAt(EyePos, EyePos+Dir, Up) * osg::Matrix::rotate(osg::PI_2, osg::Vec3(1,0,0)); }
00059
00061 osg::Matrix yawPitchRoll(osg::Vec3::value_type yaw, osg::Vec3::value_type pitch, osg::Vec3::value_type roll) const;
00062
00063 protected:
00064 osg::Vec3 EyePos, Dir, Up;
00065
00066 osg::Vec3::value_type MovingSpeed;
00067 static const osg::Vec3::value_type AlphaMin;
00068 };
00069
00070
00071 #endif // INPUT_HUMAN_MATRIX_GETTER_H