Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed DisplayGLFW/Debug/CL.read.1.tlog
Binary file not shown.
Binary file removed DisplayGLFW/Debug/CL.write.1.tlog
Binary file not shown.
Binary file removed DisplayGLFW/Debug/Lib-link.read.1.tlog
Binary file not shown.
Binary file removed DisplayGLFW/Debug/Lib-link.write.1.tlog
Binary file not shown.
Binary file removed DisplayGLFW/Debug/cl.command.1.tlog
Binary file not shown.
Binary file removed DisplayGLFW/Debug/lib.command.1.tlog
Binary file not shown.
7 changes: 4 additions & 3 deletions DisplayGLFW/DisplayGLFW.vcxproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand All @@ -19,18 +19,19 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{0C9D56F3-8B06-460D-9017-D1C3E1F6DC51}</ProjectGuid>
<RootNamespace>DisplayGLFW</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions DisplayGLFW/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void Display::addKeyCallBack(void(*keyCallback)(GLFWwindow *,int,int,int,int))
//glfwSetKeyCallback(m_window,[](GLFWwindow *window,int key,int scancode,int action,int mods){
// func(glfwGetWindowUserPointer(window),key,scancode,action,mods);
//});
//key_callback);
// key_callback);



Expand Down Expand Up @@ -79,9 +79,9 @@ Display::~Display()
//SDL_Quit();
}

void Display::Clear(float r, float g, float b, float a)
void Display::Clear(float r, float g, float my_curve, float a)
{
glClearColor(r, g, b, a);
glClearColor(r, g, my_curve, a);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}

Expand Down
10 changes: 9 additions & 1 deletion EngineVideoGames.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# Visual Studio 15
VisualStudioVersion = 15.0.28307.489
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Game", "Game\Game.vcxproj", "{257FC222-2301-4B67-A02B-880548704235}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EngineVideoGames", "EngineVideoGames\EngineVideoGames.vcxproj", "{42AF4C92-9210-42BB-AFD2-30E6108E4CC4}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DisplayGLFW", "DisplayGLFW\DisplayGLFW.vcxproj", "{0C9D56F3-8B06-460D-9017-D1C3E1F6DC51}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KDtree", "KDtree\KDtree.vcxproj", "{7CE449AF-34F9-48D2-8604-7C3D4910871D}"
ProjectSection(ProjectDependencies) = postProject
{257FC222-2301-4B67-A02B-880548704235} = {257FC222-2301-4B67-A02B-880548704235}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "linearSolver", "linearSolver\linearSolver\linearSolver.vcxproj", "{DECFCF3E-C42F-4674-B514-033BC0402038}"
EndProject
Expand Down Expand Up @@ -46,4 +51,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {11926EE0-CFD5-494D-8CCC-EC99FEDAF4B8}
EndGlobalSection
EndGlobal
7 changes: 4 additions & 3 deletions EngineVideoGames/EngineVideoGames.vcxproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand All @@ -13,18 +13,19 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{42AF4C92-9210-42BB-AFD2-30E6108E4CC4}</ProjectGuid>
<RootNamespace>EngineVideoGames</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
Expand Down
74 changes: 74 additions & 0 deletions EngineVideoGames/Mesh.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Mesh.h"
#include <limits>

void IndexedModel::CalcNormals()
{
Expand Down Expand Up @@ -244,3 +245,76 @@ IndexedModel OctahedronGenerator()
return model;
}

bool BoundingBox::checkCollision(BoundingBox other) {
return this->checkCollision(*this, other) && this->checkCollision(other, *this);
}

glm::mat4 getTransformation(glm::vec3 u, glm::vec3 v) {
glm::vec3 axis = glm::cross(u, v);
float angle = glm::acos(glm::dot(u, v));
return glm::rotate(angle, axis);
}

bool axsisCut(float b1min, float b1max, float b2min, float b2max) {
return (b1min <= b2max && b2max <= b1max) || (b1min <= b2min && b2min <= b1max) || (b1min >= b2min && b1max <= b2max);
}

bool BoundingBox::checkCollision(BoundingBox b1, BoundingBox b2) {
glm::mat3 to_b1 = glm::mat3();
to_b1[0] = glm::vec3(b1.xInit[0], b1.yInit[0], b1.zInit[0]);
to_b1[1] = glm::vec3(b1.xInit[1], b1.yInit[1], b1.zInit[1]);
to_b1[2] = glm::vec3(b1.xInit[2], b1.yInit[2], b1.zInit[2]);

glm::mat3 to_b2 = glm::mat3();
to_b2[0] = glm::vec3(b2.xInit[0], b2.yInit[0], b2.zInit[0]);
to_b2[1] = glm::vec3(b2.xInit[1], b2.yInit[1], b2.zInit[1]);
to_b2[2] = glm::vec3(b2.xInit[2], b2.yInit[2], b2.zInit[2]);

glm::mat3 from_b1 = glm::inverse(to_b1);

glm::mat3 b1_to_b2 = to_b2 * from_b1;

glm::vec3 b1xb2 = b1_to_b2 * b1.xInit;
glm::vec3 b1yb2 = b1_to_b2 * b1.yInit;
glm::vec3 b1zb2 = b1_to_b2 * b1.zInit;

float b1minx = std::numeric_limits<float>::max(), b1maxx = std::numeric_limits<float>::min()
, b1miny = std::numeric_limits<float>::max(), b1maxy = std::numeric_limits<float>::min()
, b1minz = std::numeric_limits<float>::max(), b1maxz = std::numeric_limits<float>::min();
float b2minx = std::numeric_limits<float>::max(), b2maxx = std::numeric_limits<float>::min()
, b2miny = std::numeric_limits<float>::max(), b2maxy = std::numeric_limits<float>::min()
, b2minz = std::numeric_limits<float>::max(), b2maxz = std::numeric_limits<float>::min();

for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
for (int k = -1; k < 2; k++) {
glm::vec3 p = b1.center + ((float)i * b1xb2) * b1.size.x + ((float)j * b1yb2) * b1.size.y + ((float)k * b1zb2) * b1.size.z;
b1minx = std::fmin(p.x, b1minx);
b1maxx = std::fmax(p.x, b1maxx);
b1miny = std::fmin(p.y, b1miny);
b1maxy = std::fmax(p.y, b1maxy);
b1minz = std::fmin(p.z, b1minz);
b1maxz = std::fmax(p.z, b1maxz);
}
}
}

for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
for (int k = -1; k < 2; k++) {
glm::vec3 p = b2.center + ((float)i * b2.xInit) * b2.size.x + ((float)j * b2.yInit) * b2.size.y + ((float)k * b2.zInit) * b2.size.z;
b2minx = std::fmin(p.x, b2minx);
b2maxx = std::fmax(p.x, b2maxx);
b2miny = std::fmin(p.y, b2miny);
b2maxy = std::fmax(p.y, b2maxy);
b2minz = std::fmin(p.z, b2minz);
b2maxz = std::fmax(p.z, b2maxz);
}
}
return axsisCut(b1minx, b1maxx, b2minx, b2maxx)
&& axsisCut(b1miny, b1maxy, b2miny, b2maxy)
&& axsisCut(b1minz, b1maxz, b2minz, b2maxz);
}


}
18 changes: 18 additions & 0 deletions EngineVideoGames/Mesh.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include "glm/glm.hpp"
#include <glm/gtx/transform.hpp>
#include <vector>

class IndexedModel
Expand Down Expand Up @@ -59,14 +60,31 @@ struct LineVertex
glm::vec3 color;
};

static const glm::vec3 x = glm::vec3(1, 0, 0);
static const glm::vec3 y = glm::vec3(0, 1, 0);
static const glm::vec3 z = glm::vec3(0, 0, 1);

class BoundingBox
{
private:
bool checkCollision(BoundingBox b1, BoundingBox b2);
public:
glm::vec3 center; // center coordinates
glm::vec3 size; // distance between the center of the box to its side in each dimension
glm::vec3 xInit; // x axis of the box. default value (1,0,0)
glm::vec3 yInit; // y axis of the box. default value (0,1,0)
glm::vec3 zInit; // z axis of the box. default value (0,0,1)
//TODO: Add constructor and checkCollision function

BoundingBox(glm::vec3 center, glm::vec3 size, glm::vec3 xInit= x, glm::vec3 yInit= y, glm::vec3 zInit= z) {
this->center = center;
this->size = size;
this->xInit = glm::normalize(xInit);
this->yInit = glm::normalize(yInit);
this->zInit = glm::normalize(zInit);
}

bool checkCollision(BoundingBox other);
};

IndexedModel CubeTriangles();
Expand Down
21 changes: 12 additions & 9 deletions EngineVideoGames/MeshConstructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@ MeshConstructor::MeshConstructor(const std::string& fileName)

MeshConstructor::MeshConstructor(Bezier1D *curve,bool isSurface,unsigned int resT,unsigned int resS)
{
//if(isSurface)
//{
// Bezier2D surface(*curve,glm::vec3(0,0,1),4);
// InitMesh(surface.GetSurface(resT,resS));
//}
//else
//{
// InitLine( curve->GetLine(resT));
//}
if(isSurface)
{
Bezier2D surface(*curve,glm::vec3(0,0,1),4);
InitMesh(surface.GetSurface(resT,resS));

//use this line for debugging
//InitLine(surface.GetSurface(10,7));
}
else
{
InitLine( curve->GetLine(resT));
}
}

MeshConstructor::MeshConstructor(const MeshConstructor &mesh)
Expand Down
20 changes: 20 additions & 0 deletions EngineVideoGames/MeshConstructor.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,33 @@
#include "Mesh.h"
#include "bezier1D.h"
#include "kdtree.h"
#include "Mesh.h"

class B_Node
{
private:
BoundingBox bb;
int low;
int high;
B_Node* left;
B_Node* right;

BoundingBox getBoundingbox(int low, int high,std::vector<glm::vec3>* points[]);
BoundingBox getDefultBoundingbox(glm::vec3 point);
public:
B_Node(int low, int high, std::vector<glm::vec3>* points[]);
B_Node(const B_Node &other);
bool isColiding(glm::mat4 myMat, B_Node &other,glm::mat4 otherMat);

~B_Node(void);
};

class MeshConstructor
{
VertexArray vao;
IndexBuffer *ib;
//TO DO: add bounding box data base and build it in the constructor
B_Node boundingTree;
std::vector<VertexBuffer*> vbs;
bool is2D;
int unsigned indicesNum;
Expand Down
Loading