Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesugb committed Apr 20, 2020
1 parent 9c4027f commit e6136f2
Show file tree
Hide file tree
Showing 163 changed files with 53,979 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.cpp text
*.h text
*.hpp text

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
*.jpeg binary
*.fbx binary
*.lib binary
*.dll binary
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# User-specific files
*.suo

# Everything that happens inside the dependencies folder
dependencies/*
!dependencies/glad/
!dependencies/libs/

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets

# Build and intermediate folders
x64/
FastMVR/[Dd]ebug/
FastMVR/[Rr]elease/
FastMVR/x64/
UnitTest1/[Dd]ebug/
UnitTest1/[Rr]elease/
UnitTest1/x64/

# Visual Studio cache/options directory
.vs/

# Ignore the png files, produced by LayeredGL
FastMVR/*.png

# Ignore all .obj files under /media
media/**/*.obj

# Ignore all .dump files under /media (except for one)
media/**/*.dump
!media/sponza.cfg.dump
24 changes: 24 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[submodule "dependencies/stbimage"]
path = dependencies/stbimage
url = https://github.com/nothings/stb
[submodule "dependencies/tinyobj"]
path = dependencies/tinyobj
url = https://github.com/syoyo/tinyobjloader
[submodule "dependencies/glm"]
path = dependencies/glm
url = https://github.com/g-truc/glm
[submodule "dependencies/glfw"]
path = dependencies/glfw
url = https://github.com/glfw/glfw
[submodule "dependencies/glew"]
path = dependencies/glew
url = https://github.com/edoren/glew
[submodule "dependencies/fmt"]
path = dependencies/fmt
url = https://github.com/fmtlib/fmt.git
[submodule "rt_playground/cg_base"]
path = rt_playground/cg_base
url = https://github.com/cg-tuwien/cg_base.git
[submodule "dependencies/MathGeoLib"]
path = dependencies/MathGeoLib
url = https://github.com/juj/MathGeoLib.git
39 changes: 39 additions & 0 deletions FastMVR.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29020.237
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FastMVR", "FastMVR\FastMVR.vcxproj", "{6325E01F-9A93-486C-8D35-50EE523AEB5B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTest1", "UnitTest1\UnitTest1.vcxproj", "{9932225B-D376-4930-9A5D-92EB49D59408}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6325E01F-9A93-486C-8D35-50EE523AEB5B}.Debug|x64.ActiveCfg = Debug|x64
{6325E01F-9A93-486C-8D35-50EE523AEB5B}.Debug|x64.Build.0 = Debug|x64
{6325E01F-9A93-486C-8D35-50EE523AEB5B}.Debug|x86.ActiveCfg = Debug|x64
{6325E01F-9A93-486C-8D35-50EE523AEB5B}.Release|x64.ActiveCfg = Release|x64
{6325E01F-9A93-486C-8D35-50EE523AEB5B}.Release|x64.Build.0 = Release|x64
{6325E01F-9A93-486C-8D35-50EE523AEB5B}.Release|x86.ActiveCfg = Release|x64
{9932225B-D376-4930-9A5D-92EB49D59408}.Debug|x64.ActiveCfg = Debug|x64
{9932225B-D376-4930-9A5D-92EB49D59408}.Debug|x64.Build.0 = Debug|x64
{9932225B-D376-4930-9A5D-92EB49D59408}.Debug|x86.ActiveCfg = Debug|Win32
{9932225B-D376-4930-9A5D-92EB49D59408}.Debug|x86.Build.0 = Debug|Win32
{9932225B-D376-4930-9A5D-92EB49D59408}.Release|x64.ActiveCfg = Release|x64
{9932225B-D376-4930-9A5D-92EB49D59408}.Release|x64.Build.0 = Release|x64
{9932225B-D376-4930-9A5D-92EB49D59408}.Release|x86.ActiveCfg = Release|Win32
{9932225B-D376-4930-9A5D-92EB49D59408}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7FE60517-378F-49A6-832D-792EE9CAB3E5}
EndGlobalSection
EndGlobal
1 change: 1 addition & 0 deletions FastMVR/AABB.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "AABB.h"
94 changes: 94 additions & 0 deletions FastMVR/AABB.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#pragma once
#include <glm/vec3.hpp>
#include <vector>
#include <limits>
#define GL_SCENE
#include "Scene.h"
#undef GL_SCENE

namespace mymath
{
enum struct location_wrt_aabb
{
inside,
outside,
on_the_edge
};

class AABB
{
friend bool operator==(const AABB& left, const AABB& right);
public:
glm::vec3 min_coords() const { return glm::vec3(min_x, min_y, min_z); }
glm::vec3 max_coords() const { return glm::vec3(max_x, max_y, max_z); }
glm::vec3 extent() const { return max_coords() - min_coords(); }

location_wrt_aabb classify_point(glm::vec3 pt) const
{
auto diff1 = pt - min_coords();
auto diff2 = max_coords() - pt;
if (diff1.x > 0 && diff1.y > 0 && diff1.z > 0 && diff2.x > 0 && diff2.y > 0 && diff2.z > 0) {
return location_wrt_aabb::inside;
}
if (diff1.x >= 0 && diff1.y >= 0 && diff1.z >= 0 && diff2.x >= 0 && diff2.y >= 0 && diff2.z >= 0) {
return location_wrt_aabb::on_the_edge;
}
return location_wrt_aabb::outside;
}

//location_wrt_aabb classify_triangle

static AABB create_for_vertices(const std::vector<SceneVertex>& vertices)
{
assert(vertices.size() > 0);
AABB result;
result.min_x = std::numeric_limits<float>::max();
result.min_y = std::numeric_limits<float>::max();
result.min_z = std::numeric_limits<float>::max();
result.max_x = std::numeric_limits<float>::min();
result.max_y = std::numeric_limits<float>::min();
result.max_z = std::numeric_limits<float>::min();
for (const auto& sv : vertices) {
result.min_x = glm::min(result.min_x, sv.position.x);
result.min_y = glm::min(result.min_y, sv.position.y);
result.min_z = glm::min(result.min_z, sv.position.z);
result.max_x = glm::max(result.max_x, sv.position.x);
result.max_y = glm::max(result.max_y, sv.position.y);
result.max_z = glm::max(result.max_z, sv.position.z);
}
return result;
}

static AABB create_for_min_max_coords(glm::vec3 minCoords, glm::vec3 maxCoords)
{
AABB result;
result.min_x = minCoords.x;
result.min_y = minCoords.y;
result.min_z = minCoords.z;
result.max_x = maxCoords.x;
result.max_y = maxCoords.y;
result.max_z = maxCoords.z;
return result;
}

private:
float min_x;
float min_y;
float min_z;
float max_x;
float max_y;
float max_z;
};

static bool operator==(const AABB& left, const AABB& right)
{
if (std::abs(left.min_x - right.min_x) > std::numeric_limits<float>::epsilon()) return false;
if (std::abs(left.min_y - right.min_y) > std::numeric_limits<float>::epsilon()) return false;
if (std::abs(left.min_z - right.min_z) > std::numeric_limits<float>::epsilon()) return false;
if (std::abs(left.min_x - right.min_x) > std::numeric_limits<float>::epsilon()) return false;
if (std::abs(left.min_y - right.min_y) > std::numeric_limits<float>::epsilon()) return false;
if (std::abs(left.min_z - right.min_z) > std::numeric_limits<float>::epsilon()) return false;
return true;
}

}
39 changes: 39 additions & 0 deletions FastMVR/AdditionalShaderCode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "AdditionalShaderCode.h"

AdditionalShaderCode add_code()
{
return AdditionalShaderCode{};
}

AdditionalShaderCode& AdditionalShaderCode::to_all(std::string_view code, bool encloseNewLines)
{
to_vert(code, encloseNewLines);
to_geom(code, encloseNewLines);
to_frag(code, encloseNewLines);
return *this;
}

AdditionalShaderCode& AdditionalShaderCode::to_vert(std::string_view code, bool encloseNewLines)
{
if (encloseNewLines) { m_additionToVertexShader += "\n"; }
m_additionToVertexShader += code;
if (encloseNewLines) { m_additionToVertexShader += "\n"; }
return *this;
}

AdditionalShaderCode& AdditionalShaderCode::to_geom(std::string_view code, bool encloseNewLines)
{
if (encloseNewLines) { m_additionToGeometryShader += "\n"; }
m_additionToGeometryShader += code;
if (encloseNewLines) { m_additionToGeometryShader += "\n"; }
return *this;
}

AdditionalShaderCode& AdditionalShaderCode::to_frag(std::string_view code, bool encloseNewLines)
{
if (encloseNewLines) { m_additionToFragementShader += "\n"; }
m_additionToFragementShader += code;
if (encloseNewLines) { m_additionToFragementShader += "\n"; }
return *this;
}

17 changes: 17 additions & 0 deletions FastMVR/AdditionalShaderCode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once
#include <string>


struct AdditionalShaderCode
{
AdditionalShaderCode& to_all(std::string_view code, bool encloseNewLines = true);
AdditionalShaderCode& to_vert(std::string_view code, bool encloseNewLines = true);
AdditionalShaderCode& to_geom(std::string_view code, bool encloseNewLines = true);
AdditionalShaderCode& to_frag(std::string_view code, bool encloseNewLines = true);

std::string m_additionToVertexShader;
std::string m_additionToGeometryShader;
std::string m_additionToFragementShader;
};

AdditionalShaderCode add_code();
Loading

0 comments on commit e6136f2

Please sign in to comment.