From a5830e18cb04f629a8ed03ca8e447c1b6833510e Mon Sep 17 00:00:00 2001 From: "HuYingzhuo(hugo/hyzboy)" Date: Wed, 11 Oct 2023 19:38:12 +0800 Subject: [PATCH] added ReserveDirection --- CMCore | 2 +- example/Gizmo/PlaneGrid3D.cpp | 2 ++ example/common/VulkanAppFramework.h | 16 ++++++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CMCore b/CMCore index 460dc1c5..03443255 160000 --- a/CMCore +++ b/CMCore @@ -1 +1 @@ -Subproject commit 460dc1c5ecfba0f0cef93026be5d25a4f86605b1 +Subproject commit 03443255541b4dde822f147fb7b817b3811cd8b9 diff --git a/example/Gizmo/PlaneGrid3D.cpp b/example/Gizmo/PlaneGrid3D.cpp index 97724057..8f5ffd05 100644 --- a/example/Gizmo/PlaneGrid3D.cpp +++ b/example/Gizmo/PlaneGrid3D.cpp @@ -92,6 +92,8 @@ private: camera_control->SetTarget(Vector3f(0,0,0)); camera_control->Refresh(); + cmc->SetReserveDirection(true,true); //反转x,y + render_root.RefreshMatrix(); render_list->Expend(&render_root); diff --git a/example/common/VulkanAppFramework.h b/example/common/VulkanAppFramework.h index ff96e424..376a4fcd 100644 --- a/example/common/VulkanAppFramework.h +++ b/example/common/VulkanAppFramework.h @@ -378,7 +378,9 @@ class CameraMouseControl:public MouseEvent Vector2f mouse_pos; Vector2f mouse_last_pos; -protected: + Vector2f ReverseDirection; + +protected: bool OnPressed(int x,int y,MouseButton) override { @@ -409,6 +411,8 @@ protected: Vector2f pos(x,y); Vector2f gap=pos-mouse_last_pos; + + gap*=ReverseDirection; if(left) { @@ -436,6 +440,15 @@ public: { camera=wc; cur_time=0; + + ReverseDirection.x=1; + ReverseDirection.y=1; + } + + void SetReserveDirection(bool x,bool y) + { + ReverseDirection.x=x?-1:1; + ReverseDirection.y=y?-1:1; } const Vector2f &GetMouseCoord()const{return mouse_pos;} @@ -448,7 +461,6 @@ public: class CameraAppFramework:public VulkanApplicationFramework { - protected: Camera * camera =nullptr;