mirror of
https://github.com/Ed94/DuctTaped_GL.git
synced 2024-11-10 04:24:52 -08:00
Fixed normal paperclips with hotglue for everything except cube.
Also prevent input spamming on actions that require a re-press.
This commit is contained in:
parent
da17f52c9d
commit
6dd91a3531
@ -73,7 +73,7 @@ namespace DGL
|
|||||||
|
|
||||||
struct Face
|
struct Face
|
||||||
{
|
{
|
||||||
Vec3Int Vertexes, Normals;
|
Vec3Int Vertexes;
|
||||||
};
|
};
|
||||||
|
|
||||||
using FaceList = std::vector<Face>;
|
using FaceList = std::vector<Face>;
|
||||||
@ -107,7 +107,7 @@ namespace DGL
|
|||||||
|
|
||||||
for (int index = 0; index < 3; index++)
|
for (int index = 0; index < 3; index++)
|
||||||
{
|
{
|
||||||
generated.Vertexes[index] = vertIndexes[index];
|
generated.Vertexes.vec[index] = vertIndexes[index];
|
||||||
|
|
||||||
if (index < 2)
|
if (index < 2)
|
||||||
{
|
{
|
||||||
@ -119,7 +119,7 @@ namespace DGL
|
|||||||
|
|
||||||
if (normals.size() > 0)
|
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++)
|
for (int faceIndex = 0; faceIndex < faces.size(); faceIndex++)
|
||||||
{
|
{
|
||||||
int vertexIndex1 = faces[faceIndex].Vertexes[0],
|
int vertexIndex1 = faces[faceIndex].Vertexes.vec[0],
|
||||||
vertexIndex2 = faces[faceIndex].Vertexes[1],
|
vertexIndex2 = faces[faceIndex].Vertexes.vec[1],
|
||||||
vertexIndex3 = faces[faceIndex].Vertexes[2];
|
vertexIndex3 = faces[faceIndex].Vertexes.vec[2] ;
|
||||||
|
|
||||||
Vector3 edge1 = verticies[vertexIndex2] - verticies[vertexIndex1],
|
Vector3 vert1 = verticies[vertexIndex1],
|
||||||
edge2 = verticies[vertexIndex3] - 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;
|
normal = GetCrossNormal(edge1, edge2);
|
||||||
faces[faceIndex].Normals[1] = vertexIndex2;
|
|
||||||
faces[faceIndex].Normals[2] = vertexIndex3;
|
|
||||||
|
|
||||||
normals[vertexIndex1] = normal;
|
|
||||||
normals[vertexIndex2] = normal;
|
//faces[faceIndex].Normals.vec[0] = vertexIndex1;
|
||||||
normals[vertexIndex3] = normal;
|
//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.
|
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()
|
void Load()
|
||||||
|
@ -83,7 +83,20 @@ namespace DGL
|
|||||||
using UVList = std::vector < Vector2>;
|
using UVList = std::vector < Vector2>;
|
||||||
|
|
||||||
using Vec2Int = Generic::Vector2< gUInt >;
|
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>;
|
using VertexList = std ::vector < Vector3>;
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ namespace DGL
|
|||||||
// Constants
|
// Constants
|
||||||
|
|
||||||
constexpr Window* NotShared () { return NULL; }
|
constexpr Window* NotShared () { return NULL; }
|
||||||
constexpr Monitor* WindowedMode() { return NULL; }
|
constexpr Monitor* WindowedMode() { return NULL; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,7 +116,8 @@ namespace Execution
|
|||||||
DeltaTime , // Delta between last cycle start and end.
|
DeltaTime , // Delta between last cycle start and end.
|
||||||
InputInterval = 1.0f / 144.0f, // Interval per second to complete the input process of the cycle.
|
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.
|
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.
|
Window* DefaultWindow; // Default window to use for execution.
|
||||||
|
|
||||||
@ -128,15 +129,16 @@ namespace Execution
|
|||||||
CamRotationSpeed = 27.0f ; // Rate at which the camera should rotate.
|
CamRotationSpeed = 27.0f ; // Rate at which the camera should rotate.
|
||||||
|
|
||||||
TimeValDec InputDelta = 0.0, // Current delta since last input process.
|
TimeValDec InputDelta = 0.0, // Current delta since last input process.
|
||||||
|
InputBufferDelta = 0.0,
|
||||||
PhysicsDelta = 0.0, // Current delta since last physics process.
|
PhysicsDelta = 0.0, // Current delta since last physics process.
|
||||||
RenderDelta = 0.0 ; // Current delta since last render process.
|
RenderDelta = 0.0 ; // Current delta since last render process.
|
||||||
|
|
||||||
ActionQueue ActionsToComplete; // Actions queue to run during the physics process of the cycle.
|
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 Bunny ("./Models/bunny.obj" );
|
||||||
Model Cube ("./Models/blenderCube2.obj");
|
Model Cube ("./Models/blendercube2.obj");
|
||||||
Model Eight ("./Models/eight.obj" );
|
Model Eight ("./Models/eight.obj" );
|
||||||
Model Gargoyle ("./Models/gargoyle.obj" );
|
Model Gargoyle ("./Models/gargoyle.obj" );
|
||||||
Model Hand ("./Models/hand.obj" );
|
Model Hand ("./Models/hand.obj" );
|
||||||
@ -409,6 +411,9 @@ namespace Execution
|
|||||||
|
|
||||||
SetPolygonMode(DGL::EFace::Front_and_Back, DGL::ERenderMode::Fill);
|
SetPolygonMode(DGL::EFace::Front_and_Back, DGL::ERenderMode::Fill);
|
||||||
|
|
||||||
|
glShadeModel(GL_FLAT);
|
||||||
|
|
||||||
|
|
||||||
// Cursor stuff
|
// Cursor stuff
|
||||||
|
|
||||||
SetInputMode(DefaultWindow, DGL::EMouseMode::Cursor, DGL::ECursorMode::Disable);
|
SetInputMode(DefaultWindow, DGL::EMouseMode::Cursor, DGL::ECursorMode::Disable);
|
||||||
@ -430,14 +435,14 @@ namespace Execution
|
|||||||
|
|
||||||
Light.Load();
|
Light.Load();
|
||||||
|
|
||||||
Torus.Load();
|
Cube.Load();
|
||||||
|
|
||||||
ObjectMaterial.Color = DGL::Colors::WarmSphia.Vector();
|
ObjectMaterial.Color = DGL::Colors::WarmSphia.Vector();
|
||||||
ObjectMaterial.Ambience = 0.112f ;
|
ObjectMaterial.Ambience = 0.112f ;
|
||||||
ObjectMaterial.Diffuse = 0.928f ;
|
ObjectMaterial.Diffuse = 0.928f ;
|
||||||
ObjectMaterial.Specular = 0.21f ;
|
ObjectMaterial.Specular = 0.21f ;
|
||||||
|
|
||||||
ObjectToView = Entity_Basic(Torus, ObjectMaterial);
|
ObjectToView = Entity_Basic(Cube, ObjectMaterial);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -510,6 +515,8 @@ namespace Execution
|
|||||||
InputDelta += DeltaTime;
|
InputDelta += DeltaTime;
|
||||||
PhysicsDelta += DeltaTime;
|
PhysicsDelta += DeltaTime;
|
||||||
RenderDelta += DeltaTime;
|
RenderDelta += DeltaTime;
|
||||||
|
|
||||||
|
InputBufferDelta += DeltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -517,7 +524,14 @@ namespace Execution
|
|||||||
|
|
||||||
void InputProcedure(Window* _currentWindowContext)
|
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));
|
ECursorMode cursorMode = ECursorMode(GetMouseInputMode(DefaultWindow, EMouseMode::Cursor));
|
||||||
|
|
||||||
@ -538,15 +552,21 @@ namespace Execution
|
|||||||
|
|
||||||
CursorOff = false;
|
CursorOff = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
F1_Held = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (KeyPressed(_currentWindowContext, EKeyCodes::H))
|
if (KeyPressed(_currentWindowContext, EKeyCodes::H) && not H_Held)
|
||||||
{
|
{
|
||||||
|
H_Held = true;
|
||||||
|
|
||||||
ActionsToComplete.AddToQueue(ToogleLightDelegate);
|
ActionsToComplete.AddToQueue(ToogleLightDelegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (KeyPressed(_currentWindowContext, EKeyCodes::M))
|
if (KeyPressed(_currentWindowContext, EKeyCodes::M) && not M_Held)
|
||||||
{
|
{
|
||||||
|
M_Held = true;
|
||||||
|
|
||||||
ActionsToComplete.AddToQueue(ChangeModelDelegate);
|
ActionsToComplete.AddToQueue(ChangeModelDelegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
9
x64/Debug/CompGraphics.Build.CppClean.log
Normal file
9
x64/Debug/CompGraphics.Build.CppClean.log
Normal file
@ -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
|
3
x64/Debug/CompGraphics.log
Normal file
3
x64/Debug/CompGraphics.log
Normal file
@ -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
|
BIN
x64/Debug/CompGraphics.tlog/CL.command.1.tlog
Normal file
BIN
x64/Debug/CompGraphics.tlog/CL.command.1.tlog
Normal file
Binary file not shown.
BIN
x64/Debug/CompGraphics.tlog/CL.read.1.tlog
Normal file
BIN
x64/Debug/CompGraphics.tlog/CL.read.1.tlog
Normal file
Binary file not shown.
BIN
x64/Debug/CompGraphics.tlog/CL.write.1.tlog
Normal file
BIN
x64/Debug/CompGraphics.tlog/CL.write.1.tlog
Normal file
Binary file not shown.
2
x64/Debug/CompGraphics.tlog/CompGraphics.lastbuildstate
Normal file
2
x64/Debug/CompGraphics.tlog/CompGraphics.lastbuildstate
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#TargetFrameworkVersion=v4.0:PlatformToolSet=v142:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0
|
||||||
|
Debug|x64|F:\Projects\CompGraphics\|
|
BIN
x64/Debug/CompGraphics.tlog/link.command.1.tlog
Normal file
BIN
x64/Debug/CompGraphics.tlog/link.command.1.tlog
Normal file
Binary file not shown.
BIN
x64/Debug/CompGraphics.tlog/link.read.1.tlog
Normal file
BIN
x64/Debug/CompGraphics.tlog/link.read.1.tlog
Normal file
Binary file not shown.
BIN
x64/Debug/CompGraphics.tlog/link.write.1.tlog
Normal file
BIN
x64/Debug/CompGraphics.tlog/link.write.1.tlog
Normal file
Binary file not shown.
0
x64/Debug/CompGraphics.vcxproj.FileListAbsolute.txt
Normal file
0
x64/Debug/CompGraphics.vcxproj.FileListAbsolute.txt
Normal file
BIN
x64/Debug/Execution.obj
Normal file
BIN
x64/Debug/Execution.obj
Normal file
Binary file not shown.
BIN
x64/Debug/vc142.idb
Normal file
BIN
x64/Debug/vc142.idb
Normal file
Binary file not shown.
BIN
x64/Debug/vc142.pdb
Normal file
BIN
x64/Debug/vc142.pdb
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user