diff --git a/CMSceneGraph b/CMSceneGraph index dd4f5c57..569fc6c9 160000 --- a/CMSceneGraph +++ b/CMSceneGraph @@ -1 +1 @@ -Subproject commit dd4f5c57355e4562fd94e863ffd0fcc48892073a +Subproject commit 569fc6c9ca5fbba277a70044871f2af045f2c6db diff --git a/example/Vulkan/Cubemap.cpp b/example/Vulkan/Cubemap.cpp index 4c06b9a6..830d7da3 100644 --- a/example/Vulkan/Cubemap.cpp +++ b/example/Vulkan/Cubemap.cpp @@ -200,9 +200,9 @@ public: return(false); camera->pos=Vector3f(10,10,0); - camera->target=Vector3f(0,0,0); + //camera->target=Vector3f(0,0,0); - camera->Refresh(); //更新矩阵计算 + //camera->Refresh(); //更新矩阵计算 render_list=new RenderList(device); diff --git a/example/common/VulkanAppFramework.h b/example/common/VulkanAppFramework.h index 18c25360..0392678f 100644 --- a/example/common/VulkanAppFramework.h +++ b/example/common/VulkanAppFramework.h @@ -22,6 +22,9 @@ #include #include +//#include +#include + #include #include @@ -278,12 +281,12 @@ public: class CameraKeyboardControl:public KeyboardStateEvent { - WalkerCamera *camera; + FirstPersonCameraControl *camera; float move_speed; public: - CameraKeyboardControl(WalkerCamera *wc) + CameraKeyboardControl(FirstPersonCameraControl *wc) { camera=wc; move_speed=1.0f; @@ -306,21 +309,22 @@ public: if(HasPressed(KeyboardButton::S ))camera->Backward (move_speed);else if(HasPressed(KeyboardButton::A ))camera->Left (move_speed);else if(HasPressed(KeyboardButton::D ))camera->Right (move_speed);else - if(HasPressed(KeyboardButton::R ))camera->Up (move_speed);else - if(HasPressed(KeyboardButton::F ))camera->Down (move_speed);else + //if(HasPressed(KeyboardButton::R ))camera->Up (move_speed);else + //if(HasPressed(KeyboardButton::F ))camera->Down (move_speed);else - if(HasPressed(KeyboardButton::Left ))camera->HoriRotate( move_speed);else - if(HasPressed(KeyboardButton::Right ))camera->HoriRotate(-move_speed);else - if(HasPressed(KeyboardButton::Up ))camera->VertRotate( move_speed);else - if(HasPressed(KeyboardButton::Down ))camera->VertRotate(-move_speed);else + //if(HasPressed(KeyboardButton::Left ))camera->HoriRotate( move_speed);else + //if(HasPressed(KeyboardButton::Right ))camera->HoriRotate(-move_speed);else + //if(HasPressed(KeyboardButton::Up ))camera->VertRotate( move_speed);else + //if(HasPressed(KeyboardButton::Down ))camera->VertRotate(-move_speed);else return; } }; class CameraMouseControl:public MouseEvent { - WalkerCamera *camera; + FirstPersonCameraControl *camera; double cur_time; + double last_time; Vector2f mouse_last_pos; @@ -331,6 +335,8 @@ protected: mouse_last_pos.x=x; mouse_last_pos.y=y; + last_time=cur_time; + return(true); } @@ -345,23 +351,27 @@ protected: Vector2f gap=pos-mouse_last_pos; bool update=false; - if(gap.x!=0){update=true;if(left)camera->HoriRotate( gap.x/10.0f);else camera->WrapHoriRotate(gap.x);} - if(gap.y!=0){update=true;if(left)camera->VertRotate(-gap.y/10.0f);else camera->WrapVertRotate(gap.y);} + //if(gap.x!=0){update=true;if(left)camera->HoriRotate( gap.x/10.0f);else camera->WrapHoriRotate(gap.x);} + //if(gap.y!=0){update=true;if(left)camera->VertRotate(-gap.y/10.0f);else camera->WrapVertRotate(gap.y);} + + camera->Rotate(gap,(cur_time-last_time)*5); + + last_time=cur_time; + mouse_last_pos=Vector2f(x,y); } - mouse_last_pos=Vector2f(x,y); return(true); } bool OnWheel(int v,int h) { - camera->Distance(1+(h/1000.0f)); + //camera->Distance(1+(h/1000.0f)); return(true); } public: - CameraMouseControl(WalkerCamera *wc) + CameraMouseControl(FirstPersonCameraControl *wc) { camera=wc; cur_time=0; @@ -377,11 +387,12 @@ class CameraAppFramework:public VulkanApplicationFramework { private: - GPUBuffer * ubo_camera_info =nullptr; + GPUBuffer *ubo_camera_info=nullptr; protected: - WalkerCamera * camera =nullptr; + Camera *camera=nullptr; + FirstPersonCameraControl *camera_control=nullptr; CameraKeyboardControl * ckc=nullptr; CameraMouseControl * cmc=nullptr; @@ -406,7 +417,7 @@ public: virtual void InitCamera(int w,int h) { - camera=new WalkerCamera; + camera=new Camera; camera->width=w; camera->height=h; @@ -414,14 +425,16 @@ public: camera->vp_height=h; camera->pos=Vector4f(10,10,10,1); - camera->target=Vector4f(0,0,0,1); - camera->Refresh(); //更新矩阵计算 + camera_control=new FirstPersonCameraControl(camera); + + //camera_control->target=Vector4f(0,0,0,1); + camera_control->Refresh(); //更新矩阵计算 ubo_camera_info=db->CreateUBO(sizeof(CameraInfo),&camera->info); - ckc=new CameraKeyboardControl(camera); - cmc=new CameraMouseControl(camera); + ckc=new CameraKeyboardControl(camera_control); + cmc=new CameraMouseControl(camera_control); win->Join(ckc); win->Join(cmc); @@ -432,7 +445,7 @@ public: camera->width=w; camera->height=h; - camera->Refresh(); + camera_control->Refresh(); ubo_camera_info->Write(&camera->info); } @@ -465,7 +478,7 @@ public: virtual void Draw()override { - camera->Refresh(); //更新相机矩阵 + camera_control->Refresh(); //更新相机矩阵 ubo_camera_info->Write(&camera->info); //写入缓冲区 const uint32_t index=AcquireNextImage(); diff --git a/inc/hgl/graph/VKCommandBuffer.h b/inc/hgl/graph/VKCommandBuffer.h index 37589d61..eaa797d9 100644 --- a/inc/hgl/graph/VKCommandBuffer.h +++ b/inc/hgl/graph/VKCommandBuffer.h @@ -6,8 +6,6 @@ #include #include VK_NAMESPACE_BEGIN -//push constant 一般只有128/256字节,仅能存在矩阵。 -//所以我们将每个对象的独立变换矩阵存在push constant中 class GPUCmdBuffer { protected: diff --git a/res b/res index d7c22490..91526330 160000 --- a/res +++ b/res @@ -1 +1 @@ -Subproject commit d7c22490949ff4b2f27aa3fd90d23e5c82639d1e +Subproject commit 91526330e1b7470a36d8651444709aa8a7da7efd