改进WalkerCamera计算,使所有参数改变量保持接近一致
This commit is contained in:
parent
f8569ed513
commit
282e59fc68
@ -215,7 +215,7 @@ private:
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
WalkerCamera camera;
|
WalkerCamera camera;
|
||||||
float move_speed=0.01;
|
float move_speed=1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -271,15 +271,15 @@ public:
|
|||||||
if(key_status[kbA])camera.Left (move_speed);else
|
if(key_status[kbA])camera.Left (move_speed);else
|
||||||
if(key_status[kbD])camera.Right (move_speed);else
|
if(key_status[kbD])camera.Right (move_speed);else
|
||||||
|
|
||||||
if(key_status[kbLeft ])camera.WrapLeftRotate (move_speed*100);else
|
if(key_status[kbLeft ])camera.WrapLeftRotate (move_speed);else
|
||||||
if(key_status[kbRight ])camera.WrapRightRotate(move_speed*100);else
|
if(key_status[kbRight ])camera.WrapRightRotate(move_speed);else
|
||||||
if(key_status[kbUp ])camera.WrapUpRotate (move_speed*100);else
|
if(key_status[kbUp ])camera.WrapUpRotate (move_speed);else
|
||||||
if(key_status[kbDown ])camera.WrapDownRotate (move_speed*100);else
|
if(key_status[kbDown ])camera.WrapDownRotate (move_speed);else
|
||||||
|
|
||||||
if(key_status[kbHome ])camera.ForwardTilt (move_speed*100);else
|
if(key_status[kbHome ])camera.ForwardTilt (move_speed);else
|
||||||
if(key_status[kbEnd ])camera.LeaningBack (move_speed*100);else
|
if(key_status[kbEnd ])camera.LeaningBack (move_speed);else
|
||||||
if(key_status[kbDelete ])camera.LeftRotate (move_speed*100);else
|
if(key_status[kbDelete ])camera.LeftRotate (move_speed);else
|
||||||
if(key_status[kbPageDown])camera.RightRotate (move_speed*100);else
|
if(key_status[kbPageDown])camera.RightRotate (move_speed);else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RefreshCameraUBO();
|
RefreshCameraUBO();
|
||||||
@ -287,8 +287,8 @@ public:
|
|||||||
|
|
||||||
void KeyPress(KeyboardButton kb)override
|
void KeyPress(KeyboardButton kb)override
|
||||||
{
|
{
|
||||||
if(kb==kbMinus)move_speed*=0.9;else
|
if(kb==kbMinus)move_speed*=0.9f;else
|
||||||
if(kb==kbEquals)move_speed*=1.1;else
|
if(kb==kbEquals)move_speed*=1.1f;else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RefreshCameraUBO();
|
RefreshCameraUBO();
|
||||||
|
@ -47,8 +47,6 @@ namespace hgl
|
|||||||
*/
|
*/
|
||||||
struct WalkerCamera:public Camera
|
struct WalkerCamera:public Camera
|
||||||
{
|
{
|
||||||
Vector4f foot; //脚位置
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,7 +55,6 @@ namespace hgl
|
|||||||
*/
|
*/
|
||||||
void Move(const Vector4f &move_dist)
|
void Move(const Vector4f &move_dist)
|
||||||
{
|
{
|
||||||
foot+=move_dist;
|
|
||||||
eye+=move_dist;
|
eye+=move_dist;
|
||||||
center+=move_dist;
|
center+=move_dist;
|
||||||
}
|
}
|
||||||
@ -86,16 +83,13 @@ namespace hgl
|
|||||||
|
|
||||||
public: //方法
|
public: //方法
|
||||||
|
|
||||||
virtual void Backward(float step=0.01) ///<向后
|
virtual void Backward(float step=0.01){Move((eye-center)*step/length(eye,center));} ///<向后
|
||||||
{
|
|
||||||
Move(cross(cross(center-eye,up_vector),up_vector)*step);
|
|
||||||
}
|
|
||||||
virtual void Forward(float step=0.01){Backward(-step);} ///<向前
|
virtual void Forward(float step=0.01){Backward(-step);} ///<向前
|
||||||
|
|
||||||
virtual void Up(float step=0.01){Move(length(eye,center)*step*up_vector);} ///<向上
|
virtual void Up(float step=0.01){Move(step*up_vector);} ///<向上
|
||||||
virtual void Down(float step=0.01){Up(-step);} ///<向下
|
virtual void Down(float step=0.01){Up(-step);} ///<向下
|
||||||
|
|
||||||
virtual void Right(float step=0.01){Move(cross(center-eye,up_vector)*step);} ///<向右
|
virtual void Right(float step=0.01){Move(normalized(cross(center-eye,up_vector))*step);}///<向右
|
||||||
virtual void Left(float step=0.01){Right(-step);} ///<向左
|
virtual void Left(float step=0.01){Right(-step);} ///<向左
|
||||||
|
|
||||||
public: //以自身为中心旋转
|
public: //以自身为中心旋转
|
||||||
|
Loading…
x
Reference in New Issue
Block a user