From b3c74832b30aaae499223f0a992a2fbc7967b50c Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 4 Dec 2019 20:40:45 +0000 Subject: [PATCH] Light primative --- CMakeLists.txt | 2 +- src/definitions/materials/material.hpp | 6 ++++++ test/lucy_cornell.cpp | 3 ++- test/main.cpp | 20 +++----------------- test/stanford_dragon_cornell.cpp | 12 ++++++------ 5 files changed, 18 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index adeecc9..a2376c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ add_definitions(-DRESOURCES="${CMAKE_SOURCE_DIR}/resources/") set(executable output) set(SrcDIR ./src) set(TestDIR ./test) -set(CurrentTest stanford_dragon_cornell.cpp) +set(CurrentTest main.cpp) set(IncludeDIR ./include) diff --git a/src/definitions/materials/material.hpp b/src/definitions/materials/material.hpp index 990c0ec..aa961f3 100644 --- a/src/definitions/materials/material.hpp +++ b/src/definitions/materials/material.hpp @@ -39,4 +39,10 @@ public: : Material(colour, 0.0f, 0.0f, 1.0f, 0.0f, false, false) { }; }; +class Light : public Material { +public: + Light(glm::vec3 colour, float intensity) + : Material(colour, intensity, 0.0f, 1.0f, 0.0f, false, false) { }; +}; + #endif diff --git a/test/lucy_cornell.cpp b/test/lucy_cornell.cpp index 958d335..124df2e 100644 --- a/test/lucy_cornell.cpp +++ b/test/lucy_cornell.cpp @@ -18,7 +18,8 @@ int main(int argc, char** argv) { Sky* sky = new SolidSky({ 0.0f, 0.0f, 0.0f }, 0.0f); scene->sky = sky; - Material* mat = new GlossyMaterial({ 1.0f, 1.0f, 1.0f }, 0.2f, fastDegreetoRadian(30.0f)); + // Material* mat = new GlossyMaterial({ 1.0f, 1.0f, 1.0f }, 0.2f, fastDegreetoRadian(30.0f)); + Material* mat = new MatteMaterial({ 1.0f, 1.0f, 1.0f }); std::string models = RESOURCES + std::string("//models//"); std::string lucy = RESOURCES + std::string("//models//lucy.obj"); diff --git a/test/main.cpp b/test/main.cpp index c21b139..81c6c31 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -18,26 +18,12 @@ int main(int argc, char** argv) { Scene* scene = new Scene(width, height); - Sky* sky = new GradientSky({ 35.0f / 255.0f, 148.0f / 255.0f, 235.0f / 255.0f }, { 1.0f, 1.0f, 1.0f }, 3.0f); - scene->sky = sky; + scene->sky = new GradientSky({ 35.0f / 255.0f, 148.0f / 255.0f, 235.0f / 255.0f }, { 1.0f, 1.0f, 1.0f }, 3.0f);; scene->camera = new Camera(width, height); - - //Sphere sphere1({ 1.3f, -0.8f, -5.0f }, 0.2f, new Material({ 0.817f, 0.374, 0.574 })); - //scene->objects.push_back(&sphere1); - Sphere sphere({ -2.1f, 0.0f, -8.0f }, 1.0f, new Material({ 0.817f, 0.374, 0.574 }, 0.0f, 0.0f, 0.0f, 0.0f, false, false)); - scene->objects.push_back(&sphere); - Sphere sphere1({ 0.0f, 0.0f, -8.0f }, 1.0f, new GlossyMaterial({ 0.817f, 0.374, 0.574 }, 0.7f, fastDegreetoRadian(30.0f))); - scene->objects.push_back(&sphere1); - Sphere sphere2({ 2.1f, 0.0f, -8.0f }, 1.0f, new GlossyMaterial({ 0.817f, 0.374, 0.574 }, 0.7f, fastDegreetoRadian(60.0f))); - scene->objects.push_back(&sphere2); - - Sphere light({ 35.0f, 50.0f, 25.0f }, 25.0f, new Material({ 1.0f, 1.0f, 1.0f }, 100.0f, 0.0f, 1.5f, 0.0f, false, true)); - scene->objects.push_back(&light); - - Plane plane({ 0.0f, -1.0f, 0.0f }, { 0.0f, -1.0f, 0.0f }, new Material({ 0.2f, 0.2f, 0.2f }, 0.0f, 0.0f, 1.5f, 0.0f, false, false)); - scene->objects.push_back(&plane); + scene->objects.push_back(new Sphere({ 0.0f, 0.0f, -6.0f }, 1.0f, new MatteMaterial({ 0.2f, 0.2f, 0.2f }))); + scene->objects.push_back(new Sphere({ -5.0f, -5.0f, -1.0f }, 1.0f, new Light({ 0.2f, 0.2f, 0.2f }, 5.0f))); inferno.SetScene(scene); diff --git a/test/stanford_dragon_cornell.cpp b/test/stanford_dragon_cornell.cpp index 0532eb4..1cc14e4 100644 --- a/test/stanford_dragon_cornell.cpp +++ b/test/stanford_dragon_cornell.cpp @@ -26,13 +26,13 @@ int main(int argc, char** argv) { std::string cornell = RESOURCES + std::string("//models//cornell-box.obj"); // Material* mat = new GlossyMaterial({ 1.0f, 1.0f, 1.0f }, 0.2f, fastDegreetoRadian(30.0f)); - Material* mat = new MatteMaterial({ 1.0f, 1.0f, 1.0f }); - std::vector tris = LoadTrianglesBasic(dragon, models, mat); + // Material* mat = new MatteMaterial({ 1.0f, 1.0f, 1.0f }); + // std::vector tris = LoadTrianglesBasic(dragon, models, mat); - Mesh* mesh = new Mesh(tris); - mesh->Translate({ 0.01f, -1.0, -3.6f }); - mesh->Optimise(); - scene->meshs.push_back(mesh); + // Mesh* mesh = new Mesh(tris); + // mesh->Translate({ 0.01f, -1.0, -3.6f }); + // mesh->Optimise(); + // scene->meshs.push_back(mesh); std::vector tris1 = LoadTrianglesBasic(cornell, models);