mirror of
https://github.com/Ed94/DuctTaped_GL.git
synced 2024-12-22 06:54:46 -08:00
Dropped some invisible tape in the model struct, and some double sided tape models.
This commit is contained in:
parent
599f444661
commit
8715347088
@ -1,32 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
mtllib cube.mtl
|
||||
|
||||
|
||||
#
|
||||
# cube Mesh
|
||||
#
|
||||
g cube Mesh
|
||||
|
||||
v 0.022541 0.000000 0.000000
|
||||
v 1.022541 1.000000 0.000000
|
||||
v 1.022541 0.000000 0.000000
|
||||
v 0.022541 1.000000 0.000000
|
||||
v 0.022541 1.000000 1.000000
|
||||
v 0.022541 0.000000 1.000000
|
||||
v 1.022541 1.000000 1.000000
|
||||
v 1.022541 0.000000 1.000000
|
||||
f 1 2 3
|
||||
f 1 4 2
|
||||
f 1 5 4
|
||||
f 1 6 5
|
||||
f 4 7 2
|
||||
f 4 5 7
|
||||
f 3 2 7
|
||||
f 3 7 8
|
||||
f 1 3 8
|
||||
f 1 8 6
|
||||
f 6 8 7
|
||||
f 6 7 5
|
@ -67,7 +67,9 @@ namespace DGL
|
||||
|
||||
struct Face
|
||||
{
|
||||
VecInt Vertexes, Normals;
|
||||
VecInt Vertexes,
|
||||
Normals;
|
||||
//UVs[3];
|
||||
};
|
||||
|
||||
using FaceList = std::vector<Face>;
|
||||
@ -95,7 +97,7 @@ namespace DGL
|
||||
|
||||
sfn GetFace() -> Face
|
||||
{
|
||||
Face generated;
|
||||
Face generated;// = { {0,0,0}, {0,0,0}, {0,0,0} };
|
||||
|
||||
for (int index = 0; index < 3; index++)
|
||||
{
|
||||
@ -135,8 +137,12 @@ namespace DGL
|
||||
|
||||
const string FilePath;
|
||||
|
||||
VertexList Verticies ;
|
||||
VertexList VertNormals;
|
||||
VertexList Verticies ;
|
||||
VertexList VertNormals ;
|
||||
|
||||
VertexList RAWVertex ;
|
||||
VertexList VertNormalsRAW;
|
||||
|
||||
UVList TextureMap ;
|
||||
FaceList Faces ;
|
||||
VIndexList Indicies ;
|
||||
@ -222,7 +228,7 @@ namespace DGL
|
||||
|
||||
_faceStream >> normalIndex >> ws;
|
||||
|
||||
faceMade.AddNormalIndex(normalIndex - 1);
|
||||
faceMade.AddNormalIndex(normalIndex -1);
|
||||
|
||||
Indicies.push_back(normalIndex - 1);
|
||||
}
|
||||
@ -311,12 +317,13 @@ namespace DGL
|
||||
Vector3 edge1 = Verticies[vertexIndex2] - Verticies[vertexIndex1],
|
||||
edge2 = Verticies[vertexIndex3] - Verticies[vertexIndex2],
|
||||
|
||||
normal = GetDirection(GetCrossNormal(edge1, edge2));
|
||||
normal = GetDirection(GetCrossNormal(edge2, edge1));
|
||||
|
||||
|
||||
normal[0] = RoundOff(normal[0], 7);
|
||||
normal[1] = RoundOff(normal[1], 7);
|
||||
normal[2] = RoundOff(normal[2], 7);
|
||||
normal[0] = normal[0]; // RoundOff(normal[0], 7);
|
||||
normal[1] = normal[1]; // RoundOff(normal[1], 7);
|
||||
normal[2] = normal[1]; // RoundOff(normal[2], 7);
|
||||
|
||||
|
||||
bool normalExists = false;
|
||||
|
||||
@ -328,6 +335,7 @@ namespace DGL
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!normalExists)
|
||||
{
|
||||
VertNormals.push_back(normal);
|
||||
@ -344,11 +352,47 @@ namespace DGL
|
||||
GenerateBuffers (Address(EBO), 1);
|
||||
|
||||
|
||||
if (VertNormals.size() == 0)
|
||||
/*if (VertNormals.size() == 0)
|
||||
{
|
||||
GenerateNormals();
|
||||
}*/
|
||||
|
||||
/*for (int index = 0; index < Faces.size(); index++)
|
||||
{
|
||||
cout << "FaceID: " << index << endl << endl;
|
||||
|
||||
for (int vertIndex = 0; vertIndex < 3; vertIndex++)
|
||||
{
|
||||
cout << "Vert Index: " << Faces[index].Vertexes[vertIndex] << endl;
|
||||
cout << "Face Index: " << Faces[index].Normals[vertIndex] << endl;
|
||||
|
||||
RAWVertex.push_back
|
||||
(
|
||||
Verticies[Faces[index].Vertexes[vertIndex]]
|
||||
);
|
||||
|
||||
RAWVertex.push_back
|
||||
(
|
||||
VertNormals[Faces[index].Normals[vertIndex]]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BindVertexArray(VAO);
|
||||
|
||||
BindBuffer(EBufferTarget::VertexAttributes, VBO);
|
||||
|
||||
BufferData(Address(RAWVertex[0]), RAWVertex.size() * sizeof(Vector3), EBufferTarget::VertexAttributes, EBufferUsage::StaticDraw);
|
||||
|
||||
FormatVertexAttributes<Vector3>(0, EDataType::Float, ZeroOffset(), 3, EBool::False);
|
||||
|
||||
EnableVertexAttributeArray(0);
|
||||
|
||||
FormatVertexAttributes<Vector3>(1, EDataType::Float, Offset(sizeof(Vector3)), 3, EBool::False);
|
||||
|
||||
EnableVertexAttributeArray(1);*/
|
||||
|
||||
BindVertexArray(VAO);
|
||||
|
||||
BindBuffer(EBufferTarget::VertexAttributes, VBO);
|
||||
@ -359,6 +403,7 @@ namespace DGL
|
||||
|
||||
EnableVertexAttributeArray(0);
|
||||
|
||||
|
||||
if (VertNormals.size() != 0)
|
||||
{
|
||||
BindBuffer(EBufferTarget::VertexAttributes, NBO);
|
||||
@ -382,12 +427,14 @@ namespace DGL
|
||||
{
|
||||
BindVertexArray(VAO);
|
||||
|
||||
BindBuffer(EBufferTarget::VertexIndices, EBO);
|
||||
BindBuffer(EBufferTarget::VertexAttributes, VBO);
|
||||
|
||||
gInt Size; GetBufferParameterIV(EBufferTarget::VertexIndices, EBufferParam::Size, Address(Size));
|
||||
|
||||
Size /= sizeof(gInt);
|
||||
|
||||
//DrawArrays(EPrimitives::Triangles, 0, RAWVertex.size());
|
||||
|
||||
DrawElements(EPrimitives::Triangles, Size, EDataType::UnsignedInt, ZeroOffset());
|
||||
|
||||
BindVertexArray(0);
|
||||
|
@ -36,7 +36,7 @@ void main()
|
||||
float specularStrength = 0.5;
|
||||
|
||||
vec3 viewDirection = normalize(ViewPosition - FragPosition);
|
||||
// vec3 ViewDirection = normalize(-FragPosition);
|
||||
// vec3 viewDirection = normalize(-FragPosition);
|
||||
|
||||
vec3 reflectionDirection = reflect(-lightDirection, direction);
|
||||
|
||||
@ -46,7 +46,7 @@ void main()
|
||||
|
||||
// Combining
|
||||
|
||||
vec3 result = (ambient + diffuse) * ObjectColor;
|
||||
vec3 result = (ambient + diffuse + specular) * ObjectColor;
|
||||
|
||||
FragColor = vec4(result, 1.0);
|
||||
}
|
@ -3,6 +3,9 @@
|
||||
layout (location = 0) in vec3 VertPosition;
|
||||
layout (location = 1) in vec3 VertNormal ;
|
||||
|
||||
varying vec3 vPosInterp;
|
||||
varying vec3 vNormalInterp;
|
||||
|
||||
out vec3 FragPosition ;
|
||||
out vec3 Normal ;
|
||||
out vec3 LightViewPosition;
|
||||
@ -24,7 +27,7 @@ void main()
|
||||
|
||||
FragPosition = vec3(Viewport * ModelSpace * vec4(VertPosition, 1.0));
|
||||
|
||||
Normal = mat3(transpose(InverseModelSpace)) * VertNormal;
|
||||
Normal = mat3(transpose(inverse(Viewport * ModelSpace))) * VertNormal;
|
||||
|
||||
LightViewPosition = vec3(Viewport * vec4(LightPosition, 1.0));
|
||||
|
||||
|
@ -356,7 +356,7 @@ sfn RAW_RenderCube()
|
||||
LinearColor CoralColor(1.0f, 0.5f, 0.31f, 1.0f);
|
||||
LinearColor LightColor(1.0f, 1.0f, 1.0f , 1.0f);
|
||||
|
||||
Vector3 LightPosition(1.2f, 2.0f, 3.0f);
|
||||
Vector3 LightPosition(1.2f, 2.0f, 0.5f);
|
||||
|
||||
Vector3 LightScale = Vector3(0.2f);
|
||||
|
||||
@ -481,7 +481,7 @@ sfn RAW_RenderLitCube(CoordSpace _projection, CoordSpace _viewport)
|
||||
|
||||
namespace ProperCube
|
||||
{
|
||||
Model model("torus.obj");
|
||||
Model model("cube.obj");
|
||||
|
||||
Vector3 position = Vector3(0.0f);
|
||||
|
||||
|
13
cubeGenNormals.mtl
Normal file
13
cubeGenNormals.mtl
Normal file
@ -0,0 +1,13 @@
|
||||
# File produced by Open Asset Import Library (http://www.assimp.sf.net)
|
||||
# (assimp v4.1.216079013)
|
||||
|
||||
newmtl DefaultMaterial
|
||||
Kd 0.6000000238418579 0.6000000238418579 0.6000000238418579
|
||||
Ka 0 0 0
|
||||
Ks 0 0 0
|
||||
Ke 0 0 0
|
||||
Tf 1 1 1
|
||||
d 1
|
||||
Ni 1
|
||||
illum 1
|
||||
|
41
cubeGenNormals.obj
Normal file
41
cubeGenNormals.obj
Normal file
@ -0,0 +1,41 @@
|
||||
# File produced by Open Asset Import Library (http://www.assimp.sf.net)
|
||||
# (assimp v4.1.216079013)
|
||||
|
||||
mtllib cubeGenNormals.mtl
|
||||
|
||||
# 8 vertex positions
|
||||
v 0.02254099957644939 0 0
|
||||
v 1.022541046142578 1 0
|
||||
v 1.022541046142578 0 0
|
||||
v 0.02254099957644939 1 0
|
||||
v 0.02254099957644939 1 1
|
||||
v 0.02254099957644939 0 1
|
||||
v 1.022541046142578 1 1
|
||||
v 1.022541046142578 0 1
|
||||
|
||||
# 0 UV coordinates
|
||||
|
||||
# 6 vertex normals
|
||||
vn 0 0 -1
|
||||
vn -1 0 0
|
||||
vn 0 1 0
|
||||
vn 1 0 0
|
||||
vn 0 -1 0
|
||||
vn 0 0 1
|
||||
|
||||
# Mesh 'cube Mesh' with 12 faces
|
||||
g cube Mesh
|
||||
usemtl DefaultMaterial
|
||||
f 1//1 2//1 3//1
|
||||
f 1//1 4//1 2//1
|
||||
f 1//2 5//2 4//2
|
||||
f 1//2 6//2 5//2
|
||||
f 4//3 7//3 2//3
|
||||
f 4//3 5//3 7//3
|
||||
f 3//4 2//4 7//4
|
||||
f 3//4 7//4 8//4
|
||||
f 1//5 3//5 8//5
|
||||
f 1//5 8//5 6//5
|
||||
f 6//6 8//6 7//6
|
||||
f 6//6 7//6 5//6
|
||||
|
13
horseWithNormals.mtl
Normal file
13
horseWithNormals.mtl
Normal file
@ -0,0 +1,13 @@
|
||||
# File produced by Open Asset Import Library (http://www.assimp.sf.net)
|
||||
# (assimp v4.1.216079013)
|
||||
|
||||
newmtl DefaultMaterial
|
||||
Kd 0.6000000238418579 0.6000000238418579 0.6000000238418579
|
||||
Ka 0 0 0
|
||||
Ks 0 0 0
|
||||
Ke 0 0 0
|
||||
Tf 1 1 1
|
||||
d 1
|
||||
Ni 1
|
||||
illum 1
|
||||
|
79873
horseWithNormals.obj
Normal file
79873
horseWithNormals.obj
Normal file
File diff suppressed because it is too large
Load Diff
13
torusWithNormals.mtl
Normal file
13
torusWithNormals.mtl
Normal file
@ -0,0 +1,13 @@
|
||||
# File produced by Open Asset Import Library (http://www.assimp.sf.net)
|
||||
# (assimp v4.1.216079013)
|
||||
|
||||
newmtl DefaultMaterial
|
||||
Kd 0.6000000238418579 0.6000000238418579 0.6000000238418579
|
||||
Ka 0 0 0
|
||||
Ks 0 0 0
|
||||
Ke 0 0 0
|
||||
Tf 1 1 1
|
||||
d 1
|
||||
Ni 1
|
||||
illum 1
|
||||
|
4106
torusWithNormals.obj
Normal file
4106
torusWithNormals.obj
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user