More lights

This commit is contained in:
MrLetsplay 2023-09-16 17:13:01 +02:00
parent f6bddc111b
commit fa41614783
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg
2 changed files with 17 additions and 5 deletions

@ -1 +1 @@
Subproject commit 2ff8debe8c607c90a9fa7df29577a24967b00cf9 Subproject commit 656603f4396872afd07565a02f5d73bb66885ec2

View File

@ -32,6 +32,7 @@ using namespace kek;
#define CHUNK_RADIUS 2 #define CHUNK_RADIUS 2
#define WALLS_PER_CHUNK 20 #define WALLS_PER_CHUNK 20
#define WALL_HEIGHT 9 #define WALL_HEIGHT 9
#define LIGHT_SPACING 8
static ButtonElement *buttonPlay; static ButtonElement *buttonPlay;
@ -42,6 +43,7 @@ struct Chunk {
GameObject *floor; GameObject *floor;
GameObject *ceiling; GameObject *ceiling;
std::vector<GameObject *> walls; std::vector<GameObject *> walls;
std::vector<PointLight *> lights;
}; };
std::map<long int, Chunk> loadedChunks; std::map<long int, Chunk> loadedChunks;
@ -56,10 +58,9 @@ void gameLoop(GLFWwindow *window, void *) {
glm::vec3 playerPos = player->getPosition(); glm::vec3 playerPos = player->getPosition();
Scene *scene = Engine::getActiveScene(); Scene *scene = Engine::getActiveScene();
SpotLight *fl = (SpotLight *) flashlight;
glm::vec3 playerRight = glm::cross(camera->direction, glm::vec3(0, 1, 0)); glm::vec3 playerRight = glm::cross(camera->direction, glm::vec3(0, 1, 0));
fl->moveTo(playerPos + glm::normalize(playerRight) * 0.3f); flashlight->moveTo(playerPos + glm::normalize(playerRight) * 0.3f);
fl->lookAt(camera->direction); flashlight->lookAt(camera->direction);
int chunkX = (int) playerPos.x / CHUNK_SIZE; int chunkX = (int) playerPos.x / CHUNK_SIZE;
int chunkZ = (int) playerPos.z / CHUNK_SIZE; int chunkZ = (int) playerPos.z / CHUNK_SIZE;
@ -118,7 +119,18 @@ void gameLoop(GLFWwindow *window, void *) {
walls.push_back(wall); walls.push_back(wall);
} }
Chunk newChunk{x, z, floor, ceiling, walls}; std::vector<PointLight *> lights;
// for(int lx = 0; lx < CHUNK_SIZE / LIGHT_SPACING; lx++) {
// for(int ly = 0; ly < CHUNK_SIZE / LIGHT_SPACING; ly++) {
// SpotLight *light = new SpotLight(glm::vec3(1), glm::vec3(0, -1, 0), 1, 1, 1, 0.5, 0.6);
PointLight *light = new PointLight(glm::vec3(1), 1, 1, 1);
light->moveTo(glm::vec3(x * CHUNK_SIZE, WALL_HEIGHT - 1, z * CHUNK_SIZE));
scene->lights->add(light);
lights.push_back(light);
// }
//}
Chunk newChunk{x, z, floor, ceiling, walls, lights};
loadedChunks.emplace(chunkID, newChunk); loadedChunks.emplace(chunkID, newChunk);
} }
} }