use TransformFaceToCamera in GizmoTest.cpp
This commit is contained in:
parent
5e8957b78b
commit
efd9a447fb
@ -1 +1 @@
|
||||
Subproject commit 079becd267447676ced6678bd8406208d73169ee
|
||||
Subproject commit ef1afa55da2ede0b7d0b6c8efb424e3e11c1c366
|
@ -1,5 +1,6 @@
|
||||
#include"VulkanAppFramework.h"
|
||||
#include"Gizmo.h"
|
||||
#include<hgl/graph/TransformFaceToCamera.h>
|
||||
#include<hgl/graph/Ray.h>
|
||||
|
||||
using namespace hgl;
|
||||
@ -7,59 +8,6 @@ using namespace hgl::graph;
|
||||
|
||||
const Vector3f GizmoPosition(0,0,0);
|
||||
|
||||
/**
|
||||
* 永远转向摄像机的变换节点
|
||||
*/
|
||||
class TransformFaceToCamera:public TransformBase
|
||||
{
|
||||
CameraInfo *camera_info=nullptr;
|
||||
|
||||
Matrix4f last_view_matrix;
|
||||
|
||||
protected:
|
||||
|
||||
void MakeNewestData(Matrix4f &mat) override
|
||||
{
|
||||
if(camera_info)
|
||||
mat=ToMatrix(CalculateFacingRotationQuat(WorldPosition,camera_info->view,WorldNormal));
|
||||
else
|
||||
mat=Identity4f;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
using TransformBase::TransformBase;
|
||||
|
||||
constexpr const size_t GetTypeHash()const override { return hgl::GetTypeHash<TransformFaceToCamera>(); }
|
||||
|
||||
TransformFaceToCamera(CameraInfo *ci):TransformBase()
|
||||
{
|
||||
camera_info=ci;
|
||||
|
||||
last_view_matrix=Identity4f;
|
||||
}
|
||||
|
||||
TransformBase *CreateSelfCopy()const override
|
||||
{
|
||||
return(new TransformFaceToCamera(camera_info));
|
||||
}
|
||||
|
||||
void SetCameraInfo(CameraInfo *ci) { camera_info=ci; }
|
||||
|
||||
bool Update() override
|
||||
{
|
||||
if(!camera_info)
|
||||
return(false);
|
||||
|
||||
if(IsNearlyEqual(last_view_matrix,camera_info->view))
|
||||
return(false);
|
||||
|
||||
last_view_matrix=camera_info->view;
|
||||
|
||||
UpdateVersion();
|
||||
return(true);
|
||||
}
|
||||
};//class TransformFaceToCamera:public TransformBase
|
||||
|
||||
///**
|
||||
//* 一种永远转向正面的变换节点
|
||||
@ -152,9 +100,6 @@ private:
|
||||
|
||||
rotate_white_torus->GetTransform().AddTransform(rotate_white_torus_tfc);
|
||||
|
||||
//rotate_white_torus->SetCameraInfo(ci);
|
||||
//rotate_white_torus->SetFaceToCamera(true);
|
||||
|
||||
root.AddSubNode(rotate_white_torus);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user