[WIP] first version of gizmo move test,,can't RUN.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -25,6 +29,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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user