it renders now
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 };
|
||||
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ private:
|
||||
|
||||
std::vector<glm::vec3> m_vertices;
|
||||
std::vector<glm::vec3> m_uvs;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user