diff --git a/DGL/DGL_Model.hpp b/DGL/DGL_Model.hpp index ac5c02d..e39590e 100644 --- a/DGL/DGL_Model.hpp +++ b/DGL/DGL_Model.hpp @@ -73,7 +73,7 @@ namespace DGL struct Face { - Vec3Int Vertexes, Normals; + Vec3Int Vertexes; }; using FaceList = std::vector; @@ -107,7 +107,7 @@ namespace DGL for (int index = 0; index < 3; index++) { - generated.Vertexes[index] = vertIndexes[index]; + generated.Vertexes.vec[index] = vertIndexes[index]; if (index < 2) { @@ -119,7 +119,7 @@ namespace DGL if (normals.size() > 0) { - generated.Normals[index] = normals[index]; + //generated.Normals.vec[index] = normals[index]; } } @@ -144,22 +144,40 @@ namespace DGL for (int faceIndex = 0; faceIndex < faces.size(); faceIndex++) { - int vertexIndex1 = faces[faceIndex].Vertexes[0], - vertexIndex2 = faces[faceIndex].Vertexes[1], - vertexIndex3 = faces[faceIndex].Vertexes[2]; + int vertexIndex1 = faces[faceIndex].Vertexes.vec[0], + vertexIndex2 = faces[faceIndex].Vertexes.vec[1], + vertexIndex3 = faces[faceIndex].Vertexes.vec[2] ; - Vector3 edge1 = verticies[vertexIndex2] - verticies[vertexIndex1], - edge2 = verticies[vertexIndex3] - verticies[vertexIndex1], + Vector3 vert1 = verticies[vertexIndex1], + vert2 = verticies[vertexIndex2], + vert3 = verticies[vertexIndex3] ; - normal = GetDirection(GetCrossNormal(edge1, edge2)); + Vector3 edge1 = vert2 - vert1, + edge2 = vert3 - vert1, - faces[faceIndex].Normals[0] = vertexIndex1; - faces[faceIndex].Normals[1] = vertexIndex2; - faces[faceIndex].Normals[2] = vertexIndex3; + normal = GetCrossNormal(edge1, edge2); - normals[vertexIndex1] = normal; - normals[vertexIndex2] = normal; - normals[vertexIndex3] = normal; + + //faces[faceIndex].Normals.vec[0] = vertexIndex1; + //faces[faceIndex].Normals.vec[1] = vertexIndex2; + //faces[faceIndex].Normals.vec[2] = vertexIndex3; + + normals[vertexIndex1] += normal; + normals[vertexIndex2] += normal; + normals[vertexIndex3] += normal; + } + + for (int index = 0; index < normals.size(); index++) + { + /*gFloat magnitude = 0.0f; + + magnitude = normals[index].x + normals[index].y + normals[index].z; + + normals[index].x /= magnitude; + normals[index].y /= magnitude; + normals[index].z /= magnitude;*/ + + normals[index] = GetDirection(normals[index]); } } @@ -246,6 +264,16 @@ namespace DGL UnbindVertexArray(); // Unbind vertex array. + + /*for (int index = 0; index < verticies.size(); index++) + { + cout << "Vertex: " << verticies[index].x << ", " << verticies[index].y << ", " << ", " << verticies[index].z << endl; + } + + for (int index = 0; index < verticies.size(); index++) + { + cout << "Normal: " << normals[index].x << ", " << normals[index].y << ", " << ", " << normals[index].z << endl; + }*/ } void Load() diff --git a/DGL/DGL_Types.hpp b/DGL/DGL_Types.hpp index 50f3629..8e8e826 100644 --- a/DGL/DGL_Types.hpp +++ b/DGL/DGL_Types.hpp @@ -83,7 +83,20 @@ namespace DGL using UVList = std::vector < Vector2>; using Vec2Int = Generic::Vector2< gUInt >; - using Vec3Int = Generic::Vector3< gUInt >; + + + struct Vec3Int + { + union + { + gUInt vec[3]; + gUInt x, y, z; + }; + }; + + //using Vec3Int = Generic::Vector3< gUInt >; + + using VertexList = std ::vector < Vector3>; diff --git a/DGL/DGL_Utilities.hpp b/DGL/DGL_Utilities.hpp index e27e6f4..c866da2 100644 --- a/DGL/DGL_Utilities.hpp +++ b/DGL/DGL_Utilities.hpp @@ -28,7 +28,7 @@ namespace DGL // Constants constexpr Window* NotShared () { return NULL; } - constexpr Monitor* WindowedMode() { return NULL; } + constexpr Monitor* WindowedMode() { return NULL; } diff --git a/Execution.cpp b/Execution.cpp index 5cc0821..8779923 100644 --- a/Execution.cpp +++ b/Execution.cpp @@ -116,7 +116,8 @@ namespace Execution DeltaTime , // Delta between last cycle start and end. InputInterval = 1.0f / 144.0f, // Interval per second to complete the input process of the cycle. PhysicsInterval = 1.0f / 144.0f, // Interval per second to complete the physics process of the cycle. - RenderInterval = 1.0f / 144.0f ; // Interval per second to complete the render process of the cycle. + RenderInterval = 1.0f / 144.0f, // Interval per second to complete the render process of the cycle. + InputBuffer = 1.0f; Window* DefaultWindow; // Default window to use for execution. @@ -128,15 +129,16 @@ namespace Execution CamRotationSpeed = 27.0f ; // Rate at which the camera should rotate. TimeValDec InputDelta = 0.0, // Current delta since last input process. + InputBufferDelta = 0.0, PhysicsDelta = 0.0, // Current delta since last physics process. RenderDelta = 0.0 ; // Current delta since last render process. ActionQueue ActionsToComplete; // Actions queue to run during the physics process of the cycle. - EModels CurrentModel = EModels::Torus; + EModels CurrentModel = EModels::Cube; Model Bunny ("./Models/bunny.obj" ); - Model Cube ("./Models/blenderCube2.obj"); + Model Cube ("./Models/blendercube2.obj"); Model Eight ("./Models/eight.obj" ); Model Gargoyle ("./Models/gargoyle.obj" ); Model Hand ("./Models/hand.obj" ); @@ -409,6 +411,9 @@ namespace Execution SetPolygonMode(DGL::EFace::Front_and_Back, DGL::ERenderMode::Fill); + glShadeModel(GL_FLAT); + + // Cursor stuff SetInputMode(DefaultWindow, DGL::EMouseMode::Cursor, DGL::ECursorMode::Disable); @@ -430,14 +435,14 @@ namespace Execution Light.Load(); - Torus.Load(); + Cube.Load(); ObjectMaterial.Color = DGL::Colors::WarmSphia.Vector(); ObjectMaterial.Ambience = 0.112f ; ObjectMaterial.Diffuse = 0.928f ; ObjectMaterial.Specular = 0.21f ; - ObjectToView = Entity_Basic(Torus, ObjectMaterial); + ObjectToView = Entity_Basic(Cube, ObjectMaterial); } @@ -510,6 +515,8 @@ namespace Execution InputDelta += DeltaTime; PhysicsDelta += DeltaTime; RenderDelta += DeltaTime; + + InputBufferDelta += DeltaTime; } return; @@ -517,7 +524,14 @@ namespace Execution void InputProcedure(Window* _currentWindowContext) { - if (KeyPressed(_currentWindowContext, EKeyCodes::F1)) + static bool F1_Held = false, H_Held = false, M_Held = false; + + if (!KeyPressed(_currentWindowContext, EKeyCodes::F1)) F1_Held = false; + if (!KeyPressed(_currentWindowContext, EKeyCodes::H )) H_Held = false; + if (!KeyPressed(_currentWindowContext, EKeyCodes::M )) M_Held = false; + + + if (KeyPressed(_currentWindowContext, EKeyCodes::F1) && not F1_Held) { ECursorMode cursorMode = ECursorMode(GetMouseInputMode(DefaultWindow, EMouseMode::Cursor)); @@ -538,15 +552,21 @@ namespace Execution CursorOff = false; } + + F1_Held = true; } - if (KeyPressed(_currentWindowContext, EKeyCodes::H)) + if (KeyPressed(_currentWindowContext, EKeyCodes::H) && not H_Held) { + H_Held = true; + ActionsToComplete.AddToQueue(ToogleLightDelegate); } - if (KeyPressed(_currentWindowContext, EKeyCodes::M)) + if (KeyPressed(_currentWindowContext, EKeyCodes::M) && not M_Held) { + M_Held = true; + ActionsToComplete.AddToQueue(ChangeModelDelegate); } diff --git a/x64/Debug/CompGraphics.Build.CppClean.log b/x64/Debug/CompGraphics.Build.CppClean.log new file mode 100644 index 0000000..e51dd15 --- /dev/null +++ b/x64/Debug/CompGraphics.Build.CppClean.log @@ -0,0 +1,9 @@ +f:\projects\compgraphics\x64\debug\compgraphics.exe +f:\projects\compgraphics\x64\debug\compgraphics.ilk +f:\projects\compgraphics\x64\debug\compgraphics.pdb +f:\projects\compgraphics\compgraphics\x64\debug\vc142.idb +f:\projects\compgraphics\compgraphics\x64\debug\vc142.pdb +f:\projects\compgraphics\compgraphics\x64\debug\compgraphics.tlog\cl.command.1.tlog +f:\projects\compgraphics\compgraphics\x64\debug\compgraphics.tlog\link.command.1.tlog +f:\projects\compgraphics\compgraphics\x64\debug\compgraphics.tlog\link.read.1.tlog +f:\projects\compgraphics\compgraphics\x64\debug\compgraphics.tlog\link.write.1.tlog diff --git a/x64/Debug/CompGraphics.log b/x64/Debug/CompGraphics.log new file mode 100644 index 0000000..647e778 --- /dev/null +++ b/x64/Debug/CompGraphics.log @@ -0,0 +1,3 @@ + Execution.cpp +F:\Projects\CompGraphics\CompGraphics\DGL\DGL_Entity.hpp(94,1): warning C4244: '+=': conversion from 'double' to 'DGL::gFloat', possible loss of data + CompGraphics.vcxproj -> F:\Projects\CompGraphics\x64\Debug\CompGraphics.exe diff --git a/x64/Debug/CompGraphics.tlog/CL.command.1.tlog b/x64/Debug/CompGraphics.tlog/CL.command.1.tlog new file mode 100644 index 0000000..fa93eae Binary files /dev/null and b/x64/Debug/CompGraphics.tlog/CL.command.1.tlog differ diff --git a/x64/Debug/CompGraphics.tlog/CL.read.1.tlog b/x64/Debug/CompGraphics.tlog/CL.read.1.tlog new file mode 100644 index 0000000..d7af5fc Binary files /dev/null and b/x64/Debug/CompGraphics.tlog/CL.read.1.tlog differ diff --git a/x64/Debug/CompGraphics.tlog/CL.write.1.tlog b/x64/Debug/CompGraphics.tlog/CL.write.1.tlog new file mode 100644 index 0000000..5b46319 Binary files /dev/null and b/x64/Debug/CompGraphics.tlog/CL.write.1.tlog differ diff --git a/x64/Debug/CompGraphics.tlog/CompGraphics.lastbuildstate b/x64/Debug/CompGraphics.tlog/CompGraphics.lastbuildstate new file mode 100644 index 0000000..a2b0806 --- /dev/null +++ b/x64/Debug/CompGraphics.tlog/CompGraphics.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v142:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0 +Debug|x64|F:\Projects\CompGraphics\| diff --git a/x64/Debug/CompGraphics.tlog/link.command.1.tlog b/x64/Debug/CompGraphics.tlog/link.command.1.tlog new file mode 100644 index 0000000..37581a6 Binary files /dev/null and b/x64/Debug/CompGraphics.tlog/link.command.1.tlog differ diff --git a/x64/Debug/CompGraphics.tlog/link.read.1.tlog b/x64/Debug/CompGraphics.tlog/link.read.1.tlog new file mode 100644 index 0000000..f66e71e Binary files /dev/null and b/x64/Debug/CompGraphics.tlog/link.read.1.tlog differ diff --git a/x64/Debug/CompGraphics.tlog/link.write.1.tlog b/x64/Debug/CompGraphics.tlog/link.write.1.tlog new file mode 100644 index 0000000..7fcf8ae Binary files /dev/null and b/x64/Debug/CompGraphics.tlog/link.write.1.tlog differ diff --git a/x64/Debug/CompGraphics.vcxproj.FileListAbsolute.txt b/x64/Debug/CompGraphics.vcxproj.FileListAbsolute.txt new file mode 100644 index 0000000..e69de29 diff --git a/x64/Debug/Execution.obj b/x64/Debug/Execution.obj new file mode 100644 index 0000000..a827692 Binary files /dev/null and b/x64/Debug/Execution.obj differ diff --git a/x64/Debug/vc142.idb b/x64/Debug/vc142.idb new file mode 100644 index 0000000..8ee5dc1 Binary files /dev/null and b/x64/Debug/vc142.idb differ diff --git a/x64/Debug/vc142.pdb b/x64/Debug/vc142.pdb new file mode 100644 index 0000000..a351497 Binary files /dev/null and b/x64/Debug/vc142.pdb differ