|
|
@@ -38,7 +38,7 @@ struct CarthagePalette {
|
|
|
QVector3D team_trim{0.48F, 0.54F, 0.60F};
|
|
|
};
|
|
|
|
|
|
-inline auto makePalette(const QVector3D &team) -> CarthagePalette {
|
|
|
+inline auto make_palette(const QVector3D &team) -> CarthagePalette {
|
|
|
CarthagePalette p;
|
|
|
p.team = clampVec01(team);
|
|
|
p.team_trim =
|
|
|
@@ -46,7 +46,7 @@ inline auto makePalette(const QVector3D &team) -> CarthagePalette {
|
|
|
return p;
|
|
|
}
|
|
|
|
|
|
-inline void drawBox(ISubmitter &out, Mesh *unit, Texture *white,
|
|
|
+inline void draw_box(ISubmitter &out, Mesh *unit, Texture *white,
|
|
|
const QMatrix4x4 &model, const QVector3D &pos,
|
|
|
const QVector3D &size, const QVector3D &color) {
|
|
|
QMatrix4x4 m = model;
|
|
|
@@ -55,33 +55,33 @@ inline void drawBox(ISubmitter &out, Mesh *unit, Texture *white,
|
|
|
out.mesh(unit, m, color, white, 1.0F);
|
|
|
}
|
|
|
|
|
|
-inline void drawCyl(ISubmitter &out, const QMatrix4x4 &model,
|
|
|
+inline void draw_cyl(ISubmitter &out, const QMatrix4x4 &model,
|
|
|
const QVector3D &a, const QVector3D &b, float r,
|
|
|
const QVector3D &color, Texture *white) {
|
|
|
out.mesh(getUnitCylinder(), model * cylinderBetween(a, b, r), color, white,
|
|
|
1.0F);
|
|
|
}
|
|
|
|
|
|
-void drawPlatform(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
+void draw_platform(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
Texture *white, const CarthagePalette &c) {
|
|
|
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(0.0F, 0.08F, 0.0F),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(0.0F, 0.08F, 0.0F),
|
|
|
QVector3D(2.0F, 0.08F, 1.8F), c.limestone_dark);
|
|
|
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(0.0F, 0.18F, 0.0F),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(0.0F, 0.18F, 0.0F),
|
|
|
QVector3D(1.8F, 0.02F, 1.6F), c.limestone);
|
|
|
|
|
|
for (float x = -1.5F; x <= 1.5F; x += 0.35F) {
|
|
|
for (float z = -1.3F; z <= 1.3F; z += 0.35F) {
|
|
|
if (fabsf(x) > 0.6F || fabsf(z) > 0.5F) {
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(x, 0.21F, z),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(x, 0.21F, z),
|
|
|
QVector3D(0.15F, 0.01F, 0.15F), c.terracotta);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void drawColonnade(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
+void draw_colonnade(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
Texture *white, const CarthagePalette &c) {
|
|
|
float const col_height = 1.6F;
|
|
|
float const col_radius = 0.10F;
|
|
|
@@ -90,17 +90,17 @@ void drawColonnade(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
float const x = -1.25F + float(i) * 0.5F;
|
|
|
float const z = 1.4F;
|
|
|
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(x, 0.25F, z),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(x, 0.25F, z),
|
|
|
QVector3D(col_radius * 1.2F, 0.05F, col_radius * 1.2F), c.marble);
|
|
|
|
|
|
- drawCyl(out, p.model, QVector3D(x, 0.2F, z),
|
|
|
+ draw_cyl(out, p.model, QVector3D(x, 0.2F, z),
|
|
|
QVector3D(x, 0.2F + col_height, z), col_radius, c.limestone, white);
|
|
|
|
|
|
- drawBox(out, unit, white, p.model,
|
|
|
+ draw_box(out, unit, white, p.model,
|
|
|
QVector3D(x, 0.2F + col_height + 0.05F, z),
|
|
|
QVector3D(col_radius * 1.5F, 0.08F, col_radius * 1.5F), c.marble);
|
|
|
|
|
|
- drawBox(out, unit, white, p.model,
|
|
|
+ draw_box(out, unit, white, p.model,
|
|
|
QVector3D(x, 0.2F + col_height + 0.12F, z),
|
|
|
QVector3D(col_radius * 1.3F, 0.04F, col_radius * 1.3F), c.gold);
|
|
|
}
|
|
|
@@ -109,107 +109,107 @@ void drawColonnade(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
float const z = -1.0F + float(i) * 1.0F;
|
|
|
|
|
|
float const x_left = -1.6F;
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(x_left, 0.25F, z),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(x_left, 0.25F, z),
|
|
|
QVector3D(col_radius * 1.2F, 0.05F, col_radius * 1.2F), c.marble);
|
|
|
- drawCyl(out, p.model, QVector3D(x_left, 0.2F, z),
|
|
|
+ draw_cyl(out, p.model, QVector3D(x_left, 0.2F, z),
|
|
|
QVector3D(x_left, 0.2F + col_height, z), col_radius, c.limestone,
|
|
|
white);
|
|
|
- drawBox(out, unit, white, p.model,
|
|
|
+ draw_box(out, unit, white, p.model,
|
|
|
QVector3D(x_left, 0.2F + col_height + 0.05F, z),
|
|
|
QVector3D(col_radius * 1.5F, 0.08F, col_radius * 1.5F), c.marble);
|
|
|
|
|
|
float const x_right = 1.6F;
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(x_right, 0.25F, z),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(x_right, 0.25F, z),
|
|
|
QVector3D(col_radius * 1.2F, 0.05F, col_radius * 1.2F), c.marble);
|
|
|
- drawCyl(out, p.model, QVector3D(x_right, 0.2F, z),
|
|
|
+ draw_cyl(out, p.model, QVector3D(x_right, 0.2F, z),
|
|
|
QVector3D(x_right, 0.2F + col_height, z), col_radius, c.limestone,
|
|
|
white);
|
|
|
- drawBox(out, unit, white, p.model,
|
|
|
+ draw_box(out, unit, white, p.model,
|
|
|
QVector3D(x_right, 0.2F + col_height + 0.05F, z),
|
|
|
QVector3D(col_radius * 1.5F, 0.08F, col_radius * 1.5F), c.marble);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void drawCentralCourtyard(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
+void draw_central_courtyard(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
Texture *white, const CarthagePalette &c) {
|
|
|
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(0.0F, 0.22F, 0.0F),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(0.0F, 0.22F, 0.0F),
|
|
|
QVector3D(1.3F, 0.01F, 1.1F), c.limestone_shade);
|
|
|
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(0.0F, 0.24F, 0.0F),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(0.0F, 0.24F, 0.0F),
|
|
|
QVector3D(0.7F, 0.02F, 0.5F), c.blue_light);
|
|
|
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(0.0F, 0.25F, -0.52F),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(0.0F, 0.25F, -0.52F),
|
|
|
QVector3D(0.72F, 0.02F, 0.02F), c.blue_accent);
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(0.0F, 0.25F, 0.52F),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(0.0F, 0.25F, 0.52F),
|
|
|
QVector3D(0.72F, 0.02F, 0.02F), c.blue_accent);
|
|
|
|
|
|
- drawCyl(out, p.model, QVector3D(0.0F, 0.25F, 0.0F),
|
|
|
+ draw_cyl(out, p.model, QVector3D(0.0F, 0.25F, 0.0F),
|
|
|
QVector3D(0.0F, 0.55F, 0.0F), 0.06F, c.marble, white);
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(0.0F, 0.58F, 0.0F),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(0.0F, 0.58F, 0.0F),
|
|
|
QVector3D(0.08F, 0.03F, 0.08F), c.blue_accent);
|
|
|
}
|
|
|
|
|
|
-void drawChamber(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
+void draw_chamber(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
Texture *white, const CarthagePalette &c) {
|
|
|
float const wall_h = 1.4F;
|
|
|
|
|
|
- drawBox(out, unit, white, p.model,
|
|
|
+ draw_box(out, unit, white, p.model,
|
|
|
QVector3D(0.0F, wall_h * 0.5F + 0.2F, -1.2F),
|
|
|
QVector3D(1.4F, wall_h * 0.5F, 0.1F), c.limestone);
|
|
|
|
|
|
- drawBox(out, unit, white, p.model,
|
|
|
+ draw_box(out, unit, white, p.model,
|
|
|
QVector3D(-1.5F, wall_h * 0.5F + 0.2F, -0.5F),
|
|
|
QVector3D(0.1F, wall_h * 0.5F, 0.6F), c.limestone);
|
|
|
- drawBox(out, unit, white, p.model,
|
|
|
+ draw_box(out, unit, white, p.model,
|
|
|
QVector3D(1.5F, wall_h * 0.5F + 0.2F, -0.5F),
|
|
|
QVector3D(0.1F, wall_h * 0.5F, 0.6F), c.limestone);
|
|
|
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(-0.6F, 0.65F, -1.15F),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(-0.6F, 0.65F, -1.15F),
|
|
|
QVector3D(0.25F, 0.35F, 0.03F), c.cedar_dark);
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(-0.6F, 0.98F, -1.15F),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(-0.6F, 0.98F, -1.15F),
|
|
|
QVector3D(0.25F, 0.05F, 0.03F), c.blue_accent);
|
|
|
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(0.6F, 0.65F, -1.15F),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(0.6F, 0.65F, -1.15F),
|
|
|
QVector3D(0.25F, 0.35F, 0.03F), c.cedar_dark);
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(0.6F, 0.98F, -1.15F),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(0.6F, 0.98F, -1.15F),
|
|
|
QVector3D(0.25F, 0.05F, 0.03F), c.blue_accent);
|
|
|
}
|
|
|
|
|
|
-void drawTerrace(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
+void draw_terrace(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
Texture *white, const CarthagePalette &c) {
|
|
|
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(0.0F, 2.05F, 0.0F),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(0.0F, 2.05F, 0.0F),
|
|
|
QVector3D(1.7F, 0.08F, 1.5F), c.marble);
|
|
|
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(0.0F, 2.12F, 1.45F),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(0.0F, 2.12F, 1.45F),
|
|
|
QVector3D(1.65F, 0.05F, 0.05F), c.gold);
|
|
|
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(0.0F, 2.18F, -0.2F),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(0.0F, 2.18F, -0.2F),
|
|
|
QVector3D(1.5F, 0.04F, 1.0F), c.terracotta);
|
|
|
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(0.0F, 2.28F, -0.65F),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(0.0F, 2.28F, -0.65F),
|
|
|
QVector3D(1.45F, 0.06F, 0.05F), c.limestone);
|
|
|
|
|
|
for (float x : {-1.4F, 1.4F}) {
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(x, 2.35F, -0.65F),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(x, 2.35F, -0.65F),
|
|
|
QVector3D(0.08F, 0.08F, 0.08F), c.gold);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void drawTradingGoods(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
+void draw_trading_goods(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
Texture *white, const CarthagePalette &c) {
|
|
|
|
|
|
- drawCyl(out, p.model, QVector3D(-1.2F, 0.2F, 1.1F),
|
|
|
+ draw_cyl(out, p.model, QVector3D(-1.2F, 0.2F, 1.1F),
|
|
|
QVector3D(-1.2F, 0.5F, 1.1F), 0.08F, c.terracotta_dark, white);
|
|
|
- drawCyl(out, p.model, QVector3D(-0.9F, 0.2F, 1.15F),
|
|
|
+ draw_cyl(out, p.model, QVector3D(-0.9F, 0.2F, 1.15F),
|
|
|
QVector3D(-0.9F, 0.45F, 1.15F), 0.07F, c.terracotta, white);
|
|
|
|
|
|
- drawCyl(out, p.model, QVector3D(1.1F, 0.2F, -0.9F),
|
|
|
+ draw_cyl(out, p.model, QVector3D(1.1F, 0.2F, -0.9F),
|
|
|
QVector3D(1.1F, 0.42F, -0.9F), 0.06F, c.blue_accent, white);
|
|
|
}
|
|
|
|
|
|
-void drawPhoenicianBanner(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
+void draw_phoenician_banner(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
Texture *white, const CarthagePalette &c) {
|
|
|
float const pole_x = 0.0F;
|
|
|
float const pole_z = -2.0F;
|
|
|
@@ -231,7 +231,7 @@ void drawPhoenicianBanner(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
float const beam_length = banner_width * 0.45F;
|
|
|
float const max_lowering = pole_height * 0.85F;
|
|
|
|
|
|
- auto captureColors = BarracksFlagRenderer::getCaptureColors(
|
|
|
+ auto captureColors = BarracksFlagRenderer::get_capture_colors(
|
|
|
p, c.team, c.team_trim, max_lowering);
|
|
|
|
|
|
float beam_y =
|
|
|
@@ -273,22 +273,22 @@ void drawPhoenicianBanner(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
trimTop.scale(QVector3D(banner_width / 2.0F + 0.02F, 0.04F, 0.015F));
|
|
|
out.mesh(unit, trimTop, captureColors.teamTrimColor, white, 1.0F);
|
|
|
|
|
|
- drawBox(out, unit, white, p.model,
|
|
|
+ draw_box(out, unit, white, p.model,
|
|
|
QVector3D(pole_x + 0.2F, pole_height + 0.12F, pole_z + 0.03F),
|
|
|
QVector3D(0.26F, 0.02F, 0.01F), c.gold);
|
|
|
}
|
|
|
|
|
|
-void drawRallyFlag(const DrawContext &p, ISubmitter &out, Texture *white,
|
|
|
+void draw_rally_flag(const DrawContext &p, ISubmitter &out, Texture *white,
|
|
|
const CarthagePalette &c) {
|
|
|
BarracksFlagRenderer::FlagColors colors{.team = c.team,
|
|
|
.teamTrim = c.team_trim,
|
|
|
.timber = c.cedar,
|
|
|
.timberLight = c.limestone,
|
|
|
.woodDark = c.cedar_dark};
|
|
|
- BarracksFlagRenderer::drawRallyFlagIfAny(p, out, white, colors);
|
|
|
+ BarracksFlagRenderer::draw_rally_flag_if_any(p, out, white, colors);
|
|
|
}
|
|
|
|
|
|
-void drawHealthBar(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
+void draw_health_bar(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
Texture *white) {
|
|
|
if (p.entity == nullptr)
|
|
|
return;
|
|
|
@@ -302,17 +302,17 @@ void drawHealthBar(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
return;
|
|
|
|
|
|
QVector3D const bg(0.06F, 0.06F, 0.06F);
|
|
|
- drawBox(out, unit, white, p.model, QVector3D(0.0F, 2.65F, 0.0F),
|
|
|
+ draw_box(out, unit, white, p.model, QVector3D(0.0F, 2.65F, 0.0F),
|
|
|
QVector3D(0.9F, 0.04F, 0.06F), bg);
|
|
|
|
|
|
QVector3D const fg = QVector3D(0.22F, 0.78F, 0.22F) * ratio +
|
|
|
QVector3D(0.85F, 0.15F, 0.15F) * (1.0F - ratio);
|
|
|
- drawBox(out, unit, white, p.model,
|
|
|
+ draw_box(out, unit, white, p.model,
|
|
|
QVector3D(-(0.9F * (1.0F - ratio)) * 0.5F, 2.66F, 0.0F),
|
|
|
QVector3D(0.9F * ratio * 0.5F, 0.035F, 0.055F), fg);
|
|
|
}
|
|
|
|
|
|
-void drawSelection(const DrawContext &p, ISubmitter &out) {
|
|
|
+void draw_selection(const DrawContext &p, ISubmitter &out) {
|
|
|
QMatrix4x4 m;
|
|
|
QVector3D const pos = p.model.column(3).toVector3D();
|
|
|
m.translate(pos.x(), 0.0F, pos.z());
|
|
|
@@ -324,7 +324,7 @@ void drawSelection(const DrawContext &p, ISubmitter &out) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void drawBarracks(const DrawContext &p, ISubmitter &out) {
|
|
|
+void draw_barracks(const DrawContext &p, ISubmitter &out) {
|
|
|
if (!p.resources || !p.entity)
|
|
|
return;
|
|
|
|
|
|
@@ -336,24 +336,24 @@ void drawBarracks(const DrawContext &p, ISubmitter &out) {
|
|
|
Mesh *unit = p.resources->unit();
|
|
|
Texture *white = p.resources->white();
|
|
|
QVector3D const team(r->color[0], r->color[1], r->color[2]);
|
|
|
- CarthagePalette const c = makePalette(team);
|
|
|
-
|
|
|
- drawPlatform(p, out, unit, white, c);
|
|
|
- drawColonnade(p, out, unit, white, c);
|
|
|
- drawCentralCourtyard(p, out, unit, white, c);
|
|
|
- drawChamber(p, out, unit, white, c);
|
|
|
- drawTerrace(p, out, unit, white, c);
|
|
|
- drawTradingGoods(p, out, unit, white, c);
|
|
|
- drawPhoenicianBanner(p, out, unit, white, c);
|
|
|
- drawRallyFlag(p, out, white, c);
|
|
|
- drawHealthBar(p, out, unit, white);
|
|
|
- drawSelection(p, out);
|
|
|
+ CarthagePalette const c = make_palette(team);
|
|
|
+
|
|
|
+ draw_platform(p, out, unit, white, c);
|
|
|
+ draw_colonnade(p, out, unit, white, c);
|
|
|
+ draw_central_courtyard(p, out, unit, white, c);
|
|
|
+ draw_chamber(p, out, unit, white, c);
|
|
|
+ draw_terrace(p, out, unit, white, c);
|
|
|
+ draw_trading_goods(p, out, unit, white, c);
|
|
|
+ draw_phoenician_banner(p, out, unit, white, c);
|
|
|
+ draw_rally_flag(p, out, white, c);
|
|
|
+ draw_health_bar(p, out, unit, white);
|
|
|
+ draw_selection(p, out);
|
|
|
}
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
-void registerBarracksRenderer(Render::GL::EntityRendererRegistry ®istry) {
|
|
|
- registry.registerRenderer("barracks_carthage", drawBarracks);
|
|
|
+void register_barracks_renderer(Render::GL::EntityRendererRegistry ®istry) {
|
|
|
+ registry.register_renderer("barracks_carthage", draw_barracks);
|
|
|
}
|
|
|
|
|
|
} // namespace Render::GL::Carthage
|