new scene

This commit is contained in:
Ben
2019-12-06 20:56:45 +00:00
parent b3c74832b3
commit 5fc0d2fd33
8 changed files with 900130 additions and 15 deletions

View File

@@ -12,7 +12,7 @@ add_definitions(-DRESOURCES="${CMAKE_SOURCE_DIR}/resources/")
set(executable output)
set(SrcDIR ./src)
set(TestDIR ./test)
set(CurrentTest main.cpp)
set(CurrentTest conference.cpp)
set(IncludeDIR ./include)

View File

@@ -0,0 +1,352 @@
# Blender MTL File: 'None'
# Material Count: 35
newmtl Material__0
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.047059 0.047059 0.047059
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh0_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.639216 0.600000 0.607843
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh10_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.600000 0.600000 0.600000
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh11_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.117647 0.258824 0.149020
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh12_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.427451 0.427451 0.427451
Ks 0.427451 0.427451 0.427451
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh13_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.517647 0.447059 0.337255
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh15_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.447059 0.447059 0.447059
Ks 0.447059 0.447059 0.447059
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh16_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 1.000000 1.000000 1.000000
Ks 0.498039 0.498039 0.498039
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh17_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.498039 0.498039 0.498039
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh18_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.400000 0.400000 0.400000
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh19_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.878431 0.717647 0.576471
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh1_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.639216 0.400000 0.129412
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh20_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.827451 0.698039 0.427451
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh21_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.286275 0.149020 0.129412
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh22_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.078431 0.078431 0.078431
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh23_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.819608 0.086275 0.066667
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh24_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.698039 0.698039 0.698039
Ks 0.698039 0.698039 0.698039
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh25_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.600000 0.600000 0.600000
Ks 0.600000 0.600000 0.600000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh26_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.098039 0.098039 0.098039
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh27_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.466667 0.447059 0.427451
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh28_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.639216 0.439216 0.317647
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh29_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 1.000000 1.000000 1.000000
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh2_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.737255 0.400000 0.156863
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh30_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.058824 0.058824 0.058824
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh31_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.976471 0.176471 0.168627
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh32_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.600000 0.600000 0.600000
Ks 0.600000 0.600000 0.600000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh33_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.478431 0.239216 0.117647
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh34_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.047059 0.047059 0.047059
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh35_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.600000 0.600000 0.600000
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh4_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.176471 0.058824 0.058824
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh5_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.898039 0.898039 0.898039
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh6_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.066667 0.066667 0.066667
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh7_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.698039 0.698039 0.698039
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh8_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.686275 0.427451 0.168627
Ks 0.200000 0.200000 0.200000
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000
newmtl mesh9_SG
Ns 40.000007
Ka 1.000000 1.000000 1.000000
Kd 0.709804 0.709804 0.709804
Ks 0.709804 0.709804 0.709804
Ke 0.0 0.0 0.0
Ni 1.500000
d 1.000000

899720
resources/models/conference.obj Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -74,15 +74,15 @@ bool Box::Hit(Ray* ray) {
float tmin = fmax(fmax(fmin(t1, t2), fmin(t3, t4)), fmin(t5, t6));
float tmax = fmin(fmin(fmax(t1, t2), fmax(t3, t4)), fmax(t5, t6));
if (tmax < 0.0f) {
if (tmax <= 0.0f) {
return false;
}
if (tmin > tmax) {
if (tmin >= tmax) {
return false;
}
return tmin > 0.0f;
return tmin >= 0.0f;
}
void BuildKDTreeSlow(KDTreeSlow*& node, const std::vector<Triangle*>& triangles) {

View File

@@ -32,9 +32,9 @@ void Camera::LookAt(glm::vec3 position, glm::vec3 sky, glm::vec3 lookAt, float a
Ray Camera::CastRay(int x, int y, float spX, float spY) {
// TODO: ACTUALLY GET A WORKING CAMERA
float camX = (((float)x + spX) / (float)width * 2.0f - 1.0f) * getAspectRatio(width, height) * getFovAdjustment(45.0f);
float camX = (((float)x + spX) / (float)width * 2.0f - 1.0f) * getAspectRatio(width, height) * getFovAdjustment(80.0f);
// 1.0 is taken first here as y is in the vertical
float camY = (1.0f - ((float)y + spY) / (float)height * 2.0f) * getFovAdjustment(45.0f);
float camY = (1.0f - ((float)y + spY) / (float)height * 2.0f) * getFovAdjustment(80.0f);
Ray ray{ {0.0f, 0.0f, 0.0f}, {camX, camY, -1.0f} };
ray.direction = glm::normalize(ray.direction);

38
test/conference.cpp Normal file
View File

@@ -0,0 +1,38 @@
#include <iostream>
#include "../src/inferno.hpp"
static const int width = 1000;
static const int height = 1000;
int main(int argc, char** argv) {
InfernoEngine inferno;
inferno.SetMode(MODE_OPERATION_PROGRESSIVE_GUI);
inferno.InitWindow(width, height);
Scene* scene = new Scene(width, height);
scene->camera = new Camera(width, height);
scene->sky = new SolidSky({ 0.0f, 0.0f, 0.0f }, 0.0f);
scene->objects.push_back(new Sphere({ 5000.0f, 1700.0f, 25.0f }, 1000.0f, new Light({ 1.0f, 1.0f, 1.0f }, 1000.0f)));
std::string models = RESOURCES + std::string("//models//");
std::string conference = RESOURCES + std::string("//models//conference.obj");
std::vector<Triangle*> tris1 = LoadTrianglesBasic(conference, models);
Mesh* mesh1 = new Mesh(tris1);
mesh1->Translate({ 0.0f, 1.6f, 0.0f });
mesh1->Optimise();
scene->meshs.push_back(mesh1);
inferno.SetScene(scene);
inferno.Ready();
inferno.Render();
return 0;
}

View File

@@ -22,8 +22,13 @@ int main(int argc, char** argv) {
scene->camera = new Camera(width, height);
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)));
scene->objects.push_back(new 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(new Sphere({ 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(new Sphere({ 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(new Sphere({ 35.0f, 50.0f, 25.0f }, 25.0f, new Light({ 1.0f, 1.0f, 1.0f }, 100.0f)));
scene->objects.push_back(new 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)));
inferno.SetScene(scene);

View File

@@ -25,14 +25,14 @@ int main(int argc, char** argv) {
std::string dragon = RESOURCES + std::string("//models//dragon-cornell-size.obj");
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<Triangle*> tris = LoadTrianglesBasic(dragon, models, mat);
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<Triangle*> 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<Triangle*> tris1 = LoadTrianglesBasic(cornell, models);