updated CameraControl's codes.
This commit is contained in:
parent
5b5ec1df7a
commit
057a6e2bd0
@ -1 +1 @@
|
||||
Subproject commit 846113e0fbb9f354300c21052c2c4ff0440c6dc6
|
||||
Subproject commit 40d5435239ad76d46223bd73e73c58f0332d0ed7
|
@ -71,16 +71,7 @@ public:
|
||||
if(!ro->ubo_camera_info)
|
||||
return(false);
|
||||
|
||||
{
|
||||
MaterialParameters *mp_global=ro->material_instance->GetMP(DescriptorSetsType::Global);
|
||||
|
||||
if(!mp_global)
|
||||
return(false);
|
||||
|
||||
if(!mp_global->BindUBO("g_camera",ro->ubo_camera_info))return(false);
|
||||
|
||||
mp_global->Update();
|
||||
}
|
||||
BindCameraUBO(ro->material_instance);
|
||||
|
||||
return(true);
|
||||
}
|
||||
@ -142,20 +133,14 @@ public:
|
||||
cube.sampler=db->CreateSampler();
|
||||
if(!cube.sampler)return(false);
|
||||
|
||||
{
|
||||
MaterialParameters *mp_texture=cube.material_instance->GetMP(DescriptorSetsType::Value);
|
||||
|
||||
if(!mp_texture)
|
||||
return(false);
|
||||
|
||||
if(!mp_texture->BindSampler("tex",os.render_taget->GetColorTexture(),cube.sampler))return(false);
|
||||
|
||||
mp_texture->Update();
|
||||
}
|
||||
if(!cube.material_instance->BindSampler(DescriptorSetsType::Value,"tex",os.render_taget->GetColorTexture(),cube.sampler))
|
||||
return(false);
|
||||
|
||||
{
|
||||
CubeCreateInfo cci;
|
||||
|
||||
cci.tex_coord=true;
|
||||
|
||||
Renderable *render_obj=CreateRenderableCube(db,cube.material_instance->GetVAB(),&cci);
|
||||
if(!render_obj)return(false);
|
||||
|
||||
|
@ -395,6 +395,15 @@ protected:
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool OnWheel(int,int y) override
|
||||
{
|
||||
if(y==0)return(false);
|
||||
|
||||
camera->Forward(float(y)/10.0f);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool OnMove(int x,int y) override
|
||||
{
|
||||
mouse_pos.x=x;
|
||||
@ -403,16 +412,25 @@ protected:
|
||||
bool left=HasPressed(MouseButton::Left);
|
||||
bool right=HasPressed(MouseButton::Right);
|
||||
|
||||
if(left||right)
|
||||
Vector2f pos(x,y);
|
||||
Vector2f gap=pos-mouse_last_pos;
|
||||
|
||||
if(left)
|
||||
{
|
||||
Vector2f pos(x,y);
|
||||
Vector2f gap=pos-mouse_last_pos;
|
||||
gap/=-5.0f;
|
||||
|
||||
camera->Rotate(gap);
|
||||
|
||||
last_time=cur_time;
|
||||
mouse_last_pos=Vector2f(x,y);
|
||||
}
|
||||
else
|
||||
if(right)
|
||||
{
|
||||
gap/=10.0f;
|
||||
|
||||
camera->Move(Vector3f(gap.x,0,gap.y));
|
||||
}
|
||||
|
||||
last_time=cur_time;
|
||||
mouse_last_pos=Vector2f(x,y);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user