Adding a really basic ambient light component
This commit is contained in:
@ -21,28 +21,36 @@ Entity cube;
|
||||
* - USe to initialize the game/sandbox/demo
|
||||
*/
|
||||
void Start() {
|
||||
|
||||
cube = scene.AddEntity((std::string&)"cube");
|
||||
auto& render3DComponent = cube.AddComponent<BarinkEngine::Render3DComponent>();
|
||||
auto importer = BarinkEngine::ModelImporter();
|
||||
|
||||
// Load in asset(S)
|
||||
object = importer.Import("build/Debug/Models/Cube.obj");
|
||||
renderable = object->renderable;
|
||||
|
||||
|
||||
// Add Entities to the scene
|
||||
cube = scene.AddEntity("cube");
|
||||
auto& render3DComponent = cube.AddComponent<BarinkEngine::Render3DComponent>();
|
||||
render3DComponent.mesh = *renderable->mesh;
|
||||
cube.GetComponent<BarinkEngine::TransformComponent>()
|
||||
.transform = glm::rotate(glm::mat4(1.0f), 32.0f, glm::vec3(0.5f,1.0f,0.0f));
|
||||
|
||||
|
||||
// Create a second cube
|
||||
|
||||
auto cube2 = scene.AddEntity((std::string&)"Cube2");
|
||||
auto cube2 = scene.AddEntity("Cube2");
|
||||
auto& cube2Render = cube2.AddComponent<BarinkEngine::Render3DComponent>();
|
||||
cube2Render.mesh = *renderable->mesh;
|
||||
cube2Render.color = glm::vec3(0.0f, 1.0f, 0.0f);
|
||||
auto& cube2Trans = cube2.GetComponent<BarinkEngine::TransformComponent>();
|
||||
cube2Trans.transform = glm::translate( glm::mat4(1.0f), glm::vec3(1.0f,0.0f, 5.0f));
|
||||
|
||||
|
||||
// Create a light
|
||||
auto AmbientLight = scene.AddEntity("AmbientLight");
|
||||
AmbientLight.AddComponent<BarinkEngine::LightComponent>();
|
||||
|
||||
|
||||
|
||||
renderer.Prepare(scene);
|
||||
|
||||
|
||||
@ -53,6 +61,7 @@ void Start() {
|
||||
|
||||
|
||||
|
||||
bool showImGuiMetrics = false;
|
||||
/*
|
||||
* Runs every frame
|
||||
* - Use to draw Immediate mode graphics (Not meant for HUD's )
|
||||
@ -62,16 +71,47 @@ void ImmediateGraphicsDraw()
|
||||
// Show internal BarinkEngine stats
|
||||
ShowStats();
|
||||
|
||||
ImGui::Begin("Render edit");
|
||||
ImGui::Begin("Scene view");
|
||||
auto group = scene.getReg().view<BarinkEngine::IdentifierComponent>();
|
||||
group.each([](auto entity, BarinkEngine::IdentifierComponent& identifier) {
|
||||
|
||||
auto& a = cube.GetComponent<BarinkEngine::Render3DComponent>();
|
||||
ImGui::Text("%s", identifier.name.c_str());
|
||||
|
||||
});
|
||||
ImGui::End();
|
||||
|
||||
ImGui::DragFloat3("Color", &a.color[0], 0.01f, 0.0f, 1.0f);
|
||||
|
||||
ImGui::Begin("Settings");
|
||||
|
||||
|
||||
if (ImGui::Button("ImGui Debug"))
|
||||
{
|
||||
std::cout << "Click!" << std::endl;
|
||||
showImGuiMetrics = true;
|
||||
}
|
||||
ImGui::ShowMetricsWindow(&showImGuiMetrics);
|
||||
|
||||
auto& a = cube.GetComponent<BarinkEngine::Render3DComponent>();
|
||||
|
||||
auto& b = cube.GetComponent<BarinkEngine::TransformComponent>();
|
||||
|
||||
ImGui::DragFloat3("Color", &a.color[0], 0.01f, 0.0f, 1.0f);
|
||||
|
||||
ImGui::DragFloat3("Position", &b.transform[3][0], 0.01f, 0.0f, 16.0f);
|
||||
|
||||
auto l = scene.getReg().view<BarinkEngine::LightComponent>();
|
||||
l.each([](auto entity, BarinkEngine::LightComponent& light) {
|
||||
ImGui::Text("Lighting");
|
||||
ImGui::SliderFloat("Intensity", &light.Strength, 0.0f, 1.0f);
|
||||
ImGui::SliderFloat3("l-Color", &light.Color[0], 0.0f, 1.0f);
|
||||
|
||||
});
|
||||
|
||||
|
||||
ImGui::End();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user