[WIP] first version of gizmo move test,,can't RUN.
This commit is contained in:
parent
03f7237db3
commit
412ed6f3f2
2
CMCore
2
CMCore
@ -1 +1 @@
|
||||
Subproject commit 7feefc65c96d704f05b43f266b30e628fad5e539
|
||||
Subproject commit 1a61053e33ba573fb80a3775200e3db83dafd6bd
|
@ -32,4 +32,6 @@ enum class GizmoShape:uint
|
||||
bool InitGizmoResource(GPUDevice *);
|
||||
void FreeGizmoResource();
|
||||
|
||||
StaticMesh *GetGizmoMoveStaticMesh();
|
||||
|
||||
VK_NAMESPACE_END
|
||||
|
@ -30,66 +30,85 @@ VK_NAMESPACE_BEGIN
|
||||
namespace
|
||||
{
|
||||
static StaticMesh *sm_gizmo_move=nullptr;
|
||||
|
||||
bool InitGizmoMoveStaticMesh()
|
||||
{
|
||||
Renderable *sphere=GetGizmoRenderable(GizmoShape::Sphere,GizmoColor::White);
|
||||
Renderable *cylinder[3]
|
||||
{
|
||||
GetGizmoRenderable(GizmoShape::Cylinder,GizmoColor::Red),
|
||||
GetGizmoRenderable(GizmoShape::Cylinder,GizmoColor::Green),
|
||||
GetGizmoRenderable(GizmoShape::Cylinder,GizmoColor::Blue),
|
||||
};
|
||||
|
||||
Renderable *cone[3]
|
||||
{
|
||||
GetGizmoRenderable(GizmoShape::Cone,GizmoColor::Red),
|
||||
GetGizmoRenderable(GizmoShape::Cone,GizmoColor::Green),
|
||||
GetGizmoRenderable(GizmoShape::Cone,GizmoColor::Blue),
|
||||
};
|
||||
|
||||
if(!sphere)
|
||||
return(false);
|
||||
|
||||
for(int i=0;i<3;i++)
|
||||
{
|
||||
if(!cylinder[i])
|
||||
return(false);
|
||||
|
||||
if(!cone[i])
|
||||
return(false);
|
||||
}
|
||||
|
||||
{
|
||||
SceneNode *root_node=new SceneNode(scale(1),sphere);
|
||||
|
||||
root_node->CreateSubNode(scale(9,1,1),cylinder[0]);
|
||||
|
||||
{
|
||||
Transform tm;
|
||||
|
||||
tm.SetTranslation(Vector3f(0,0,4.5f));
|
||||
root_node->CreateSubNode(tm.GetMatrix(),cylinder[2]); //Z 向上
|
||||
|
||||
tm.SetRotation(Vector3f(0,0,1),90);
|
||||
tm.SetTranslation(Vector3f(4.5f,0,0));
|
||||
|
||||
root_node->CreateSubNode(tm.GetMatrix(),cylinder[0]); //X 向右
|
||||
|
||||
tm.SetRotation(Vector3f(1,0,0),90);
|
||||
tm.SetTranslation(Vector3f(0,4.5f,0));
|
||||
|
||||
root_node->CreateSubNode(tm.GetMatrix(),cylinder[1]); //Y 向前
|
||||
}
|
||||
|
||||
sm_gizmo_move=CreateGizmoStaticMesh(root_node);
|
||||
}
|
||||
|
||||
if(!sm_gizmo_move)
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
}//namespace
|
||||
|
||||
StaticMesh *GetGizmoMoveStaticMesh()
|
||||
{
|
||||
return sm_gizmo_move;
|
||||
}
|
||||
|
||||
void ClearGizmoMoveStaticMesh()
|
||||
{
|
||||
SAFE_CLEAR(sm_gizmo_move);
|
||||
}
|
||||
|
||||
bool InitGizmoMoveStaticMesh()
|
||||
{
|
||||
Renderable *sphere=GetGizmoRenderable(GizmoShape::Sphere,GizmoColor::White);
|
||||
Renderable *cylinder[3]
|
||||
{
|
||||
GetGizmoRenderable(GizmoShape::Cylinder,GizmoColor::Red),
|
||||
GetGizmoRenderable(GizmoShape::Cylinder,GizmoColor::Green),
|
||||
GetGizmoRenderable(GizmoShape::Cylinder,GizmoColor::Blue),
|
||||
};
|
||||
|
||||
Renderable *cone[3]
|
||||
{
|
||||
GetGizmoRenderable(GizmoShape::Cone,GizmoColor::Red),
|
||||
GetGizmoRenderable(GizmoShape::Cone,GizmoColor::Green),
|
||||
GetGizmoRenderable(GizmoShape::Cone,GizmoColor::Blue),
|
||||
};
|
||||
|
||||
if(!sphere)
|
||||
return(false);
|
||||
|
||||
for(int i=0;i<3;i++)
|
||||
{
|
||||
if(!cylinder[i])
|
||||
return(false);
|
||||
|
||||
if(!cone[i])
|
||||
return(false);
|
||||
}
|
||||
|
||||
{
|
||||
SceneNode *root_node=new SceneNode(sphere);
|
||||
|
||||
root_node->CreateSubNode(scale(9,1,1),cylinder[0]);
|
||||
|
||||
{
|
||||
Transform tm;
|
||||
|
||||
tm.SetTranslation(Vector3f(0,0,4.5f));
|
||||
root_node->CreateSubNode(tm.GetMatrix(),cylinder[2]); //Z 向上圆柱
|
||||
|
||||
tm.SetTranslation(Vector3f(0,0,9.5f));
|
||||
root_node->CreateSubNode(tm.GetMatrix(),cone[2]); //Z 向上圆锥
|
||||
|
||||
tm.SetRotation(AxisVector::Y,90);
|
||||
tm.SetTranslation(Vector3f(4.5f,0,0));
|
||||
|
||||
root_node->CreateSubNode(tm.GetMatrix(),cylinder[0]); //X 向右圆柱
|
||||
|
||||
tm.SetTranslation(Vector3f(9.5f,0,0));
|
||||
root_node->CreateSubNode(tm.GetMatrix(),cone[0]); //X 向右圆锥
|
||||
|
||||
tm.SetRotation(AxisVector::X,90);
|
||||
tm.SetTranslation(Vector3f(0,4.5f,0));
|
||||
|
||||
root_node->CreateSubNode(tm.GetMatrix(),cylinder[1]); //Y 向前圆柱
|
||||
|
||||
tm.SetTranslation(Vector3f(0,9.5f,0));
|
||||
root_node->CreateSubNode(tm.GetMatrix(),cone[1]); //Y 向前圆锥
|
||||
}
|
||||
|
||||
sm_gizmo_move=CreateGizmoStaticMesh(root_node);
|
||||
}
|
||||
|
||||
if(!sm_gizmo_move)
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
VK_NAMESPACE_END
|
||||
|
@ -12,6 +12,9 @@
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
bool InitGizmoMoveStaticMesh();
|
||||
void ClearGizmoMoveStaticMesh();
|
||||
|
||||
namespace
|
||||
{
|
||||
static RenderResource * gizmo_rr=nullptr;
|
||||
@ -109,9 +112,9 @@ namespace
|
||||
if(!gizmo_line.vdm)
|
||||
return(false);
|
||||
|
||||
if(!gizmo_line.vdm->Init( HGL_SIZE_1MB, //最大顶点数量
|
||||
HGL_SIZE_1MB, //最大索引数量
|
||||
IndexType::U16)) //索引类型
|
||||
if(!gizmo_line.vdm->Init( HGL_SIZE_1MB, //最大顶点数量
|
||||
HGL_SIZE_1MB, //最大索引数量
|
||||
IndexType::U16)) //索引类型
|
||||
return(false);
|
||||
}
|
||||
|
||||
@ -238,11 +241,15 @@ bool InitGizmoResource(GPUDevice *device)
|
||||
if(!InitGizmoResource2D(device))
|
||||
return(false);
|
||||
|
||||
InitGizmoMoveStaticMesh();
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void FreeGizmoResource()
|
||||
{
|
||||
ClearGizmoMoveStaticMesh();
|
||||
|
||||
for(GizmoRenderable &gr:gizmo_rederable)
|
||||
{
|
||||
SAFE_CLEAR(gr.prim)
|
||||
|
@ -6,6 +6,8 @@ using namespace hgl::graph;
|
||||
|
||||
class TestApp:public SceneAppFramework
|
||||
{
|
||||
StaticMesh *sm=nullptr;
|
||||
|
||||
private:
|
||||
|
||||
bool InitGizmo()
|
||||
@ -13,6 +15,8 @@ private:
|
||||
if(!InitGizmoResource(device))
|
||||
return(false);
|
||||
|
||||
sm=GetGizmoMoveStaticMesh();
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@ -26,6 +30,13 @@ public:
|
||||
if(!InitGizmo())
|
||||
return(false);
|
||||
|
||||
camera->pos=Vector3f(32,32,32);
|
||||
camera_control->SetTarget(Vector3f(0,0,0));
|
||||
camera_control->Refresh();
|
||||
|
||||
render_root.RefreshMatrix();
|
||||
render_list->Expend(sm->GetScene());
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VKRenderable.h>
|
||||
#include<hgl/type/SortedSets.h>
|
||||
@ -22,5 +22,9 @@ public:
|
||||
virtual ~StaticMesh();
|
||||
|
||||
static StaticMesh *CreateNewObject(RenderResource *,SceneNode *);
|
||||
|
||||
public:
|
||||
|
||||
SceneNode *GetScene(){return root_node;}
|
||||
};//class StaticMesh
|
||||
VK_NAMESPACE_END
|
||||
|
@ -115,6 +115,8 @@ class IndirectDispatchBuffer;
|
||||
|
||||
class RenderResource;
|
||||
|
||||
class StaticMesh;
|
||||
|
||||
enum class SharingMode
|
||||
{
|
||||
Exclusive = 0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user