Fixed visual bugs, added stud snapping

Hope I've done this properly. Stud snapping is primitive and needs work done.
This commit is contained in:
unknown
2021-03-16 13:24:47 -04:00
parent d03e78a648
commit 3de82eb64d
19 changed files with 3263 additions and 72 deletions

View File

@@ -9,7 +9,6 @@ std::vector<GLfloat> _normals;
std::vector<GLushort> _indices;
Color3 color;
void addVertex(const Vector3& vertexPos,const Color3& color)
{
_vertices.push_back(vertexPos.x);
@@ -58,6 +57,66 @@ void makeFace(int vertex1,int vertex2, int vertex3)
Vector3(_vertices[vertex3],_vertices[vertex3+1],_vertices[vertex3+2]));
}
// Moved from the renderer function.
void drawBevels()
{
// Bevel Top Front
makeFace(0,36,48);
makeFace(48,18,0);
// Bevel Left Front Corner
makeFace(18,156,162);
makeFace(24,18,162);
// Bevel Left Front Top Corner
makeFace(48,156,18);
// Bevel Left Front Bottom Corner
makeFace(120,6,150);
// Bevel Left Top
makeFace(48,66,156);
makeFace(144,156,66);
// Bevel Bottom
makeFace(6,120,114);
makeFace(114,12,6);
// Left Bottom
makeFace(120,150,174);
makeFace(174,132,120);
// Right Front Top Corner
makeFace(36,0,180);
// Right Front Corner
makeFace(180,0,12);
makeFace(186,180,12);
// Right Front Bottom Corner
makeFace(186,12,114);
// Right Bottom
makeFace(186,114,108);
makeFace(108,198,186);
// Right Top Corner
makeFace(180,192,36);
makeFace(192,42,36);
// Right Back Top Corner
makeFace(72,42,192);
// Right Back Bottom Corner
makeFace(78,198,108);
// Right Back Corner
makeFace(72,192,198);
makeFace(198,78,72);
// Back Bottom Corner
makeFace(78,108,132);
makeFace(132,84,78);
// Back Top
makeFace(42,72,102);
makeFace(102,66,42);
// Back Left Top Corner
makeFace(144,66,102);
// Back Left Corner
makeFace(144,102,84);
makeFace(84,174,144);
// Back Left Bottom Corner
makeFace(174,84,132);
for (unsigned short i=0;i<_vertices.size()/6;i++) {
_indices.push_back(i);
}
}
void renderBlock(const Vector3& renderSize)
{
addTriangle(Vector3(renderSize.x-_bevelSize,renderSize.y-_bevelSize,renderSize.z),
@@ -119,62 +178,7 @@ void renderBlock(const Vector3& renderSize)
Vector3(renderSize.x,-renderSize.y+_bevelSize,renderSize.z-_bevelSize)
);
// Bevel Top Front
makeFace(0,36,48);
makeFace(48,18,0);
// Bevel Left Front Corner
makeFace(18,156,162);
makeFace(24,18,162);
// Bevel Left Front Top Corner
makeFace(48,156,18);
// Bevel Left Front Bottom Corner
makeFace(120,6,150);
// Bevel Left Top
makeFace(48,66,156);
makeFace(144,156,66);
// Bevel Bottom
makeFace(6,120,114);
makeFace(114,12,6);
// Left Bottom
makeFace(120,150,174);
makeFace(174,132,120);
// Right Front Top Corner
makeFace(36,0,180);
// Right Front Corner
makeFace(180,0,12);
makeFace(186,180,12);
// Right Front Bottom Corner
makeFace(186,12,114);
// Right Bottom
makeFace(186,114,108);
makeFace(108,198,186);
// Right Top Corner
makeFace(180,192,36);
makeFace(192,42,36);
// Right Back Top Corner
makeFace(72,42,192);
// Right Back Bottom Corner
makeFace(78,198,108);
// Right Back Corner
makeFace(72,192,198);
makeFace(198,78,72);
// Back Bottom Corner
makeFace(78,108,132);
makeFace(132,84,78);
// Back Top
makeFace(42,72,102);
makeFace(102,66,42);
// Back Left Top Corner
makeFace(144,66,102);
// Back Left Corner
makeFace(144,102,84);
makeFace(84,174,144);
// Back Left Bottom Corner
makeFace(174,84,132);
for (unsigned short i=0;i<_vertices.size()/6;i++) {
_indices.push_back(i);
}
drawBevels();
glVertexPointer(3, GL_FLOAT,6 * sizeof(GLfloat), &_vertices[0]);
glColorPointer(3, GL_FLOAT,6 * sizeof(GLfloat), &_vertices[3]);