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:
Edward R. Gonzalez 2020-02-21 16:05:46 -05:00
parent da17f52c9d
commit 6dd91a3531
17 changed files with 100 additions and 25 deletions

View File

@ -73,7 +73,7 @@ namespace DGL
struct Face
{
Vec3Int Vertexes, Normals;
Vec3Int Vertexes;
};
using FaceList = std::vector<Face>;
@ -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()

View File

@ -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>;

View File

@ -28,7 +28,7 @@ namespace DGL
// Constants
constexpr Window* NotShared () { return NULL; }
constexpr Monitor* WindowedMode() { return NULL; }
constexpr Monitor* WindowedMode() { return NULL; }

View File

@ -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);
}

View 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

View 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

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,2 @@
#TargetFrameworkVersion=v4.0:PlatformToolSet=v142:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0
Debug|x64|F:\Projects\CompGraphics\|

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
x64/Debug/Execution.obj Normal file

Binary file not shown.

BIN
x64/Debug/vc142.idb Normal file

Binary file not shown.

BIN
x64/Debug/vc142.pdb Normal file

Binary file not shown.