store maincamera entity and rework base level setup
This commit is contained in:
parent
c1fa4c62ce
commit
64171da71a
|
|
@ -76,6 +76,8 @@ namespace Nz
|
|||
OnActionRegistered(properties);
|
||||
}
|
||||
|
||||
inline entt::handle GetMainCamera() { return m_mainCamera; }
|
||||
|
||||
private:
|
||||
static EditorBaseApplication* s_instance;
|
||||
|
||||
|
|
@ -88,5 +90,6 @@ namespace Nz
|
|||
Nz::EditorLogger* m_logger;
|
||||
|
||||
Nz::Level m_level;
|
||||
entt::handle m_mainCamera;
|
||||
};
|
||||
}
|
||||
|
|
@ -84,9 +84,9 @@ namespace Nz
|
|||
if (bRes)
|
||||
{
|
||||
// configure camera
|
||||
auto camera = CreateEntity("Camera");
|
||||
auto& cmp = camera.get<Nz::EditorNameComponent>();
|
||||
//cmp.SetFlags(EditorEntityFlags_Hidden);
|
||||
m_mainCamera = CreateEntity("MainCamera");
|
||||
auto& cmp = m_mainCamera.get<Nz::EditorNameComponent>();
|
||||
cmp.SetFlags(EditorEntityFlags_Hidden);
|
||||
|
||||
auto& cameraComponent = camera.emplace<Nz::CameraComponent>(m_windowSwapchain.get(), Nz::ProjectionType::Perspective);
|
||||
cameraComponent.UpdateFOV(70.f);
|
||||
|
|
|
|||
|
|
@ -41,10 +41,12 @@ namespace NzEditor
|
|||
auto directional = CreateEntity("SunLight");
|
||||
Nz::LightComponent& lightComponent = directional.emplace<Nz::LightComponent>();
|
||||
Nz::DirectionalLight& light = lightComponent.AddLight<Nz::DirectionalLight>();
|
||||
light.UpdateRotation(Nz::EulerAnglesf(-45.f, 0.f, 0.f));
|
||||
light.UpdateRotation(Nz::Quaternionf::LookAt(Nz::Vector3f(-1, 0, -1), Nz::Vector3f::Up()));
|
||||
light.EnableShadowCasting(true);
|
||||
}
|
||||
{
|
||||
auto cube = CreateEntity("Cube");
|
||||
cube.get<Nz::NodeComponent>().SetPosition(Nz::Vector3f(0, 0, 0));
|
||||
Nz::GraphicsComponent& graphicsComponent = cube.emplace<Nz::GraphicsComponent>();
|
||||
|
||||
std::shared_ptr<Nz::GraphicalMesh> boxMesh = Nz::GraphicalMesh::Build(Nz::Primitive::Box(Nz::Vector3f(1.f), Nz::Vector3ui::Zero(), Nz::Matrix4f::Scale(Nz::Vector3f(1.f)), Nz::Rectf(0.f, 0.f, 2.f, 2.f)));
|
||||
|
|
@ -55,6 +57,10 @@ namespace NzEditor
|
|||
boxModel->SetMaterial(0, std::move(boxMat));
|
||||
graphicsComponent.AttachRenderable(boxModel);
|
||||
}
|
||||
|
||||
GetMainCamera().get<Nz::NodeComponent>().SetPosition(-5, 0, 0);
|
||||
GetMainCamera().get<Nz::NodeComponent>().SetRotation(Nz::Quaternionf::LookAt(Nz::Vector3f(1, 0, 0), Nz::Vector3f::Up()));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue