Commit 2e68a646 authored by Florian Oetke's avatar Florian Oetke
Browse files

tweaked camera position and attached light source to camera

parent f8a2378d
......@@ -8,8 +8,8 @@
"Viewtarget": {
"offset": {
"x": 0.0,
"y": 10.0,
"z": 1.0
"y": 15.0,
"z": 4.0
}
},
"Spring": {
......
......@@ -4,6 +4,7 @@
#include "../gameplay/player_comp.hpp"
#include "../gameplay/rigid_body_comp.hpp"
#include "../gameplay/viewtarget_comp.hpp"
#include "../helper/attachment_comp.hpp"
#include <mirrage/ecs/components/transform_comp.hpp>
#include <mirrage/ecs/ecs.hpp>
......@@ -26,19 +27,31 @@ namespace phase_shifter::level {
auto cam_azimuth = 0.0f;
auto cam_dir = glm::quat(glm::vec3(
(cam_elevation - 2.f) * glm::pi<float>() / 2.f, glm::pi<float>() * cam_azimuth, 0.f));
_entities.entity_builder("camera")
.rotation(cam_dir)
.position(glm::rotate(cam_dir, glm::vec3(0, 0, -1)) * 8.f + position)
.post_create([=](ecs::Entity_facet entity) {
entity.process<Transform_comp>([&](auto& transform) {
transform.position = transform.direction() * -15.f + position;
transform.look_at(position);
});
entity.process([=](gameplay::Viewtarget_comp& viewtarget) {
viewtarget.target = playerhandle;
});
})
.create();
auto camera = _entities.entity_builder("camera")
.rotation(cam_dir)
.position(glm::rotate(cam_dir, glm::vec3(0, 0, -1)) * 8.f + position)
.post_create([=](ecs::Entity_facet entity) {
entity.process<Transform_comp>([&](auto& transform) {
transform.position = transform.direction() * -15.f + position;
transform.look_at(position);
});
entity.process([=](gameplay::Viewtarget_comp& viewtarget) {
viewtarget.target = playerhandle;
});
})
.create();
auto sun_elevation = 0.2f * glm::pi<float>();
auto sun_azimuth = -0.2f;
auto sun_dir = glm::quat(glm::vec3(
(sun_elevation - 2.f) * glm::pi<float>() / 2.f, glm::pi<float>() * sun_azimuth, 0.f));
_entities.entity_builder("sun")
.rotation(sun_dir)
.position(glm::rotate(sun_dir, glm::vec3(0, 0, 1)) * 40.f)
.create()
.emplace<helper::Attachment_comp>(camera.handle(),
glm::rotate(sun_dir, glm::vec3(0, 0, 1)) * 40.f);
});
}
......
......@@ -85,21 +85,10 @@ namespace phase_shifter {
}
});
_level_system->load("dummy");
// TODO: replace with level-loading / generation code
auto sun_elevation = 0.05f * glm::pi<float>();
auto sun_azimuth = 0.7f;
auto sun_dir = glm::quat(glm::vec3(
(sun_elevation - 2.f) * glm::pi<float>() / 2.f, glm::pi<float>() * sun_azimuth, 0.f));
entities()
.entity_builder("sun")
.rotation(sun_dir)
.position(glm::rotate(sun_dir, glm::vec3(0, 0, 1)) * 40.f)
.create();
// TODO: remove
entities().entity_builder("test_particle_emitter").position(glm::vec3(11, 0, 11)).create();
_level_system->load("dummy");
}
Meta_system::~Meta_system()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment