Basic alpha blending works but I have no z ordering yet.

This commit is contained in:
Zed A. Shaw 2026-08-29 16:08:33 -04:00
parent 128f522089
commit 11b7f4a3ed
14 changed files with 272 additions and 30 deletions

View file

@ -10,17 +10,18 @@ void Scene::update() {
camera.update(deltaTime);
}
void Scene::draw_model(Shader& with_shader, Model& scene_model, Material& material, glm::vec3& position, float scale)
void Scene::draw_thing(Shader& with_shader, Thing& thing)
{
with_shader.apply_material(material);
with_shader.apply_material(thing.material);
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, position);
model = glm::scale(model, glm::vec3(scale, scale, scale));
model = glm::translate(model, thing.position);
model = glm::rotate(model, glm::radians(thing.rotation.angle), thing.rotation.axes);
model = glm::scale(model, glm::vec3(thing.scale));
with_shader.setMat4("model", model);
scene_model.draw(with_shader);
thing.model.draw(with_shader);
}
void Scene::render(GLFWwindow* window) {
@ -47,7 +48,7 @@ void Scene::render(GLFWwindow* window) {
}
for(auto& thing : things) {
draw_model(shader, thing.model, thing.material, thing.position);
draw_thing(shader, thing);
}
}
@ -55,13 +56,15 @@ void Scene::cleanup() {
shader.cleanup();
}
void Scene::spawn(const std::string& name, components::Position& position) {
void Scene::spawn(const std::string& name, components::Position& position, components::Rotation& rotation) {
if(models.contains(name)) {
things.emplace_back(
name,
models.at(name),
position,
materials.at("default"));
name,
models.at(name),
materials.at("default"),
position,
rotation,
1.0f);
} else {
dbc::log($F("No model named: {}", name));
}