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)
|
if(!ro->ubo_camera_info)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
{
|
BindCameraUBO(ro->material_instance);
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
@ -142,20 +133,14 @@ public:
|
|||||||
cube.sampler=db->CreateSampler();
|
cube.sampler=db->CreateSampler();
|
||||||
if(!cube.sampler)return(false);
|
if(!cube.sampler)return(false);
|
||||||
|
|
||||||
{
|
if(!cube.material_instance->BindSampler(DescriptorSetsType::Value,"tex",os.render_taget->GetColorTexture(),cube.sampler))
|
||||||
MaterialParameters *mp_texture=cube.material_instance->GetMP(DescriptorSetsType::Value);
|
|
||||||
|
|
||||||
if(!mp_texture)
|
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
if(!mp_texture->BindSampler("tex",os.render_taget->GetColorTexture(),cube.sampler))return(false);
|
|
||||||
|
|
||||||
mp_texture->Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
CubeCreateInfo cci;
|
CubeCreateInfo cci;
|
||||||
|
|
||||||
|
cci.tex_coord=true;
|
||||||
|
|
||||||
Renderable *render_obj=CreateRenderableCube(db,cube.material_instance->GetVAB(),&cci);
|
Renderable *render_obj=CreateRenderableCube(db,cube.material_instance->GetVAB(),&cci);
|
||||||
if(!render_obj)return(false);
|
if(!render_obj)return(false);
|
||||||
|
|
||||||
|
@ -395,6 +395,15 @@ protected:
|
|||||||
return(true);
|
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
|
bool OnMove(int x,int y) override
|
||||||
{
|
{
|
||||||
mouse_pos.x=x;
|
mouse_pos.x=x;
|
||||||
@ -403,16 +412,25 @@ protected:
|
|||||||
bool left=HasPressed(MouseButton::Left);
|
bool left=HasPressed(MouseButton::Left);
|
||||||
bool right=HasPressed(MouseButton::Right);
|
bool right=HasPressed(MouseButton::Right);
|
||||||
|
|
||||||
if(left||right)
|
|
||||||
{
|
|
||||||
Vector2f pos(x,y);
|
Vector2f pos(x,y);
|
||||||
Vector2f gap=pos-mouse_last_pos;
|
Vector2f gap=pos-mouse_last_pos;
|
||||||
|
|
||||||
|
if(left)
|
||||||
|
{
|
||||||
|
gap/=-5.0f;
|
||||||
|
|
||||||
camera->Rotate(gap);
|
camera->Rotate(gap);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if(right)
|
||||||
|
{
|
||||||
|
gap/=10.0f;
|
||||||
|
|
||||||
|
camera->Move(Vector3f(gap.x,0,gap.y));
|
||||||
|
}
|
||||||
|
|
||||||
last_time=cur_time;
|
last_time=cur_time;
|
||||||
mouse_last_pos=Vector2f(x,y);
|
mouse_last_pos=Vector2f(x,y);
|
||||||
}
|
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user