Added a white ring outside gizmo_rotate

This commit is contained in:
hyzboy 2024-08-01 01:42:21 +08:00
parent 2137725bd2
commit 7f074c6c79
4 changed files with 56 additions and 9 deletions

2
CMCore

@ -1 +1 @@
Subproject commit 7165984d2270c61f19653a3a256c05786ec478fa
Subproject commit 7589d62732b68b99de1bec561b1703dd2b043c03

@ -1 +1 @@
Subproject commit f11e49363bed867c5fb5584277718983e6b6b697
Subproject commit 53f0c618567a0e85aca2de4e9e06e08f587c1f7e

View File

@ -33,6 +33,8 @@ enum class GizmoShape:uint
bool InitGizmoResource(RenderResource *);
void FreeGizmoResource();
Renderable *GetGizmoRenderable(const GizmoShape &shape,const GizmoColor &color);
StaticMesh *GetGizmoMoveStaticMesh();
StaticMesh *GetGizmoScaleStaticMesh();
StaticMesh *GetGizmoRotateStaticMesh();

View File

@ -1,9 +1,22 @@
#include"VulkanAppFramework.h"
#include"Gizmo.h"
#include<hgl/graph/Ray.h>
using namespace hgl;
using namespace hgl::graph;
/**
*
*/
Vector2f WorldToScreen(const Vector3f &world_pos,const CameraInfo &ci,const ViewportInfo &vi)
{
Vector4f pos=ci.vp*Vector4f(world_pos,1);
pos/=pos.w;
return Vector2f((pos.x+1)*vi.GetViewportWidth()/2,(1-pos.y)*vi.GetViewportHeight()/2);
}
class TestApp:public SceneAppFramework
{
SceneNode root;
@ -11,6 +24,8 @@ class TestApp:public SceneAppFramework
StaticMesh *sm_move=nullptr;
StaticMesh *sm_rotate=nullptr;
Renderable *face_torus=nullptr;
private:
bool InitGizmo()
@ -21,6 +36,8 @@ private:
sm_move =GetGizmoMoveStaticMesh();
sm_rotate =GetGizmoRotateStaticMesh();
face_torus =GetGizmoRenderable(GizmoShape::Torus,GizmoColor::White);
return(true);
}
@ -36,13 +53,6 @@ public:
camera->pos=Vector3f(32,32,32);
camera_control->SetTarget(Vector3f(0,0,0));
camera_control->Refresh();
root.CreateSubNode(sm_move->GetScene());
root.CreateSubNode(sm_rotate->GetScene());
root.RefreshMatrix();
render_list->Expend(&root);
return(true);
}
@ -51,6 +61,41 @@ public:
{
FreeGizmoResource();
}
void BuildCommandBuffer(uint32 index) override
{
camera_control->Refresh();
const CameraInfo &ci=camera_control->GetCameraInfo();
const ViewportInfo &vi=GetViewportInfo();
const float screen_height=vi.GetViewportHeight();
root.Clear();
const Vector3f GizmoPosition(0,0,0);
const Vector4f pos=ci.Project(GizmoPosition);
root.SetLocalMatrix(scale(pos.w*16.0f/screen_height));
root.CreateSubNode(sm_move->GetScene());
root.CreateSubNode(sm_rotate->GetScene());
{
Transform tm;
tm.SetRotation(CalculateFacingRotationQuat(GizmoPosition,ci.view,AxisVector::X));
tm.SetScale(15);
root.CreateSubNode(tm,face_torus);
}
root.RefreshMatrix();
render_list->Expend(&root);
SceneAppFramework::BuildCommandBuffer(index);
}
};//class TestApp:public SceneAppFramework
int main(int,char **)