Skip to content

Commit 9cf7d2d

Browse files
committed
Bugfixing, Compatibility Issues
1 parent e40af85 commit 9cf7d2d

File tree

16 files changed

+145
-87
lines changed

16 files changed

+145
-87
lines changed

VXCT.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ Global
1717
{251A78D8-D077-4F3C-BDF6-401D25E50E07}.Debug|x64.Build.0 = Debug|Win32
1818
{251A78D8-D077-4F3C-BDF6-401D25E50E07}.Debug|x86.ActiveCfg = Debug|Win32
1919
{251A78D8-D077-4F3C-BDF6-401D25E50E07}.Debug|x86.Build.0 = Debug|Win32
20-
{251A78D8-D077-4F3C-BDF6-401D25E50E07}.Release|x64.ActiveCfg = Release|x64
21-
{251A78D8-D077-4F3C-BDF6-401D25E50E07}.Release|x64.Build.0 = Release|x64
20+
{251A78D8-D077-4F3C-BDF6-401D25E50E07}.Release|x64.ActiveCfg = Release|Win32
21+
{251A78D8-D077-4F3C-BDF6-401D25E50E07}.Release|x64.Build.0 = Release|Win32
2222
{251A78D8-D077-4F3C-BDF6-401D25E50E07}.Release|x86.ActiveCfg = Release|Win32
2323
{251A78D8-D077-4F3C-BDF6-401D25E50E07}.Release|x86.Build.0 = Release|Win32
2424
EndGlobalSection

VXCT/VXCT.vcxproj

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,22 @@
7777
<IncludePath>G:\Users\Kahl\source\glfw-3.2.1\include;G:\Users\Kahl\source\GLM_9_8_5;G:\Users\Kahl\source\glad\include;$(IncludePath)</IncludePath>
7878
<LibraryPath>G:\Users\Kahl\source\glfw-3.2.1\libraries;$(LibraryPath)</LibraryPath>
7979
</PropertyGroup>
80+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
81+
<IncludePath>G:\Users\Kahl\source\glfw-3.2.1\include;G:\Users\Kahl\source\GLM_9_8_5;G:\Users\Kahl\source\glad\include;$(IncludePath)</IncludePath>
82+
<LibraryPath>G:\Users\Kahl\source\glfw-3.2.1\libraries;$(LibraryPath);$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64</LibraryPath>
83+
</PropertyGroup>
84+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
85+
<LibraryPath>G:\Users\Kahl\source\assimp-3.1.1\libraries_release;G:\Users\Kahl\source\glfw-3.2.1\libraries_release;$(LibraryPath)</LibraryPath>
86+
<IncludePath>G:\Users\Kahl\source\assimp-3.1.1\include;G:\Users\Kahl\source\glfw-3.2.1\include;G:\Users\Kahl\source\glad\include;$(IncludePath)</IncludePath>
87+
</PropertyGroup>
8088
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
8189
<ClCompile>
8290
<WarningLevel>Level3</WarningLevel>
8391
<Optimization>Disabled</Optimization>
8492
<SDLCheck>true</SDLCheck>
8593
<AdditionalIncludeDirectories>G:\Users\Kahl\source\GLM_9_8_5;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
8694
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
95+
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
8796
</ClCompile>
8897
<Link>
8998
<AdditionalDependencies>opengl32.lib;glfw3.lib;assimp.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -107,10 +116,13 @@
107116
<FunctionLevelLinking>true</FunctionLevelLinking>
108117
<IntrinsicFunctions>true</IntrinsicFunctions>
109118
<SDLCheck>true</SDLCheck>
119+
<AdditionalIncludeDirectories>G:\Users\Kahl\source\GLM_9_8_5;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
120+
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
110121
</ClCompile>
111122
<Link>
112123
<EnableCOMDATFolding>true</EnableCOMDATFolding>
113124
<OptimizeReferences>true</OptimizeReferences>
125+
<AdditionalDependencies>opengl32.lib;glfw3.lib;assimp.lib;%(AdditionalDependencies)</AdditionalDependencies>
114126
</Link>
115127
</ItemDefinitionGroup>
116128
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -120,10 +132,12 @@
120132
<FunctionLevelLinking>true</FunctionLevelLinking>
121133
<IntrinsicFunctions>true</IntrinsicFunctions>
122134
<SDLCheck>true</SDLCheck>
135+
<AdditionalIncludeDirectories>G:\Users\Kahl\source\GLM_9_8_5;G:\Users\Kahl\source\glfw-3.2.1\include;G:\Users\Kahl\source\glad\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
123136
</ClCompile>
124137
<Link>
125138
<EnableCOMDATFolding>true</EnableCOMDATFolding>
126139
<OptimizeReferences>true</OptimizeReferences>
140+
<AdditionalDependencies>opengl32.lib;glfw3.lib;%(AdditionalDependencies)</AdditionalDependencies>
127141
</Link>
128142
</ItemDefinitionGroup>
129143
<ItemGroup>
@@ -143,7 +157,6 @@
143157
<ClCompile Include="core\assets\World\Material.cpp" />
144158
<ClCompile Include="core\assets\World\PointLight.cpp" />
145159
<ClCompile Include="core\assets\Utilities\SceneParser.cpp" />
146-
<ClCompile Include="stb_image.cpp" />
147160
<ClCompile Include="core\assets\VoxelMap.cpp" />
148161
<ClCompile Include="core\assets\VoxSettings.cpp" />
149162
<ClCompile Include="core\assets\Utilities\Timer.cpp" />
@@ -165,7 +178,6 @@
165178
<ClInclude Include="core\assets\Utilities\FrameTimeCounter.h" />
166179
<ClInclude Include="core\assets\Utilities\SceneParser.h" />
167180
<ClInclude Include="core\assets\World\Lighting.h" />
168-
<ClInclude Include="stb_image.h" />
169181
<ClInclude Include="core\constants\VertexData.h" />
170182
<ClInclude Include="core\assets\VoxelMap.h" />
171183
<ClInclude Include="core\assets\VoxSettings.h" />

VXCT/VXCT.vcxproj.filters

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
<ClCompile Include="..\..\..\glad\src\glad.c">
2525
<Filter>Source Files</Filter>
2626
</ClCompile>
27-
<ClCompile Include="stb_image.cpp">
28-
<Filter>Source Files</Filter>
29-
</ClCompile>
3027
<ClCompile Include="core\globals.cpp">
3128
<Filter>Source Files</Filter>
3229
</ClCompile>
@@ -83,9 +80,6 @@
8380
<ClInclude Include="core\base.h">
8481
<Filter>Header Files</Filter>
8582
</ClInclude>
86-
<ClInclude Include="stb_image.h">
87-
<Filter>Header Files</Filter>
88-
</ClInclude>
8983
<ClInclude Include="core\globals.h">
9084
<Filter>Header Files</Filter>
9185
</ClInclude>

VXCT/core/Engine.cpp

Lines changed: 69 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ void Engine::run() {
111111
consoleThread = std::thread(&Engine::console, this);
112112
consoleThread.detach();
113113

114+
// == TEMPORARY FIX ==
115+
// For some reason compiling this program with /MD instead of /MDd leads to only these values being false. I know it makes no sense, but this at leas fixes it...
116+
G::VoxLightSettings->intermediate_cones = true;
117+
G::VoxLightSettings->front_cone = true;
118+
G::VoxLightSettings->side_cones = false;
119+
114120
// >> Render Loop <<
115121

116122
while (!window->shouldClose())
@@ -270,6 +276,7 @@ void Engine::console() {
270276
else if (input[0] == "specular_dist_factor" || input[0] == "sdf") { G::VoxLightSettings->specular_dist_factor = strtof(input[1].c_str(), 0); }
271277

272278
else if (input[0] == "diffuse_offset" || input[0] == "do") { G::VoxLightSettings->diffuse_offset = strtof(input[1].c_str(), 0); }
279+
else if (input[0] == "diffuse_origin_offset" || input[0] == "doo") { G::VoxLightSettings->diffuse_origin_offset = strtof(input[1].c_str(), 0); }
273280
else if (input[0] == "occlusion_offset" || input[0] == "oo") { G::VoxLightSettings->occlusion_offset = strtof(input[1].c_str(), 0); }
274281
else if (input[0] == "specular_offset" || input[0] == "so") { G::VoxLightSettings->specular_offset = strtof(input[1].c_str(), 0); }
275282

@@ -285,6 +292,22 @@ void Engine::console() {
285292

286293
else if (input[0] == "load") { loadSceneOnNextFrame = true; scene_load_dir = SCENE_DIR + input[1] + ".txt"; }
287294
else if (input[0] == "vox_freq") { voxelize_freq = strtof(input[1].c_str(), 0); }
295+
else if (input[0] == "toggle") {
296+
for (int i = 0; i < mainScene->objs.size(); i++) {
297+
if (mainScene->objs[i]->name == input[1]) toggle(&mainScene->objs[i]->active, mainScene->objs[i]->name);
298+
}
299+
}
300+
else print(this, "Unknwon Command");
301+
}
302+
else if (input.size() == 3) {
303+
if (input[0] == "scale") {
304+
for (int i = 0; i < mainScene->objs.size(); i++) {
305+
if (mainScene->objs[i]->name == input[1]) {
306+
float scalar = strtof(input[2].c_str(), 0);
307+
mainScene->objs[i]->scale( glm::vec3(scalar) );
308+
}
309+
}
310+
}
288311
else print(this, "Unknwon Command");
289312
}
290313
//eg. setmat Sphere1 shininess 0.1
@@ -299,38 +322,58 @@ void Engine::console() {
299322
}
300323
}
301324
}
325+
else if (input[0] == "translate") {
326+
for (int i = 0; i < mainScene->objs.size(); i++) {
327+
if (mainScene->objs[i]->name == input[1]) {
328+
if (input[2] == "x") { mainScene->objs[i]->translate( strtof(input[3].c_str(), 0), 0, 0); }
329+
else if (input[2] == "y") { mainScene->objs[i]->translate(0, strtof(input[3].c_str(), 0), 0); }
330+
else if (input[2] == "z") { mainScene->objs[i]->translate(0, 0, strtof(input[3].c_str(), 0)); }
331+
else print(this, "Invalid Axis");
332+
}
333+
}
334+
}
335+
else if (input[0] == "rotate") {
336+
for (int i = 0; i < mainScene->objs.size(); i++) {
337+
if (mainScene->objs[i]->name == input[1]) {
338+
if (input[2] == "x") { mainScene->objs[i]->rotate(glm::vec3(strtof(input[3].c_str(), 0), 0, 0)); }
339+
else if (input[2] == "y") { mainScene->objs[i]->rotate(glm::vec3(0, strtof(input[3].c_str(), 0), 0)); }
340+
else if (input[2] == "z") { mainScene->objs[i]->rotate(glm::vec3(0, 0, strtof(input[3].c_str(), 0))); }
341+
else print(this, "Invalid Axis");
342+
}
343+
}
344+
}
302345
else print(this, "Unknwon Command");
303346
}
304347
else if (input.size() == 1) {
305-
if (input[0] == "objs") objs = !objs;
306-
else if (input[0] == "voxs") voxs = !voxs;
348+
if (input[0] == "objs") { toggle(&objs, "Draw Objects"); }
349+
else if (input[0] == "voxs") { toggle(&voxs, "Draw Voxels"); }
307350
else if (input[0] == "vox") voxelizeOnNextFrame = true;
308-
else if (input[0] == "voxsW") voxsWireframe = !voxsWireframe;
309-
else if (input[0] == "objsW") objsWireframe = !objsWireframe;
310-
else if (input[0] == "sfMode") sfMode = !sfMode;
351+
else if (input[0] == "voxsW") { toggle(&voxsWireframe, "Wireframe Voxels"); }
352+
else if (input[0] == "objsW") { toggle(&objsWireframe, "Wireframe Objects"); }
353+
else if (input[0] == "sfMode") { toggle(&sfMode, "Single Frame Mode"); }
311354
else if (input[0] == "sf" && sfMode) singleFrame = true;
312-
else if (input[0] == "iLight") iLight = !iLight;
313-
else if (input[0] == "overlayW") overlayWireframe = !overlayWireframe;
355+
else if (input[0] == "iLight") { toggle(&iLight, "VXCT"); }
356+
else if (input[0] == "overlayW") { toggle(&overlayWireframe, "Wireframe Overlay"); }
314357
else if (input[0] == "pos1") G::SceneCamera->setPosition(1);
315358
else if (input[0] == "pos2") G::SceneCamera->setPosition(2);
316359
else if (input[0] == "ray") rayOnNextFrame = true;
317-
else if (input[0] == "loclod") LocLod = !LocLod;
360+
else if (input[0] == "loclod") { toggle(&LocLod, "Localized LOD Mode"); }
318361
else if (input[0] == "avgf") frametimecounter->printAvg();
319362
else if (input[0] == "clearf") frametimecounter->clear();
320-
else if (input[0] == "dynamic") { dynamic_scene = !dynamic_scene; print(this, dynamic_scene?"Dynamic revoxelization: ON":"Dynamic revoxelization: OFF"); }
363+
else if (input[0] == "dynamic") { toggle(&dynamic_scene, "Dynamic Revoxelization"); }
321364

322-
else if (input[0] == "phong") G::VoxLightSettings->phong = !G::VoxLightSettings->phong;
323-
else if (input[0] == "phong_ambient") G::VoxLightSettings->phong_ambient = !G::VoxLightSettings->phong_ambient;
324-
else if (input[0] == "phong_diffuse") G::VoxLightSettings->phong_diffuse = !G::VoxLightSettings->phong_diffuse;
325-
else if (input[0] == "phong_specular") G::VoxLightSettings->phong_specular = !G::VoxLightSettings->phong_specular;
365+
else if (input[0] == "phong") toggle(&G::VoxLightSettings->phong, "VXCT Phong");
366+
else if (input[0] == "phong_ambient") toggle(&G::VoxLightSettings->phong_ambient, "VXCT Phong Ambient");
367+
else if (input[0] == "phong_diffuse") toggle(&G::VoxLightSettings->phong_diffuse, "VXCT Phong Diffuse");
368+
else if (input[0] == "phong_specular") toggle(&G::VoxLightSettings->phong_specular, "VXCT Phong Specular");
326369

327-
else if (input[0] == "front_cone") G::VoxLightSettings->front_cone = !G::VoxLightSettings->front_cone;
328-
else if (input[0] == "side_cones") G::VoxLightSettings->side_cones = !G::VoxLightSettings->side_cones;
329-
else if (input[0] == "intermediate_cones") G::VoxLightSettings->intermediate_cones = !G::VoxLightSettings->intermediate_cones;
370+
else if (input[0] == "front_cone") toggle(&G::VoxLightSettings->front_cone, "VXCT Front Cone");
371+
else if (input[0] == "side_cones") toggle(&G::VoxLightSettings->side_cones, "VXCT Side Cones");
372+
else if (input[0] == "intermediate_cones") toggle(&G::VoxLightSettings->intermediate_cones, "VXCT Intermediate Cones");
330373

331-
else if (input[0] == "vox_diffuse" || input[0] == "vdiff") G::VoxLightSettings->vox_diffuse = !G::VoxLightSettings->vox_diffuse;
332-
else if (input[0] == "vox_specular" || input[0] == "vspec") G::VoxLightSettings->vox_specular = !G::VoxLightSettings->vox_specular;
333-
else if (input[0] == "vox_shadows" || input[0] == "vshad") G::VoxLightSettings->vox_shadows = !G::VoxLightSettings->vox_shadows;
374+
else if (input[0] == "vox_diffuse" || input[0] == "vdiff") toggle(&G::VoxLightSettings->vox_diffuse, "VXCT Diffuse Component");
375+
else if (input[0] == "vox_specular" || input[0] == "vspec") toggle(&G::VoxLightSettings->vox_specular, "VXCT Specular Component");
376+
else if (input[0] == "vox_shadows" || input[0] == "vshad") toggle(&G::VoxLightSettings->vox_shadows, "VXCT Occlusion Component");
334377

335378
else if (input[0] == "phong_only") { G::VoxLightSettings->vox_diffuse = G::VoxLightSettings->vox_shadows = G::VoxLightSettings->vox_specular = false; G::VoxLightSettings->phong = true; }
336379
else if (input[0] == "shadows_only") { G::VoxLightSettings->vox_diffuse = G::VoxLightSettings->phong = G::VoxLightSettings->vox_specular = false; G::VoxLightSettings->vox_shadows = true; }
@@ -342,6 +385,8 @@ void Engine::console() {
342385
else if (input[0] == "occlusion_offset" || input[0] == "oo") { print(this, "Occlusion Offset : " + std::to_string(G::VoxLightSettings->occlusion_offset)); }
343386
else if (input[0] == "specular_offset" || input[0] == "so") { print(this, "Specular Offset : " + std::to_string(G::VoxLightSettings->specular_offset)); }
344387

388+
else if (input[0] == "exit" || input[0] == "quit" || input[0] == "q") window->exit();
389+
345390
else print(this, "Unknwon Command");
346391
}
347392

@@ -350,3 +395,8 @@ void Engine::console() {
350395
settingMutex.unlock();
351396
}
352397
}
398+
399+
void Engine::toggle(bool* var, std::string name) {
400+
(*var) = !(*var);
401+
print(this, name + ((*var) ? ": ON" : ": OFF"));
402+
}

VXCT/core/Engine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class Engine : IOobject
1616
private:
1717
void loadGlad();
1818
void console();
19+
void toggle(bool* var, std::string name);
1920
std::thread consoleThread;
2021
std::mutex settingMutex;
2122

VXCT/core/assets/Graphics/Shader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ void Shader::setVsettings(const std::string &name, VoxSettings &vsettings_obj) c
203203
this->setFloat(name + ".diffuse_dist_factor", vs.diffuse_dist_factor);
204204
this->setFloat(name + ".diffuse_apperture", vs.diffuse_apperture);
205205
this->setFloat(name + ".diffuse_offset", vs.diffuse_offset);
206+
this->setFloat(name + ".diffuse_origin_offset", vs.diffuse_origin_offset);
206207

207208
this->setFloat(name + ".occlusion_dist_factor", vs.occlusion_dist_factor);
208209
this->setFloat(name + ".occlusion_apperture", vs.occlusion_apperture);

VXCT/core/assets/Graphics/Window.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ void processInput(GLFWwindow *window);
77

88
Window::Window() : IOobject("unnamedWindow")
99
{
10+
close = false;
11+
1012
glfwInit(); //Initialize glfw
1113
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); //Set opengl version to 4.5 core
1214
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5);
@@ -33,6 +35,10 @@ Window::~Window()
3335
{
3436
}
3537

38+
void Window::exit() {
39+
this->close = true;
40+
}
41+
3642
void Window::setPolygonMode(PolygonMode polygonmode, bool doubleSidedFaces) {
3743
GLenum face, mode;
3844
face = doubleSidedFaces ? GL_FRONT_AND_BACK : GL_FRONT;
@@ -43,7 +49,7 @@ void Window::setPolygonMode(PolygonMode polygonmode, bool doubleSidedFaces) {
4349
}
4450

4551
bool Window::shouldClose() {
46-
return glfwWindowShouldClose(this->window);
52+
return close || glfwWindowShouldClose(this->window);
4753
}
4854

4955
GLFWwindow* Window::getGLFWwindow() {

VXCT/core/assets/Graphics/Window.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ class Window : IOobject
1111
{
1212
private:
1313
GLFWwindow * window;
14+
bool close;
1415
public:
1516
void setPolygonMode(PolygonMode polygonmode = W_FILL, bool doubleSidedFaces = true);
1617
Window();
1718
~Window();
1819
bool shouldClose();
20+
void exit();
1921
GLFWwindow* getGLFWwindow();
2022
void processInput();
2123
};

VXCT/core/assets/Utilities/SceneParser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,6 @@ void SceneParser::processComplexNode_toscene(Scene* scene, sp_node* node) {
248248
break; }
249249

250250
case sp_nodetype::MODEL: {
251-
//active
252-
if (hasChildNodeOfType(node, sp_nodetype::ACTIVE) && !getChildOfType(node, sp_nodetype::ACTIVE)->GetData_b()) return;
253-
254251
//path, shader, name
255252
std::string path = OBJ_SCENE_CUBE1;
256253
std::string tmp_shader="COLOR";
@@ -275,6 +272,9 @@ void SceneParser::processComplexNode_toscene(Scene* scene, sp_node* node) {
275272
}
276273
else { print(this, "Model has neither path nor primitive: " + name); return; }
277274

275+
//active
276+
if (hasChildNodeOfType(node, sp_nodetype::ACTIVE) && !getChildOfType(node, sp_nodetype::ACTIVE)->GetData_b()) new_model->active = false;
277+
278278
//set shader unifrom references
279279
new_model->addMat4Reference("model_u", &new_model->model);
280280
new_model->addMat4Reference("proj_u", &G::SceneCamera->projMatrix);

VXCT/core/assets/VoxSettings.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ VoxSettings::VoxSettings()
1010
specular_dist_factor = 0.8f;
1111

1212
diffuse_offset = 0.19f;
13+
diffuse_origin_offset = 0.05f;
1314
occlusion_offset = 0.08f;
1415
specular_offset = 0.15f;
1516

@@ -28,9 +29,9 @@ VoxSettings::VoxSettings()
2829
vox_shadows = true;
2930
vox_specular = true;
3031

31-
bool front_cone=true;
32-
bool side_cones=false;
33-
bool intermediate_cones=true;
32+
bool front_cone = true;
33+
bool side_cones = false;
34+
bool intermediate_cones = true;
3435

3536
//Different voxelmap sizes require different values.
3637
if (VOX_SIZE == 128) {
@@ -62,6 +63,7 @@ VoxSettings_struct VoxSettings::to_struct()
6263
ret.specular_dist_factor = specular_dist_factor;
6364

6465
ret.diffuse_offset = diffuse_offset;
66+
ret.diffuse_origin_offset = diffuse_origin_offset;
6567
ret.occlusion_offset = occlusion_offset;
6668
ret.specular_offset = specular_offset;
6769

0 commit comments

Comments
 (0)