|
@@ -1,13 +1,12 @@
|
|
|
#include "barracks_renderer.h"
|
|
#include "barracks_renderer.h"
|
|
|
#include "registry.h"
|
|
#include "registry.h"
|
|
|
-#include "../gl/renderer.h"
|
|
|
|
|
#include "../gl/resources.h"
|
|
#include "../gl/resources.h"
|
|
|
#include "../../game/core/component.h"
|
|
#include "../../game/core/component.h"
|
|
|
|
|
|
|
|
namespace Render::GL {
|
|
namespace Render::GL {
|
|
|
|
|
|
|
|
-static void drawBarracks(const DrawParams& p) {
|
|
|
|
|
- if (!p.renderer || !p.resources || !p.entity) return;
|
|
|
|
|
|
|
+static void drawBarracks(const DrawContext& p, ISubmitter& out) {
|
|
|
|
|
+ if (!p.resources || !p.entity) return;
|
|
|
auto* t = p.entity->getComponent<Engine::Core::TransformComponent>();
|
|
auto* t = p.entity->getComponent<Engine::Core::TransformComponent>();
|
|
|
auto* r = p.entity->getComponent<Engine::Core::RenderableComponent>();
|
|
auto* r = p.entity->getComponent<Engine::Core::RenderableComponent>();
|
|
|
auto* u = p.entity->getComponent<Engine::Core::UnitComponent>();
|
|
auto* u = p.entity->getComponent<Engine::Core::UnitComponent>();
|
|
@@ -27,19 +26,19 @@ static void drawBarracks(const DrawParams& p) {
|
|
|
QMatrix4x4 foundation = p.model;
|
|
QMatrix4x4 foundation = p.model;
|
|
|
foundation.translate(0.0f, -0.15f, 0.0f);
|
|
foundation.translate(0.0f, -0.15f, 0.0f);
|
|
|
foundation.scale(1.35f, 0.10f, 1.2f);
|
|
foundation.scale(1.35f, 0.10f, 1.2f);
|
|
|
- p.renderer->drawMeshColored(p.resources->unit(), foundation, stone, p.resources->white());
|
|
|
|
|
|
|
+ out.mesh(p.resources->unit(), foundation, stone, p.resources->white(), 1.0f);
|
|
|
|
|
|
|
|
// Wooden walls (main volume)
|
|
// Wooden walls (main volume)
|
|
|
QMatrix4x4 walls = p.model;
|
|
QMatrix4x4 walls = p.model;
|
|
|
walls.scale(1.15f, 0.65f, 0.95f);
|
|
walls.scale(1.15f, 0.65f, 0.95f);
|
|
|
- p.renderer->drawMeshColored(p.resources->unit(), walls, wood, p.resources->white());
|
|
|
|
|
|
|
+ out.mesh(p.resources->unit(), walls, wood, p.resources->white(), 1.0f);
|
|
|
|
|
|
|
|
// Timber beams: vertical corners
|
|
// Timber beams: vertical corners
|
|
|
auto drawBeam = [&](float x, float z) {
|
|
auto drawBeam = [&](float x, float z) {
|
|
|
QMatrix4x4 b = p.model;
|
|
QMatrix4x4 b = p.model;
|
|
|
b.translate(x, 0.20f, z);
|
|
b.translate(x, 0.20f, z);
|
|
|
b.scale(0.06f, 0.75f, 0.06f);
|
|
b.scale(0.06f, 0.75f, 0.06f);
|
|
|
- p.renderer->drawMeshColored(p.resources->unit(), b, woodDark, p.resources->white());
|
|
|
|
|
|
|
+ out.mesh(p.resources->unit(), b, woodDark, p.resources->white(), 1.0f);
|
|
|
};
|
|
};
|
|
|
drawBeam( 0.9f, 0.7f);
|
|
drawBeam( 0.9f, 0.7f);
|
|
|
drawBeam(-0.9f, 0.7f);
|
|
drawBeam(-0.9f, 0.7f);
|
|
@@ -50,58 +49,58 @@ static void drawBarracks(const DrawParams& p) {
|
|
|
QMatrix4x4 roofBase = p.model;
|
|
QMatrix4x4 roofBase = p.model;
|
|
|
roofBase.translate(0.0f, 0.55f, 0.0f);
|
|
roofBase.translate(0.0f, 0.55f, 0.0f);
|
|
|
roofBase.scale(1.25f, 0.18f, 1.05f);
|
|
roofBase.scale(1.25f, 0.18f, 1.05f);
|
|
|
- p.renderer->drawMeshColored(p.resources->unit(), roofBase, thatch, p.resources->white());
|
|
|
|
|
|
|
+ out.mesh(p.resources->unit(), roofBase, thatch, p.resources->white(), 1.0f);
|
|
|
|
|
|
|
|
QMatrix4x4 roofMid = p.model;
|
|
QMatrix4x4 roofMid = p.model;
|
|
|
roofMid.translate(0.0f, 0.72f, 0.0f);
|
|
roofMid.translate(0.0f, 0.72f, 0.0f);
|
|
|
roofMid.scale(1.05f, 0.14f, 0.95f);
|
|
roofMid.scale(1.05f, 0.14f, 0.95f);
|
|
|
- p.renderer->drawMeshColored(p.resources->unit(), roofMid, thatch, p.resources->white());
|
|
|
|
|
|
|
+ out.mesh(p.resources->unit(), roofMid, thatch, p.resources->white(), 1.0f);
|
|
|
|
|
|
|
|
QMatrix4x4 roofRidge = p.model;
|
|
QMatrix4x4 roofRidge = p.model;
|
|
|
roofRidge.translate(0.0f, 0.86f, 0.0f);
|
|
roofRidge.translate(0.0f, 0.86f, 0.0f);
|
|
|
roofRidge.scale(0.85f, 0.12f, 0.85f);
|
|
roofRidge.scale(0.85f, 0.12f, 0.85f);
|
|
|
- p.renderer->drawMeshColored(p.resources->unit(), roofRidge, thatch, p.resources->white());
|
|
|
|
|
|
|
+ out.mesh(p.resources->unit(), roofRidge, thatch, p.resources->white(), 1.0f);
|
|
|
|
|
|
|
|
// Roof ridge beam
|
|
// Roof ridge beam
|
|
|
QMatrix4x4 ridge = p.model;
|
|
QMatrix4x4 ridge = p.model;
|
|
|
ridge.translate(0.0f, 0.96f, 0.0f);
|
|
ridge.translate(0.0f, 0.96f, 0.0f);
|
|
|
ridge.scale(1.1f, 0.04f, 0.12f);
|
|
ridge.scale(1.1f, 0.04f, 0.12f);
|
|
|
- p.renderer->drawMeshColored(p.resources->unit(), ridge, woodDark, p.resources->white());
|
|
|
|
|
|
|
+ out.mesh(p.resources->unit(), ridge, woodDark, p.resources->white(), 1.0f);
|
|
|
|
|
|
|
|
// Door at front
|
|
// Door at front
|
|
|
QMatrix4x4 door = p.model;
|
|
QMatrix4x4 door = p.model;
|
|
|
door.translate(0.0f, -0.02f, 0.62f);
|
|
door.translate(0.0f, -0.02f, 0.62f);
|
|
|
door.scale(0.25f, 0.38f, 0.06f);
|
|
door.scale(0.25f, 0.38f, 0.06f);
|
|
|
- p.renderer->drawMeshColored(p.resources->unit(), door, doorColor, p.resources->white());
|
|
|
|
|
|
|
+ out.mesh(p.resources->unit(), door, doorColor, p.resources->white(), 1.0f);
|
|
|
|
|
|
|
|
// Side annex (shed) on the right
|
|
// Side annex (shed) on the right
|
|
|
QMatrix4x4 annex = p.model;
|
|
QMatrix4x4 annex = p.model;
|
|
|
annex.translate(0.95f, -0.05f, -0.15f);
|
|
annex.translate(0.95f, -0.05f, -0.15f);
|
|
|
annex.scale(0.55f, 0.45f, 0.55f);
|
|
annex.scale(0.55f, 0.45f, 0.55f);
|
|
|
- p.renderer->drawMeshColored(p.resources->unit(), annex, wood, p.resources->white());
|
|
|
|
|
|
|
+ out.mesh(p.resources->unit(), annex, wood, p.resources->white(), 1.0f);
|
|
|
|
|
|
|
|
QMatrix4x4 annexRoof = p.model;
|
|
QMatrix4x4 annexRoof = p.model;
|
|
|
annexRoof.translate(0.95f, 0.30f, -0.15f);
|
|
annexRoof.translate(0.95f, 0.30f, -0.15f);
|
|
|
annexRoof.scale(0.60f, 0.12f, 0.60f);
|
|
annexRoof.scale(0.60f, 0.12f, 0.60f);
|
|
|
- p.renderer->drawMeshColored(p.resources->unit(), annexRoof, thatch, p.resources->white());
|
|
|
|
|
|
|
+ out.mesh(p.resources->unit(), annexRoof, thatch, p.resources->white(), 1.0f);
|
|
|
|
|
|
|
|
// Chimney on the back-left
|
|
// Chimney on the back-left
|
|
|
QMatrix4x4 chimney = p.model;
|
|
QMatrix4x4 chimney = p.model;
|
|
|
chimney.translate(-0.65f, 0.75f, -0.55f);
|
|
chimney.translate(-0.65f, 0.75f, -0.55f);
|
|
|
chimney.scale(0.10f, 0.35f, 0.10f);
|
|
chimney.scale(0.10f, 0.35f, 0.10f);
|
|
|
- p.renderer->drawMeshColored(p.resources->unit(), chimney, stone, p.resources->white());
|
|
|
|
|
|
|
+ out.mesh(p.resources->unit(), chimney, stone, p.resources->white(), 1.0f);
|
|
|
|
|
|
|
|
QMatrix4x4 chimneyCap = p.model;
|
|
QMatrix4x4 chimneyCap = p.model;
|
|
|
chimneyCap.translate(-0.65f, 0.95f, -0.55f);
|
|
chimneyCap.translate(-0.65f, 0.95f, -0.55f);
|
|
|
chimneyCap.scale(0.16f, 0.05f, 0.16f);
|
|
chimneyCap.scale(0.16f, 0.05f, 0.16f);
|
|
|
- p.renderer->drawMeshColored(p.resources->unit(), chimneyCap, stone, p.resources->white());
|
|
|
|
|
|
|
+ out.mesh(p.resources->unit(), chimneyCap, stone, p.resources->white(), 1.0f);
|
|
|
|
|
|
|
|
// Path stones leading from door
|
|
// Path stones leading from door
|
|
|
auto drawPaver = [&](float ox, float oz, float sx, float sz) {
|
|
auto drawPaver = [&](float ox, float oz, float sx, float sz) {
|
|
|
QMatrix4x4 paver = p.model;
|
|
QMatrix4x4 paver = p.model;
|
|
|
paver.translate(ox, -0.14f, oz);
|
|
paver.translate(ox, -0.14f, oz);
|
|
|
paver.scale(sx, 0.02f, sz);
|
|
paver.scale(sx, 0.02f, sz);
|
|
|
- p.renderer->drawMeshColored(p.resources->unit(), paver, path, p.resources->white());
|
|
|
|
|
|
|
+ out.mesh(p.resources->unit(), paver, path, p.resources->white(), 1.0f);
|
|
|
};
|
|
};
|
|
|
drawPaver( 0.0f, 0.9f, 0.25f, 0.20f);
|
|
drawPaver( 0.0f, 0.9f, 0.25f, 0.20f);
|
|
|
drawPaver( 0.0f, 1.15f, 0.22f, 0.18f);
|
|
drawPaver( 0.0f, 1.15f, 0.22f, 0.18f);
|
|
@@ -109,28 +108,56 @@ static void drawBarracks(const DrawParams& p) {
|
|
|
|
|
|
|
|
// Crates near the door
|
|
// Crates near the door
|
|
|
QMatrix4x4 crate1 = p.model; crate1.translate(0.45f, -0.05f, 0.55f); crate1.scale(0.18f, 0.18f, 0.18f);
|
|
QMatrix4x4 crate1 = p.model; crate1.translate(0.45f, -0.05f, 0.55f); crate1.scale(0.18f, 0.18f, 0.18f);
|
|
|
- p.renderer->drawMeshColored(p.resources->unit(), crate1, crate, p.resources->white());
|
|
|
|
|
|
|
+ out.mesh(p.resources->unit(), crate1, crate, p.resources->white(), 1.0f);
|
|
|
QMatrix4x4 crate2 = p.model; crate2.translate(0.58f, 0.02f, 0.45f); crate2.scale(0.14f, 0.14f, 0.14f);
|
|
QMatrix4x4 crate2 = p.model; crate2.translate(0.58f, 0.02f, 0.45f); crate2.scale(0.14f, 0.14f, 0.14f);
|
|
|
- p.renderer->drawMeshColored(p.resources->unit(), crate2, crate, p.resources->white());
|
|
|
|
|
|
|
+ out.mesh(p.resources->unit(), crate2, crate, p.resources->white(), 1.0f);
|
|
|
|
|
|
|
|
// Simple fence posts on front-left
|
|
// Simple fence posts on front-left
|
|
|
for (int i=0;i<3;++i) {
|
|
for (int i=0;i<3;++i) {
|
|
|
QMatrix4x4 post = p.model;
|
|
QMatrix4x4 post = p.model;
|
|
|
post.translate(-0.85f + 0.18f * i, -0.05f, 0.85f);
|
|
post.translate(-0.85f + 0.18f * i, -0.05f, 0.85f);
|
|
|
post.scale(0.05f, 0.25f, 0.05f);
|
|
post.scale(0.05f, 0.25f, 0.05f);
|
|
|
- p.renderer->drawMeshColored(p.resources->unit(), post, woodDark, p.resources->white());
|
|
|
|
|
|
|
+ out.mesh(p.resources->unit(), post, woodDark, p.resources->white(), 1.0f);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Banner pole with team-colored flag
|
|
// Banner pole with team-colored flag
|
|
|
QMatrix4x4 pole = p.model;
|
|
QMatrix4x4 pole = p.model;
|
|
|
pole.translate(-0.9f, 0.55f, -0.55f);
|
|
pole.translate(-0.9f, 0.55f, -0.55f);
|
|
|
pole.scale(0.05f, 0.7f, 0.05f);
|
|
pole.scale(0.05f, 0.7f, 0.05f);
|
|
|
- p.renderer->drawMeshColored(p.resources->unit(), pole, woodDark, p.resources->white());
|
|
|
|
|
|
|
+ out.mesh(p.resources->unit(), pole, woodDark, p.resources->white(), 1.0f);
|
|
|
|
|
|
|
|
QMatrix4x4 banner = p.model;
|
|
QMatrix4x4 banner = p.model;
|
|
|
banner.translate(-0.82f, 0.80f, -0.50f);
|
|
banner.translate(-0.82f, 0.80f, -0.50f);
|
|
|
banner.scale(0.35f, 0.22f, 0.02f);
|
|
banner.scale(0.35f, 0.22f, 0.02f);
|
|
|
- p.renderer->drawMeshColored(p.resources->unit(), banner, team, p.resources->white());
|
|
|
|
|
|
|
+ out.mesh(p.resources->unit(), banner, team, p.resources->white(), 1.0f);
|
|
|
|
|
+
|
|
|
|
|
+ // Rally flag if set
|
|
|
|
|
+ if (auto* prod = p.entity->getComponent<Engine::Core::ProductionComponent>()) {
|
|
|
|
|
+ if (prod->rallySet && p.resources) {
|
|
|
|
|
+ QMatrix4x4 flagModel;
|
|
|
|
|
+ flagModel.translate(prod->rallyX, 0.1f, prod->rallyZ);
|
|
|
|
|
+ flagModel.scale(0.2f, 0.2f, 0.2f);
|
|
|
|
|
+ out.mesh(p.resources->unit(), flagModel, QVector3D(1.0f, 0.9f, 0.2f), p.resources->white(), 1.0f);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Selection smoke if selected (twice the previous diameter ~ scale *2.0)
|
|
|
|
|
+ if (p.selected) {
|
|
|
|
|
+ QMatrix4x4 m;
|
|
|
|
|
+ QVector3D pos = p.model.column(3).toVector3D();
|
|
|
|
|
+ // Force ground-level placement; ignore model's Y height for discs
|
|
|
|
|
+ m.translate(pos.x(), 0.0f, pos.z());
|
|
|
|
|
+ m.scale(1.8f, 1.0f, 1.8f); // previously ~0.9, now doubled
|
|
|
|
|
+ out.selectionSmoke(m, QVector3D(0.2f, 0.8f, 0.2f), 0.32f);
|
|
|
|
|
+ }
|
|
|
|
|
+ // Hover smoke if hovered and not selected (subtle)
|
|
|
|
|
+ else if (p.hovered) {
|
|
|
|
|
+ QMatrix4x4 m;
|
|
|
|
|
+ QVector3D pos = p.model.column(3).toVector3D();
|
|
|
|
|
+ m.translate(pos.x(), 0.0f, pos.z());
|
|
|
|
|
+ m.scale(1.8f, 1.0f, 1.8f);
|
|
|
|
|
+ out.selectionSmoke(m, QVector3D(0.90f, 0.90f, 0.25f), 0.20f);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void registerBarracksRenderer(EntityRendererRegistry& registry) {
|
|
void registerBarracksRenderer(EntityRendererRegistry& registry) {
|