Working version, no shadows

This commit is contained in:
2022-04-24 09:00:55 +03:00
parent 583f4bb4f3
commit a0deddb660
5 changed files with 182 additions and 66 deletions
+22 -31
View File
@@ -1,3 +1,5 @@
#include <memory>
#include "peripherals_glfw.h"
#include "demo/demo_engine.h"
#include "timer.h"
@@ -10,6 +12,7 @@ INITIALIZE_EASYLOGGINGPP
int main() {
acidrain::peripherals_glfw peripherals;
peripherals.init();
LOG(INFO) << "peripherals initialized";
glDisable(GL_DEPTH_TEST);
@@ -33,7 +36,7 @@ int main() {
demo_data::meshes.push_back(mesh_generator::grid(30, 30));
demo_data::meshes.push_back(mesh_generator::cube());
auto mat = shared_ptr<material>(new material());
auto mat = std::make_shared<material>();
mat->ambient = glm::vec4(0, 0, 0.15, 1);
mat->diffuse = glm::vec4(1, 1, 1, 1);
// material->diffuse = glm::vec4(1, 0, 0, 1);
@@ -102,10 +105,10 @@ int main() {
demoPartScene.cameraName = "cam1";
demoPartScene.lightName = "light1";
scene *scene1 = new scene();
auto *scene1 = new scene();
demoPartScene.scene_ = shared_ptr<scene>(scene1);
auto smallSphere = shared_ptr<mesh_node>(new mesh_node());
auto smallSphere = std::make_shared<mesh_node>();
smallSphere->mesh_ = demo_data::meshes[1];
smallSphere->material_ = demo_data::materials[0];
smallSphere->position = glm::vec3(0, 0, 0);
@@ -201,26 +204,26 @@ int main() {
glBindFramebuffer(GL_FRAMEBUFFER, 0);
timer timer1;
while (!peripherals.should_close() && timer1.seconds_since_start() < DEMO_LENGTH_IN_SECONDS) {
double elapsedSeconds = timer1.seconds_since_start();
// bigSphere->mesh_ = mesh_generator::extrude(mesh_generator::sphere(50, 50), {200, 201, 100, 101, 400, 401}, 0.05,
// (int) ((sin(elapsedSeconds) + 0.5) * 40));
//
// smallSphere->position = glm::vec3(0, sin(2 * M_PI * 0.13 * elapsedSeconds) * 2.0 + 0.5, 0);
//// meshNode->position = glm::vec3(0, 0.001, 0);
// // camNode->target = glm::vec3(0, 0.0001, 0);
// // camNode->position = glm::vec3(0, 5, -10);
// lightNode2->position = glm::vec3(5 * sin(2 * M_PI * 0.15 * elapsedSeconds), 2,
// 5 * cos(2 * M_PI * 0.15 * elapsedSeconds));
// lightNode->position = glm::vec3(5 * cos(2 * M_PI * 0.75 * elapsedSeconds), 2,
// 5 * sin(2 * M_PI * 0.75 * elapsedSeconds));
//
// lightMeshNode->position = lightNode2->position;
//
// bigSphere->rotation *= angleAxis((float) (M_PI / 4.0 * timer1.lap()), normalize(glm::vec3(0.2, 0.5, 0.3)));
bigSphere->mesh_ = mesh_generator::extrude(mesh_generator::sphere(50, 50), {200, 201, 100, 101, 400, 401}, 0.05,
(int) ((sin(elapsedSeconds) + 0.5) * 40));
smallSphere->position = glm::vec3(0, sin(2 * M_PI * 0.13 * elapsedSeconds) * 2.0 + 0.5, 0);
// meshNode->position = glm::vec3(0, 0.001, 0);
// camNode->target = glm::vec3(0, 0.0001, 0);
// camNode->position = glm::vec3(0, 5, -10);
lightNode2->position = glm::vec3(5 * sin(2 * M_PI * 0.15 * elapsedSeconds), 2,
5 * cos(2 * M_PI * 0.15 * elapsedSeconds));
lightNode->position = glm::vec3(5 * cos(2 * M_PI * 0.75 * elapsedSeconds), 2,
5 * sin(2 * M_PI * 0.75 * elapsedSeconds));
lightMeshNode->position = lightNode2->position;
bigSphere->rotation *= angleAxis((float) (M_PI / 4.0 * timer1.lap()), normalize(glm::vec3(0.2, 0.5, 0.3)));
demoPartClear.process(demoPartClear.normalizeTime(elapsedSeconds));
demoPartScene.process(demoPartScene.normalizeTime(elapsedSeconds));
@@ -228,16 +231,4 @@ int main() {
peripherals.swap_buffers();
peripherals.poll_events();
}
// double alpha = 0.0;
// while (!peripherals.should_close()) {
// alpha += 0.01;
// if (alpha > 1.0) alpha = 0.0;
//
// glClearColor(0.0 * alpha, 0.1 * alpha, 1.0 * alpha, 1 * alpha);
// glClear(GL_COLOR_BUFFER_BIT);
//
// peripherals.swap_buffers();
// peripherals.poll_events();
// }
}