gizmo's scale/move/rotate to use same Value.
This commit is contained in:
parent
3f37fec8a8
commit
ca6d99b6fb
2
CMCore
2
CMCore
@ -1 +1 @@
|
|||||||
Subproject commit 97743adb3f36fdda659b584e6ff93773b2a85f2a
|
Subproject commit 0ac2a9431a14767c018f6f20a8ea0a3604b859ee
|
@ -91,50 +91,50 @@ bool InitGizmoMoveStaticMesh()
|
|||||||
|
|
||||||
const Vector3f one_scale(1);
|
const Vector3f one_scale(1);
|
||||||
const Vector3f plane_scale(2);
|
const Vector3f plane_scale(2);
|
||||||
const Vector3f cylinder_scale(0.35f,0.35f,4.0f);
|
const Vector3f cylinder_scale(GIZMO_CYLINDER_RADIUS,GIZMO_CYLINDER_RADIUS,GIZMO_CYLINDER_HALF_LENGTH);
|
||||||
|
|
||||||
{
|
{
|
||||||
tm.SetScale(cylinder_scale);
|
tm.SetScale(cylinder_scale);
|
||||||
tm.SetTranslation(0,0,4.5f);
|
tm.SetTranslation(0,0,GIZMO_CYLINDER_OFFSET);
|
||||||
root_node->CreateSubNode(tm,cylinder[2]); //Z 向上圆柱
|
root_node->CreateSubNode(tm,cylinder[2]); //Z 向上圆柱
|
||||||
|
|
||||||
tm.SetScale(one_scale);
|
tm.SetScale(one_scale);
|
||||||
tm.SetTranslation(0,0,9.5f);
|
tm.SetTranslation(0,0,GIZMO_CONE_OFFSET);
|
||||||
root_node->CreateSubNode(tm,cone[2]); //Z 向上圆锥
|
root_node->CreateSubNode(tm,cone[2]); //Z 向上圆锥
|
||||||
|
|
||||||
tm.SetScale(plane_scale);
|
tm.SetScale(plane_scale);
|
||||||
tm.SetTranslation(5,5,0);
|
tm.SetTranslation(GIZMO_TWO_AXIS_OFFSET,GIZMO_TWO_AXIS_OFFSET,0);
|
||||||
root_node->CreateSubNode(tm,plane[2]);
|
root_node->CreateSubNode(tm,plane[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
tm.SetScale(cylinder_scale);
|
tm.SetScale(cylinder_scale);
|
||||||
tm.SetRotation(AxisVector::Y,90);
|
tm.SetRotation(AxisVector::Y,90);
|
||||||
tm.SetTranslation(4.5f,0,0);
|
tm.SetTranslation(GIZMO_CYLINDER_OFFSET,0,0);
|
||||||
root_node->CreateSubNode(tm,cylinder[0]); //X 向右圆柱
|
root_node->CreateSubNode(tm,cylinder[0]); //X 向右圆柱
|
||||||
|
|
||||||
tm.SetScale(one_scale);
|
tm.SetScale(one_scale);
|
||||||
tm.SetTranslation(9.5f,0,0);
|
tm.SetTranslation(GIZMO_CONE_OFFSET,0,0);
|
||||||
root_node->CreateSubNode(tm,cone[0]); //X 向右圆锥
|
root_node->CreateSubNode(tm,cone[0]); //X 向右圆锥
|
||||||
|
|
||||||
tm.SetScale(plane_scale);
|
tm.SetScale(plane_scale);
|
||||||
tm.SetTranslation(0,5,5);
|
tm.SetTranslation(0,GIZMO_TWO_AXIS_OFFSET,GIZMO_TWO_AXIS_OFFSET);
|
||||||
root_node->CreateSubNode(tm,plane[0]);
|
root_node->CreateSubNode(tm,plane[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
tm.SetScale(cylinder_scale);
|
tm.SetScale(cylinder_scale);
|
||||||
tm.SetRotation(AxisVector::X,-90);
|
tm.SetRotation(AxisVector::X,-90);
|
||||||
tm.SetTranslation(0,4.5f,0);
|
tm.SetTranslation(0,GIZMO_CYLINDER_OFFSET,0);
|
||||||
|
|
||||||
root_node->CreateSubNode(tm,cylinder[1]); //Y 向前圆柱
|
root_node->CreateSubNode(tm,cylinder[1]); //Y 向前圆柱
|
||||||
|
|
||||||
tm.SetScale(one_scale);
|
tm.SetScale(one_scale);
|
||||||
tm.SetTranslation(0,9.5f,0);
|
tm.SetTranslation(0,GIZMO_CONE_OFFSET,0);
|
||||||
root_node->CreateSubNode(tm,cone[1]); //Y 向前圆锥
|
root_node->CreateSubNode(tm,cone[1]); //Y 向前圆锥
|
||||||
|
|
||||||
tm.SetScale(plane_scale);
|
tm.SetScale(plane_scale);
|
||||||
tm.SetTranslation(5,0,5);
|
tm.SetTranslation(GIZMO_TWO_AXIS_OFFSET,0,GIZMO_TWO_AXIS_OFFSET);
|
||||||
root_node->CreateSubNode(tm,plane[1]);
|
root_node->CreateSubNode(tm,plane[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ bool InitGizmoRotateStaticMesh()
|
|||||||
{
|
{
|
||||||
Transform tm;
|
Transform tm;
|
||||||
|
|
||||||
tm.SetScale(10.0f);
|
tm.SetScale(GIZMO_ARROW_LENGTH);
|
||||||
|
|
||||||
root_node->CreateSubNode(tm,torus[0]);
|
root_node->CreateSubNode(tm,torus[0]);
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ void ClearGizmoScaleStaticMesh()
|
|||||||
|
|
||||||
bool InitGizmoScaleStaticMesh()
|
bool InitGizmoScaleStaticMesh()
|
||||||
{
|
{
|
||||||
Renderable *sphere=GetGizmoRenderable(GizmoShape::Sphere,GizmoColor::White);
|
Renderable *center_cube=GetGizmoRenderable(GizmoShape::Cube,GizmoColor::White);
|
||||||
Renderable *cylinder[3]
|
Renderable *cylinder[3]
|
||||||
{
|
{
|
||||||
GetGizmoRenderable(GizmoShape::Cylinder,GizmoColor::Red),
|
GetGizmoRenderable(GizmoShape::Cylinder,GizmoColor::Red),
|
||||||
@ -66,7 +66,7 @@ bool InitGizmoScaleStaticMesh()
|
|||||||
GetGizmoRenderable(GizmoShape::Plane,GizmoColor::Blue)
|
GetGizmoRenderable(GizmoShape::Plane,GizmoColor::Blue)
|
||||||
};
|
};
|
||||||
|
|
||||||
if(!sphere)
|
if(!center_cube)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
for(int i=0;i<3;i++)
|
for(int i=0;i<3;i++)
|
||||||
@ -82,57 +82,59 @@ bool InitGizmoScaleStaticMesh()
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
SceneNode *root_node=new SceneNode(scale(0.5f),sphere);
|
SceneNode *root_node=new SceneNode();
|
||||||
|
|
||||||
|
root_node->CreateSubNode(scale(GIZMO_CENTER_SPHERE_RADIUS*2),center_cube);
|
||||||
|
|
||||||
{
|
{
|
||||||
Transform tm;
|
Transform tm;
|
||||||
|
|
||||||
const Vector3f one_scale(2);
|
const Vector3f one_scale(1);
|
||||||
const Vector3f plane_scale(2);
|
const Vector3f plane_scale(2);
|
||||||
const Vector3f cylinder_scale(0.35f,0.35f,4.0f);
|
const Vector3f cylinder_scale(GIZMO_CYLINDER_RADIUS,GIZMO_CYLINDER_RADIUS,GIZMO_CYLINDER_HALF_LENGTH);
|
||||||
|
|
||||||
{
|
{
|
||||||
tm.SetScale(cylinder_scale);
|
tm.SetScale(cylinder_scale);
|
||||||
tm.SetTranslation(0,0,4.5f);
|
tm.SetTranslation(0,0,GIZMO_CYLINDER_OFFSET);
|
||||||
root_node->CreateSubNode(tm,cylinder[2]); //Z 向上圆柱
|
root_node->CreateSubNode(tm,cylinder[2]); //Z 向上圆柱
|
||||||
|
|
||||||
tm.SetScale(one_scale);
|
tm.SetScale(one_scale);
|
||||||
tm.SetTranslation(0,0,9.5f);
|
tm.SetTranslation(0,0,GIZMO_CONE_OFFSET);
|
||||||
root_node->CreateSubNode(tm,cube[2]); //Z 向上圆锥
|
root_node->CreateSubNode(tm,cube[2]); //Z 向上圆锥
|
||||||
|
|
||||||
tm.SetScale(plane_scale);
|
tm.SetScale(plane_scale);
|
||||||
tm.SetTranslation(5,5,0);
|
tm.SetTranslation(GIZMO_TWO_AXIS_OFFSET,GIZMO_TWO_AXIS_OFFSET,0);
|
||||||
root_node->CreateSubNode(tm,plane[2]);
|
root_node->CreateSubNode(tm,plane[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
tm.SetScale(cylinder_scale);
|
tm.SetScale(cylinder_scale);
|
||||||
tm.SetRotation(AxisVector::Y,90);
|
tm.SetRotation(AxisVector::Y,90);
|
||||||
tm.SetTranslation(4.5f,0,0);
|
tm.SetTranslation(GIZMO_CYLINDER_OFFSET,0,0);
|
||||||
root_node->CreateSubNode(tm,cylinder[0]); //X 向右圆柱
|
root_node->CreateSubNode(tm,cylinder[0]); //X 向右圆柱
|
||||||
|
|
||||||
tm.SetScale(one_scale);
|
tm.SetScale(one_scale);
|
||||||
tm.SetTranslation(9.5f,0,0);
|
tm.SetTranslation(GIZMO_CONE_OFFSET,0,0);
|
||||||
root_node->CreateSubNode(tm,cube[0]); //X 向右圆锥
|
root_node->CreateSubNode(tm,cube[0]); //X 向右圆锥
|
||||||
|
|
||||||
tm.SetScale(plane_scale);
|
tm.SetScale(plane_scale);
|
||||||
tm.SetTranslation(0,5,5);
|
tm.SetTranslation(0,GIZMO_TWO_AXIS_OFFSET,GIZMO_TWO_AXIS_OFFSET);
|
||||||
root_node->CreateSubNode(tm,plane[0]);
|
root_node->CreateSubNode(tm,plane[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
tm.SetScale(cylinder_scale);
|
tm.SetScale(cylinder_scale);
|
||||||
tm.SetRotation(AxisVector::X,-90);
|
tm.SetRotation(AxisVector::X,-90);
|
||||||
tm.SetTranslation(0,4.5f,0);
|
tm.SetTranslation(0,GIZMO_CYLINDER_OFFSET,0);
|
||||||
|
|
||||||
root_node->CreateSubNode(tm,cylinder[1]); //Y 向前圆柱
|
root_node->CreateSubNode(tm,cylinder[1]); //Y 向前圆柱
|
||||||
|
|
||||||
tm.SetScale(one_scale);
|
tm.SetScale(one_scale);
|
||||||
tm.SetTranslation(0,9.5f,0);
|
tm.SetTranslation(0,GIZMO_CONE_OFFSET,0);
|
||||||
root_node->CreateSubNode(tm,cube[1]); //Y 向前圆锥
|
root_node->CreateSubNode(tm,cube[1]); //Y 向前圆锥
|
||||||
|
|
||||||
tm.SetScale(plane_scale);
|
tm.SetScale(plane_scale);
|
||||||
tm.SetTranslation(5,0,5);
|
tm.SetTranslation(GIZMO_TWO_AXIS_OFFSET,0,GIZMO_TWO_AXIS_OFFSET);
|
||||||
root_node->CreateSubNode(tm,plane[1]);
|
root_node->CreateSubNode(tm,plane[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ namespace
|
|||||||
{
|
{
|
||||||
ConeCreateInfo cci;
|
ConeCreateInfo cci;
|
||||||
|
|
||||||
cci.radius =1; //圆锥半径
|
cci.radius =GIZMO_CONE_RADIUS; //圆锥半径
|
||||||
cci.halfExtend =1; //圆锤一半高度
|
cci.halfExtend =1; //圆锤一半高度
|
||||||
cci.numberSlices=16; //圆锥底部分割数
|
cci.numberSlices=16; //圆锥底部分割数
|
||||||
cci.numberStacks=3; //圆锥高度分割数
|
cci.numberStacks=3; //圆锥高度分割数
|
||||||
|
@ -20,6 +20,21 @@ constexpr const COLOR gizmo_color[size_t(GizmoColor::RANGE_SIZE)]=
|
|||||||
COLOR::BlenderYellow,
|
COLOR::BlenderYellow,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constexpr const float GIZMO_ARROW_LENGTH=10; ///<箭头整体长度
|
||||||
|
constexpr const float GIZMO_CENTER_SPHERE_RADIUS=1.0f; ///<中心球半径
|
||||||
|
|
||||||
|
constexpr const float GIZMO_CONE_LENGTH=1.0f; ///<圆锥高度
|
||||||
|
constexpr const float GIZMO_CONE_RADIUS=1.0f; ///<圆锥底部半径
|
||||||
|
constexpr const float GIZMO_CONE_OFFSET=GIZMO_ARROW_LENGTH-(GIZMO_CONE_LENGTH/2.0f); ///<圆锥偏移量
|
||||||
|
|
||||||
|
constexpr const float GIZMO_CYLINDER_RADIUS=0.25f; ///<圆柱半径
|
||||||
|
constexpr const float GIZMO_CYLINDER_LENGTH=GIZMO_ARROW_LENGTH-GIZMO_CENTER_SPHERE_RADIUS-GIZMO_CONE_LENGTH; ///<圆柱长度
|
||||||
|
|
||||||
|
constexpr const float GIZMO_CYLINDER_HALF_LENGTH=GIZMO_CYLINDER_LENGTH/2.0f; ///<圆柱一半长度
|
||||||
|
constexpr const float GIZMO_CYLINDER_OFFSET=GIZMO_CYLINDER_HALF_LENGTH+GIZMO_CENTER_SPHERE_RADIUS; ///<圆柱偏移量
|
||||||
|
|
||||||
|
constexpr const float GIZMO_TWO_AXIS_OFFSET=5.0F; ///<二轴调节点偏移量(方片或圆)
|
||||||
|
|
||||||
Renderable *GetGizmoRenderable(const GizmoShape &gs,const GizmoColor &);
|
Renderable *GetGizmoRenderable(const GizmoShape &gs,const GizmoColor &);
|
||||||
|
|
||||||
StaticMesh *CreateGizmoStaticMesh(SceneNode *);
|
StaticMesh *CreateGizmoStaticMesh(SceneNode *);
|
||||||
|
@ -61,6 +61,7 @@ class TestApp:public SceneAppFramework
|
|||||||
|
|
||||||
StaticMesh *sm_move=nullptr;
|
StaticMesh *sm_move=nullptr;
|
||||||
StaticMesh *sm_rotate=nullptr;
|
StaticMesh *sm_rotate=nullptr;
|
||||||
|
StaticMesh *sm_scale=nullptr;
|
||||||
|
|
||||||
Renderable *face_torus=nullptr;
|
Renderable *face_torus=nullptr;
|
||||||
|
|
||||||
@ -73,6 +74,7 @@ private:
|
|||||||
|
|
||||||
sm_move =GetGizmoMoveStaticMesh();
|
sm_move =GetGizmoMoveStaticMesh();
|
||||||
sm_rotate =GetGizmoRotateStaticMesh();
|
sm_rotate =GetGizmoRotateStaticMesh();
|
||||||
|
sm_scale =GetGizmoScaleStaticMesh();
|
||||||
|
|
||||||
face_torus =GetGizmoRenderable(GizmoShape::Torus,GizmoColor::White);
|
face_torus =GetGizmoRenderable(GizmoShape::Torus,GizmoColor::White);
|
||||||
|
|
||||||
@ -88,6 +90,7 @@ private:
|
|||||||
|
|
||||||
root.CreateSubNode(sm_move->GetScene());
|
root.CreateSubNode(sm_move->GetScene());
|
||||||
root.CreateSubNode(sm_rotate->GetScene());
|
root.CreateSubNode(sm_rotate->GetScene());
|
||||||
|
//root.CreateSubNode(sm_scale->GetScene());
|
||||||
|
|
||||||
//{
|
//{
|
||||||
// Transform tm;
|
// Transform tm;
|
||||||
|
2
res
2
res
@ -1 +1 @@
|
|||||||
Subproject commit 475d8ad43ceee084cd24f5d0bed59de9f6aa36fd
|
Subproject commit e1a36d78f0eead5f6bb65493432c4690637b991d
|
@ -44,6 +44,8 @@ namespace hgl
|
|||||||
*/
|
*/
|
||||||
void SceneNode::RefreshMatrix()
|
void SceneNode::RefreshMatrix()
|
||||||
{
|
{
|
||||||
|
SceneOrient::RefreshMatrix();
|
||||||
|
|
||||||
// if (scene_matrix.IsNewestVersion()) //自己不变,不代表下面不变
|
// if (scene_matrix.IsNewestVersion()) //自己不变,不代表下面不变
|
||||||
//return;
|
//return;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user