2D세상을 3D 세상으로 확장한다. (MVP)Model (Local to World) → View (Camera) → Projection (Screen)
struct FMatrix
{
float M[4][4]; static const FMatrix Identity;
};
UE5 “Engine\Source\Runtime\Core\Public\Math\Matrix.h”
struct FVector
{
float X;
float Y;
float Z;
float Dot(const FVector& rhs);
FVector Cross(const FVector& rhs);
float Length() const;
void Normalize();
};
struct FVector4
{
float X;
float Y;
float Z;
float W;
float Dot(const FVector4& Other);
float Length();
float Length3();
...
};
cbuffer constants : register(b0)
{
row_major float4x4 MVP;
};
FMatrix MVP;
카메라 좌우, 전후방 이동 (W,A,S,D 키보드), 카메라 Yaw, Pitch 회전 (마우스 클릭)을 구현한다.
3차원 공간 상에서 오브젝트 (기본 Primitive - Plane, Cube, Sphere)을 배치한다.
class USceneComponent: public UObject
{
public:
FVector RelativeLocation;
FVector RelativeRotation;
FVector RelativeScale3D;
};
class UPrimitiveComponent : public USceneComponent
{
};
class UCubeComp : public UPrimitiveComponent
{
};
class USphereComp : public UPrimitiveComponent
{
};
마우스 클릭으로 배치된 오브젝트를 선택한다. (Deprojection, Picking)Vertex Shader를 사용해 해당 오브젝트를 강조 (Highlight) 한다.
World 좌표계, 선택된 오브젝트의 Local 좌표계를 나타내는 3차원 Axis 렌더링 한다.

선택된 오브젝트 Gizmo 컨트롤을 통해 변형 (Transform - Location, Rotation, Scale)이 가능하다.
생성된 오브젝트의 총 개수와 사용된 메모리를 Stat 창(ImGui)를 사용해 나타낸다.
배치된 오브젝트들의 정보를 Json 파일로 저장 후, 불러 들이기를 통해 씬(Scene)을 재구성한다.
{
"Version" : 1,
"NextUUID" : 8,
"Primitives" : {
"0" : {
"Location" : [0.290000, 1.210000, 0.000000],
"Rotation" : [0.000000, 0.000000, 0.000000],
"Scale" : [1.000000, 1.000000, 1.000000],
"Type" : "Sphere"
},
"1" : {
"Location" : [-0.170000, 0.060000, 0.000000],
"Rotation" : [0.000000, 0.000000, 0.000000],
"Scale" : [1.000000, 1.000000, 1.000000],
"Type" : "Sphere"
},
"2" : {
"Location" : [0.330000, -0.290000, 0.000000],
"Rotation" : [0.000000, 0.000000, 0.000000],
"Scale" : [1.000000, 1.000000, 1.000000],
"Type" : "Sphere"
},
"3" : {
"Location" : [-0.140000, 0.030000, 0.000000],
"Rotation" : [0.000000, 0.000000, 0.000000],
"Scale" : [1.000000, 1.000000, 1.000000],
"Type" : "Sphere"
},
"4" : {
"Location" : [-1.060000, 0.620000, 0.240000],
"Rotation" : [0.000000, 0.000000, 0.000000],
"Scale" : [3.000000, 3.000000, 3.000000],
"Type" : "Sphere"
},
"5" : {
"Location" : [0.000000, -0.750000, 1.290000],
"Rotation" : [0.000000, 0.000000, 0.000000],
"Scale" : [100.000000, 1.000000, 100.000000],
"Type" : "Cube"
},
"6" : {
"Location" : [0.290000, 0.420000, 0.000000],
"Rotation" : [0.000000, 0.760000, 0.000000],
"Scale" : [2.000000, 2.000000, 2.000000],
"Type" : "Cube"
},
"7" : {
"Location" : [-0.850000, 1.070000, 2.460000],
"Rotation" : [0.000000, -0.910000, 0.000000],
"Scale" : [3.000000, 3.000000, 3.000000],
"Type" : "Triangle"
}
}
}