it renders now

This commit is contained in:
Ben Kyd
2019-10-15 17:36:17 +01:00
parent fdc87ba343
commit d6618506d3
4 changed files with 23 additions and 19 deletions

View File

@@ -7,10 +7,12 @@
Chunk::Chunk() {
m_model = glm::mat4(1.0f);
for (int x = 0; x < CHUNK_WIDTH; x++)
for (int y = 0; y < CHUNK_HEIGHT; y++)
for (int z = 0; z < CHUNK_HEIGHT; z++) {
Voxels.push_back(std::make_shared<Voxel>(x, y, z));
}
@@ -23,6 +25,7 @@ Chunk::Chunk() {
Chunk::Chunk(std::vector<std::shared_ptr<Voxel>> voxels) {
m_model = glm::mat4(1.0f);
Voxels = voxels;
m_mesh();
@@ -57,8 +60,8 @@ void Chunk::m_mesh() {
for (auto& voxel : Voxels) {
std::vector<glm::vec3>tempVerts;
std::vector<glm::vec3>tempUVs;
std::vector<glm::vec3> tempVerts;
std::vector<glm::vec3> tempUVs;
voxel->GetMesh(tempVerts, tempUVs);

View File

@@ -3,9 +3,9 @@
#include "../common.hpp"
#define CHUNK_HEIGHT 1
#define CHUNK_WIDTH 1
#define CHUNK_DEPTH 1
#define CHUNK_HEIGHT 10
#define CHUNK_WIDTH 10
#define CHUNK_DEPTH 10
class Camera;
class Shader;

View File

@@ -10,16 +10,14 @@ Voxel::Voxel(int x, int y, int z) {
m_model = glm::translate(glm::mat4(1.0f), { (float)x, (float)y, (float)z });
//glm::mat4 Matrix = {
// {1, 3, 0, 0},
// {0, 1, 0, 0},
// glm::mat4 Matrix = {
// {1, 3, 0, 0},
// {0, 1, 0, 0},
// {0, 0, 1, 0},
// {0, 0, 0, 1},
//};
// {0, 0, 0, 1},
// };
//m_model = Matrix * m_model;
// m_model = Matrix * m_model;
// Texture winding order - top, bottom, left, right, front, back
@@ -34,21 +32,23 @@ Voxel::Voxel(int x, int y, int z) {
std::vector<glm::vec3> Vert;
std::vector<glm::vec3> UVs;
face.GetMesh(Vert, UVs);
m_vertices.insert(m_vertices.end(), Vert.begin(), Vert.end());
m_uvs.insert(m_uvs.end(), UVs.begin(), UVs.end());
}
/*
for (auto& vert : m_vertices) {
glm::vec4 tmp = { vert, 1 };
for (int i = 0; i < m_vertices.size(); i++) {
glm::vec4 tmp = { m_vertices[i], 1 };
glm::vec4 res = tmp * m_model;
vert = { res.x, res.y, res.z };
m_vertices[i] = { res.x, res.y, res.z };
}*/
}
}

View File

@@ -22,6 +22,7 @@ private:
std::vector<glm::vec3> m_vertices;
std::vector<glm::vec3> m_uvs;
};
#endif