|
@@ -22,7 +22,6 @@ using Render::Geom::clamp01;
|
|
|
using Render::Geom::clampVec01;
|
|
using Render::Geom::clampVec01;
|
|
|
using Render::Geom::cylinderBetween;
|
|
using Render::Geom::cylinderBetween;
|
|
|
using Render::Geom::lerp;
|
|
using Render::Geom::lerp;
|
|
|
-using Render::Geom::sphereAt;
|
|
|
|
|
|
|
|
|
|
struct BuildingProportions {
|
|
struct BuildingProportions {
|
|
|
static constexpr float base_width = 2.4F;
|
|
static constexpr float base_width = 2.4F;
|
|
@@ -88,18 +87,18 @@ inline void drawCylinder(ISubmitter &out, const QMatrix4x4 &model,
|
|
|
inline void unitBox(ISubmitter &out, Mesh *unitMesh, Texture *white,
|
|
inline void unitBox(ISubmitter &out, Mesh *unitMesh, Texture *white,
|
|
|
const QMatrix4x4 &model, const QVector3D &t,
|
|
const QMatrix4x4 &model, const QVector3D &t,
|
|
|
const QVector3D &s, const QVector3D &color) {
|
|
const QVector3D &s, const QVector3D &color) {
|
|
|
- QMatrix4x4 M = model;
|
|
|
|
|
- M.translate(t);
|
|
|
|
|
- M.scale(s);
|
|
|
|
|
- out.mesh(unitMesh, M, color, white, 1.0F);
|
|
|
|
|
|
|
+ QMatrix4x4 m = model;
|
|
|
|
|
+ m.translate(t);
|
|
|
|
|
+ m.scale(s);
|
|
|
|
|
+ out.mesh(unitMesh, m, color, white, 1.0F);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
inline void unitBox(ISubmitter &out, Mesh *unitMesh, Texture *white,
|
|
inline void unitBox(ISubmitter &out, Mesh *unitMesh, Texture *white,
|
|
|
const QMatrix4x4 &model, const QVector3D &s,
|
|
const QMatrix4x4 &model, const QVector3D &s,
|
|
|
const QVector3D &color) {
|
|
const QVector3D &color) {
|
|
|
- QMatrix4x4 M = model;
|
|
|
|
|
- M.scale(s);
|
|
|
|
|
- out.mesh(unitMesh, M, color, white, 1.0F);
|
|
|
|
|
|
|
+ QMatrix4x4 m = model;
|
|
|
|
|
+ m.scale(s);
|
|
|
|
|
+ out.mesh(unitMesh, m, color, white, 1.0F);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
inline void drawFoundation(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
inline void drawFoundation(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
@@ -136,26 +135,26 @@ inline void drawFoundation(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
|
|
|
|
|
inline void drawWalls(const DrawContext &p, ISubmitter &out, Mesh *,
|
|
inline void drawWalls(const DrawContext &p, ISubmitter &out, Mesh *,
|
|
|
Texture *white, const BarracksPalette &C) {
|
|
Texture *white, const BarracksPalette &C) {
|
|
|
- constexpr float W = BuildingProportions::base_width;
|
|
|
|
|
- constexpr float D = BuildingProportions::base_depth;
|
|
|
|
|
- constexpr float H = BuildingProportions::base_height;
|
|
|
|
|
|
|
+ constexpr float w = BuildingProportions::base_width;
|
|
|
|
|
+ constexpr float d = BuildingProportions::base_depth;
|
|
|
|
|
+ constexpr float h = BuildingProportions::base_height;
|
|
|
|
|
|
|
|
const float r = 0.09F;
|
|
const float r = 0.09F;
|
|
|
const float notch = 0.07F;
|
|
const float notch = 0.07F;
|
|
|
|
|
|
|
|
- const float left_x = -W * 0.5F;
|
|
|
|
|
- const float right_x = W * 0.5F;
|
|
|
|
|
- const float back_z = -D * 0.5F;
|
|
|
|
|
- const float front_z = D * 0.5F;
|
|
|
|
|
|
|
+ const float left_x = -w * 0.5F;
|
|
|
|
|
+ const float right_x = w * 0.5F;
|
|
|
|
|
+ const float back_z = -d * 0.5F;
|
|
|
|
|
+ const float front_z = d * 0.5F;
|
|
|
|
|
|
|
|
- const int courses = std::max(4, int(H / (2.0F * r)));
|
|
|
|
|
|
|
+ const int courses = std::max(4, int(h / (2.0F * r)));
|
|
|
const float y0 = r;
|
|
const float y0 = r;
|
|
|
|
|
|
|
|
- auto logX = [&](float y, float z, float x0, float x1, const QVector3D &col) {
|
|
|
|
|
|
|
+ auto log_x = [&](float y, float z, float x0, float x1, const QVector3D &col) {
|
|
|
drawCylinder(out, p.model, QVector3D(x0 - notch, y, z),
|
|
drawCylinder(out, p.model, QVector3D(x0 - notch, y, z),
|
|
|
QVector3D(x1 + notch, y, z), r, col, white);
|
|
QVector3D(x1 + notch, y, z), r, col, white);
|
|
|
};
|
|
};
|
|
|
- auto logZ = [&](float y, float x, float z0, float z1, const QVector3D &col) {
|
|
|
|
|
|
|
+ auto log_z = [&](float y, float x, float z0, float z1, const QVector3D &col) {
|
|
|
drawCylinder(out, p.model, QVector3D(x, y, z0 - notch),
|
|
drawCylinder(out, p.model, QVector3D(x, y, z0 - notch),
|
|
|
QVector3D(x, y, z1 + notch), r, col, white);
|
|
QVector3D(x, y, z1 + notch), r, col, white);
|
|
|
};
|
|
};
|
|
@@ -169,15 +168,15 @@ inline void drawWalls(const DrawContext &p, ISubmitter &out, Mesh *,
|
|
|
QVector3D const log_col = lerp(C.timber, C.timberLight, (i % 2) * 0.25F);
|
|
QVector3D const log_col = lerp(C.timber, C.timberLight, (i % 2) * 0.25F);
|
|
|
|
|
|
|
|
if (y <= (door_h - 0.5F * r)) {
|
|
if (y <= (door_h - 0.5F * r)) {
|
|
|
- logX(y, front_z, left_x, -gap_half, log_col);
|
|
|
|
|
- logX(y, front_z, +gap_half, right_x, log_col);
|
|
|
|
|
|
|
+ log_x(y, front_z, left_x, -gap_half, log_col);
|
|
|
|
|
+ log_x(y, front_z, +gap_half, right_x, log_col);
|
|
|
} else {
|
|
} else {
|
|
|
- logX(y, front_z, left_x, right_x, log_col);
|
|
|
|
|
|
|
+ log_x(y, front_z, left_x, right_x, log_col);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- logX(y, back_z, left_x, right_x, log_col);
|
|
|
|
|
- logZ(y, left_x, back_z, front_z, log_col);
|
|
|
|
|
- logZ(y, right_x, back_z, front_z, log_col);
|
|
|
|
|
|
|
+ log_x(y, back_z, left_x, right_x, log_col);
|
|
|
|
|
+ log_z(y, left_x, back_z, front_z, log_col);
|
|
|
|
|
+ log_z(y, right_x, back_z, front_z, log_col);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
QVector3D const post_col = C.woodDark;
|
|
QVector3D const post_col = C.woodDark;
|
|
@@ -191,8 +190,8 @@ inline void drawWalls(const DrawContext &p, ISubmitter &out, Mesh *,
|
|
|
QVector3D(+gap_half, y0 + door_h, front_z), r, C.timberLight,
|
|
QVector3D(+gap_half, y0 + door_h, front_z), r, C.timberLight,
|
|
|
white);
|
|
white);
|
|
|
|
|
|
|
|
- float const brace_y0 = H * 0.35F;
|
|
|
|
|
- float const brace_y1 = H * 0.95F;
|
|
|
|
|
|
|
+ float const brace_y0 = h * 0.35F;
|
|
|
|
|
+ float const brace_y1 = h * 0.95F;
|
|
|
drawCylinder(out, p.model,
|
|
drawCylinder(out, p.model,
|
|
|
QVector3D(left_x + 0.08F, brace_y0, back_z + 0.10F),
|
|
QVector3D(left_x + 0.08F, brace_y0, back_z + 0.10F),
|
|
|
QVector3D(left_x + 0.38F, brace_y1, back_z + 0.10F), r * 0.6F,
|
|
QVector3D(left_x + 0.38F, brace_y1, back_z + 0.10F), r * 0.6F,
|
|
@@ -222,17 +221,17 @@ struct ChimneyInfo {
|
|
|
inline auto drawChimney(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
inline auto drawChimney(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
Texture *white,
|
|
Texture *white,
|
|
|
const BarracksPalette &C) -> ChimneyInfo {
|
|
const BarracksPalette &C) -> ChimneyInfo {
|
|
|
- constexpr float W = BuildingProportions::base_width;
|
|
|
|
|
- constexpr float D = BuildingProportions::base_depth;
|
|
|
|
|
- constexpr float H = BuildingProportions::base_height;
|
|
|
|
|
|
|
+ constexpr float w = BuildingProportions::base_width;
|
|
|
|
|
+ constexpr float d = BuildingProportions::base_depth;
|
|
|
|
|
+ constexpr float h = BuildingProportions::base_height;
|
|
|
constexpr float rise = BuildingProportions::roof_pitch;
|
|
constexpr float rise = BuildingProportions::roof_pitch;
|
|
|
|
|
|
|
|
- float const x = -W * 0.32F;
|
|
|
|
|
- float const z = -D * 0.5F - 0.06F;
|
|
|
|
|
|
|
+ float const x = -w * 0.32F;
|
|
|
|
|
+ float const z = -d * 0.5F - 0.06F;
|
|
|
|
|
|
|
|
float const base_y = 0.18F;
|
|
float const base_y = 0.18F;
|
|
|
- float const ridge_y = H + rise;
|
|
|
|
|
- float const topY = ridge_y + 0.35F;
|
|
|
|
|
|
|
+ float const ridge_y = h + rise;
|
|
|
|
|
+ float const top_y = ridge_y + 0.35F;
|
|
|
|
|
|
|
|
QVector3D const base_sz(BuildingProportions::chimney_width * 0.65F, 0.16F,
|
|
QVector3D const base_sz(BuildingProportions::chimney_width * 0.65F, 0.16F,
|
|
|
BuildingProportions::chimney_width * 0.55F);
|
|
BuildingProportions::chimney_width * 0.55F);
|
|
@@ -240,7 +239,7 @@ inline auto drawChimney(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
base_sz, C.stoneDark);
|
|
base_sz, C.stoneDark);
|
|
|
|
|
|
|
|
int const segments = 4;
|
|
int const segments = 4;
|
|
|
- float const segH = (topY - (base_y + base_sz.y() * 2.0F)) / float(segments);
|
|
|
|
|
|
|
+ float const seg_h = (top_y - (base_y + base_sz.y() * 2.0F)) / float(segments);
|
|
|
float const w0 = BuildingProportions::chimney_width * 0.55F;
|
|
float const w0 = BuildingProportions::chimney_width * 0.55F;
|
|
|
float const w1 = BuildingProportions::chimney_width * 0.34F;
|
|
float const w1 = BuildingProportions::chimney_width * 0.34F;
|
|
|
|
|
|
|
@@ -250,48 +249,48 @@ inline auto drawChimney(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
float const hz = wy * 0.85F;
|
|
float const hz = wy * 0.85F;
|
|
|
QVector3D const col =
|
|
QVector3D const col =
|
|
|
(i % 2 == 0) ? C.stone : lerp(C.stone, C.stoneDark, 0.35F);
|
|
(i % 2 == 0) ? C.stone : lerp(C.stone, C.stoneDark, 0.35F);
|
|
|
- float const yMid = base_y + base_sz.y() * 2.0F + segH * (i + 0.5F);
|
|
|
|
|
- unitBox(out, unit, white, p.model, QVector3D(x, yMid, z),
|
|
|
|
|
- QVector3D(wy, segH * 0.5F, hz), col);
|
|
|
|
|
|
|
+ float const y_mid = base_y + base_sz.y() * 2.0F + seg_h * (i + 0.5F);
|
|
|
|
|
+ unitBox(out, unit, white, p.model, QVector3D(x, y_mid, z),
|
|
|
|
|
+ QVector3D(wy, seg_h * 0.5F, hz), col);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- float const corbel_y = topY - 0.14F;
|
|
|
|
|
|
|
+ float const corbel_y = top_y - 0.14F;
|
|
|
unitBox(out, unit, white, p.model, QVector3D(x, corbel_y, z),
|
|
unitBox(out, unit, white, p.model, QVector3D(x, corbel_y, z),
|
|
|
QVector3D(w1 * 1.22F, 0.025F, w1 * 1.22F), C.stoneDark);
|
|
QVector3D(w1 * 1.22F, 0.025F, w1 * 1.22F), C.stoneDark);
|
|
|
unitBox(out, unit, white, p.model, QVector3D(x, corbel_y + 0.05F, z),
|
|
unitBox(out, unit, white, p.model, QVector3D(x, corbel_y + 0.05F, z),
|
|
|
QVector3D(w1 * 1.05F, 0.02F, w1 * 1.05F),
|
|
QVector3D(w1 * 1.05F, 0.02F, w1 * 1.05F),
|
|
|
lerp(C.stone, C.stoneDark, 0.2F));
|
|
lerp(C.stone, C.stoneDark, 0.2F));
|
|
|
|
|
|
|
|
- float const potH = 0.10F;
|
|
|
|
|
- unitBox(out, unit, white, p.model, QVector3D(x, topY + potH * 0.5F, z),
|
|
|
|
|
- QVector3D(w1 * 0.45F, potH * 0.5F, w1 * 0.45F),
|
|
|
|
|
|
|
+ float const pot_h = 0.10F;
|
|
|
|
|
+ unitBox(out, unit, white, p.model, QVector3D(x, top_y + pot_h * 0.5F, z),
|
|
|
|
|
+ QVector3D(w1 * 0.45F, pot_h * 0.5F, w1 * 0.45F),
|
|
|
lerp(C.stoneDark, QVector3D(0.08F, 0.08F, 0.08F), 0.35F));
|
|
lerp(C.stoneDark, QVector3D(0.08F, 0.08F, 0.08F), 0.35F));
|
|
|
|
|
|
|
|
- unitBox(out, unit, white, p.model, QVector3D(x, H + rise * 0.55F, z + 0.06F),
|
|
|
|
|
|
|
+ unitBox(out, unit, white, p.model, QVector3D(x, h + rise * 0.55F, z + 0.06F),
|
|
|
QVector3D(w1 * 1.35F, 0.01F, 0.04F),
|
|
QVector3D(w1 * 1.35F, 0.01F, 0.04F),
|
|
|
lerp(C.stoneDark, QVector3D(0.05F, 0.05F, 0.05F), 0.3F));
|
|
lerp(C.stoneDark, QVector3D(0.05F, 0.05F, 0.05F), 0.3F));
|
|
|
|
|
|
|
|
- return ChimneyInfo{x, z, base_y, topY + potH, 0.28F};
|
|
|
|
|
|
|
+ return ChimneyInfo{x, z, base_y, top_y + pot_h, 0.28F};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
inline void drawRoofs(const DrawContext &p, ISubmitter &out, Mesh *,
|
|
inline void drawRoofs(const DrawContext &p, ISubmitter &out, Mesh *,
|
|
|
Texture *white, const BarracksPalette &C,
|
|
Texture *white, const BarracksPalette &C,
|
|
|
const ChimneyInfo &ch) {
|
|
const ChimneyInfo &ch) {
|
|
|
- constexpr float W = BuildingProportions::base_width;
|
|
|
|
|
- constexpr float D = BuildingProportions::base_depth;
|
|
|
|
|
- constexpr float H = BuildingProportions::base_height;
|
|
|
|
|
|
|
+ constexpr float w = BuildingProportions::base_width;
|
|
|
|
|
+ constexpr float d = BuildingProportions::base_depth;
|
|
|
|
|
+ constexpr float h = BuildingProportions::base_height;
|
|
|
constexpr float rise = BuildingProportions::roof_pitch;
|
|
constexpr float rise = BuildingProportions::roof_pitch;
|
|
|
constexpr float over = BuildingProportions::roof_overhang;
|
|
constexpr float over = BuildingProportions::roof_overhang;
|
|
|
|
|
|
|
|
const float r = 0.085F;
|
|
const float r = 0.085F;
|
|
|
|
|
|
|
|
- const float left_x = -W * 0.5F;
|
|
|
|
|
- const float right_x = W * 0.5F;
|
|
|
|
|
- const float back_z = -D * 0.5F;
|
|
|
|
|
- const float front_z = D * 0.5F;
|
|
|
|
|
|
|
+ const float left_x = -w * 0.5F;
|
|
|
|
|
+ const float right_x = w * 0.5F;
|
|
|
|
|
+ const float back_z = -d * 0.5F;
|
|
|
|
|
+ const float front_z = d * 0.5F;
|
|
|
|
|
|
|
|
- const float plate_y = H;
|
|
|
|
|
- const float ridge_y = H + rise;
|
|
|
|
|
|
|
+ const float plate_y = h;
|
|
|
|
|
+ const float ridge_y = h + rise;
|
|
|
|
|
|
|
|
drawCylinder(out, p.model, QVector3D(left_x - over, plate_y, front_z + over),
|
|
drawCylinder(out, p.model, QVector3D(left_x - over, plate_y, front_z + over),
|
|
|
QVector3D(right_x + over, plate_y, front_z + over), r,
|
|
QVector3D(right_x + over, plate_y, front_z + over), r,
|
|
@@ -331,11 +330,11 @@ inline void drawRoofs(const DrawContext &p, ISubmitter &out, Mesh *,
|
|
|
purlin(0.70F, false);
|
|
purlin(0.70F, false);
|
|
|
|
|
|
|
|
auto split_thatch = [&](float y, float z, float rad, const QVector3D &col) {
|
|
auto split_thatch = [&](float y, float z, float rad, const QVector3D &col) {
|
|
|
- float const gapL = ch.x - ch.gapRadius;
|
|
|
|
|
- float const gapR = ch.x + ch.gapRadius;
|
|
|
|
|
|
|
+ float const gap_l = ch.x - ch.gapRadius;
|
|
|
|
|
+ float const gap_r = ch.x + ch.gapRadius;
|
|
|
drawCylinder(out, p.model, QVector3D(left_x - over * 0.35F, y, z),
|
|
drawCylinder(out, p.model, QVector3D(left_x - over * 0.35F, y, z),
|
|
|
- QVector3D(gapL, y, z), rad, col, white);
|
|
|
|
|
- drawCylinder(out, p.model, QVector3D(gapR, y, z),
|
|
|
|
|
|
|
+ QVector3D(gap_l, y, z), rad, col, white);
|
|
|
|
|
+ drawCylinder(out, p.model, QVector3D(gap_r, y, z),
|
|
|
QVector3D(right_x + over * 0.35F, y, z), rad, col, white);
|
|
QVector3D(right_x + over * 0.35F, y, z), rad, col, white);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -369,123 +368,129 @@ inline void drawRoofs(const DrawContext &p, ISubmitter &out, Mesh *,
|
|
|
|
|
|
|
|
inline void drawDoor(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
inline void drawDoor(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
Texture *white, const BarracksPalette &C) {
|
|
Texture *white, const BarracksPalette &C) {
|
|
|
- constexpr float D = BuildingProportions::base_depth;
|
|
|
|
|
- constexpr float dW = BuildingProportions::door_width;
|
|
|
|
|
- constexpr float dH = BuildingProportions::door_height;
|
|
|
|
|
|
|
+ constexpr float d = BuildingProportions::base_depth;
|
|
|
|
|
+ constexpr float d_w = BuildingProportions::door_width;
|
|
|
|
|
+ constexpr float d_h = BuildingProportions::door_height;
|
|
|
|
|
|
|
|
const float y0 = 0.09F;
|
|
const float y0 = 0.09F;
|
|
|
- const float zf = D * 0.5F;
|
|
|
|
|
|
|
+ const float zf = d * 0.5F;
|
|
|
|
|
|
|
|
QVector3D const frame_col = C.woodDark;
|
|
QVector3D const frame_col = C.woodDark;
|
|
|
unitBox(out, unit, white, p.model,
|
|
unitBox(out, unit, white, p.model,
|
|
|
- QVector3D(0.0F, y0 + dH * 0.5F, zf + 0.015F),
|
|
|
|
|
- QVector3D(dW * 0.5F, dH * 0.5F, 0.02F), C.door);
|
|
|
|
|
|
|
+ QVector3D(0.0F, y0 + d_h * 0.5F, zf + 0.015F),
|
|
|
|
|
+ QVector3D(d_w * 0.5F, d_h * 0.5F, 0.02F), C.door);
|
|
|
|
|
|
|
|
- float const plank_w = dW / 6.0F;
|
|
|
|
|
|
|
+ float const plank_w = d_w / 6.0F;
|
|
|
for (int i = 0; i < 6; ++i) {
|
|
for (int i = 0; i < 6; ++i) {
|
|
|
- float const cx = -dW * 0.5F + plank_w * (i + 0.5F);
|
|
|
|
|
|
|
+ float const cx = -d_w * 0.5F + plank_w * (i + 0.5F);
|
|
|
QVector3D const plank_col = lerp(C.door, C.woodDark, 0.15F * (i % 2));
|
|
QVector3D const plank_col = lerp(C.door, C.woodDark, 0.15F * (i % 2));
|
|
|
unitBox(out, unit, white, p.model,
|
|
unitBox(out, unit, white, p.model,
|
|
|
- QVector3D(cx, y0 + dH * 0.5F, zf + 0.022F),
|
|
|
|
|
- QVector3D(plank_w * 0.48F, dH * 0.48F, 0.006F), plank_col);
|
|
|
|
|
|
|
+ QVector3D(cx, y0 + d_h * 0.5F, zf + 0.022F),
|
|
|
|
|
+ QVector3D(plank_w * 0.48F, d_h * 0.48F, 0.006F), plank_col);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
drawCylinder(out, p.model,
|
|
drawCylinder(out, p.model,
|
|
|
- QVector3D(-dW * 0.45F, y0 + dH * 0.35F, zf + 0.03F),
|
|
|
|
|
- QVector3D(+dW * 0.45F, y0 + dH * 0.35F, zf + 0.03F), 0.02F,
|
|
|
|
|
|
|
+ QVector3D(-d_w * 0.45F, y0 + d_h * 0.35F, zf + 0.03F),
|
|
|
|
|
+ QVector3D(+d_w * 0.45F, y0 + d_h * 0.35F, zf + 0.03F), 0.02F,
|
|
|
frame_col, white);
|
|
frame_col, white);
|
|
|
|
|
|
|
|
- drawCylinder(out, p.model, QVector3D(dW * 0.32F, y0 + dH * 0.45F, zf + 0.04F),
|
|
|
|
|
- QVector3D(dW * 0.42F, y0 + dH * 0.45F, zf + 0.04F), 0.012F,
|
|
|
|
|
|
|
+ drawCylinder(out, p.model,
|
|
|
|
|
+ QVector3D(d_w * 0.32F, y0 + d_h * 0.45F, zf + 0.04F),
|
|
|
|
|
+ QVector3D(d_w * 0.42F, y0 + d_h * 0.45F, zf + 0.04F), 0.012F,
|
|
|
C.timberLight, white);
|
|
C.timberLight, white);
|
|
|
|
|
|
|
|
unitBox(out, unit, white, p.model,
|
|
unitBox(out, unit, white, p.model,
|
|
|
- QVector3D(0.0F, y0 + dH + 0.10F, zf + 0.02F),
|
|
|
|
|
|
|
+ QVector3D(0.0F, y0 + d_h + 0.10F, zf + 0.02F),
|
|
|
QVector3D(0.22F, 0.06F, 0.01F), C.woodDark);
|
|
QVector3D(0.22F, 0.06F, 0.01F), C.woodDark);
|
|
|
unitBox(out, unit, white, p.model,
|
|
unitBox(out, unit, white, p.model,
|
|
|
- QVector3D(0.0F, y0 + dH + 0.10F, zf + 0.025F),
|
|
|
|
|
|
|
+ QVector3D(0.0F, y0 + d_h + 0.10F, zf + 0.025F),
|
|
|
QVector3D(0.18F, 0.05F, 0.008F), C.team);
|
|
QVector3D(0.18F, 0.05F, 0.008F), C.team);
|
|
|
unitBox(out, unit, white, p.model,
|
|
unitBox(out, unit, white, p.model,
|
|
|
- QVector3D(0.0F, y0 + dH + 0.10F, zf + 0.03F),
|
|
|
|
|
|
|
+ QVector3D(0.0F, y0 + d_h + 0.10F, zf + 0.03F),
|
|
|
QVector3D(0.08F, 0.02F, 0.007F), C.teamTrim);
|
|
QVector3D(0.08F, 0.02F, 0.007F), C.teamTrim);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
inline void drawWindows(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
inline void drawWindows(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
Texture *white, const BarracksPalette &C) {
|
|
Texture *white, const BarracksPalette &C) {
|
|
|
- constexpr float W = BuildingProportions::base_width;
|
|
|
|
|
- constexpr float D = BuildingProportions::base_depth;
|
|
|
|
|
- constexpr float H = BuildingProportions::base_height;
|
|
|
|
|
|
|
+ constexpr float base_w = BuildingProportions::base_width;
|
|
|
|
|
+ constexpr float base_d = BuildingProportions::base_depth;
|
|
|
|
|
+ constexpr float base_h = BuildingProportions::base_height;
|
|
|
|
|
|
|
|
- const float left_x = -W * 0.5F;
|
|
|
|
|
- const float right_x = W * 0.5F;
|
|
|
|
|
- const float back_z = -D * 0.5F;
|
|
|
|
|
- const float front_z = D * 0.5F;
|
|
|
|
|
|
|
+ const float left_x = -base_w * 0.5F;
|
|
|
|
|
+ const float right_x = base_w * 0.5F;
|
|
|
|
|
+ const float back_z = -base_d * 0.5F;
|
|
|
|
|
+ const float front_z = base_d * 0.5F;
|
|
|
|
|
|
|
|
- float w = BuildingProportions::window_width * 0.55F;
|
|
|
|
|
- float h = BuildingProportions::window_height * 0.55F;
|
|
|
|
|
- float frame_t = 0.03F;
|
|
|
|
|
|
|
+ float const window_w = BuildingProportions::window_width * 0.55F;
|
|
|
|
|
+ float const window_h = BuildingProportions::window_height * 0.55F;
|
|
|
|
|
+ float const frame_t = 0.03F;
|
|
|
|
|
|
|
|
auto framed_window = [&](QVector3D center, bool shutters) {
|
|
auto framed_window = [&](QVector3D center, bool shutters) {
|
|
|
unitBox(out, unit, white, p.model, center + QVector3D(0, 0, 0.012F),
|
|
unitBox(out, unit, white, p.model, center + QVector3D(0, 0, 0.012F),
|
|
|
- QVector3D(w * 0.5F, h * 0.5F, 0.008F), C.window);
|
|
|
|
|
- unitBox(out, unit, white, p.model, center + QVector3D(0, 0, 0.016F),
|
|
|
|
|
- QVector3D(w * 0.5F, frame_t, 0.006F), C.timber);
|
|
|
|
|
- unitBox(out, unit, white, p.model, center + QVector3D(0, 0, 0.016F),
|
|
|
|
|
- QVector3D(frame_t, h * 0.5F, 0.006F), C.timber);
|
|
|
|
|
|
|
+ QVector3D(window_w * 0.5F, window_h * 0.5F, 0.008F), C.window);
|
|
|
|
|
+
|
|
|
unitBox(out, unit, white, p.model, center + QVector3D(0, 0, 0.016F),
|
|
unitBox(out, unit, white, p.model, center + QVector3D(0, 0, 0.016F),
|
|
|
- QVector3D(w * 0.5F, frame_t, 0.006F), C.timber);
|
|
|
|
|
|
|
+ QVector3D(window_w * 0.5F, frame_t, 0.006F), C.timber);
|
|
|
unitBox(out, unit, white, p.model, center + QVector3D(0, 0, 0.016F),
|
|
unitBox(out, unit, white, p.model, center + QVector3D(0, 0, 0.016F),
|
|
|
- QVector3D(frame_t, h * 0.5F, 0.006F), C.timber);
|
|
|
|
|
|
|
+ QVector3D(frame_t, window_h * 0.5F, 0.006F), C.timber);
|
|
|
|
|
|
|
|
unitBox(out, unit, white, p.model, center + QVector3D(0, 0, 0.02F),
|
|
unitBox(out, unit, white, p.model, center + QVector3D(0, 0, 0.02F),
|
|
|
- QVector3D(w * 0.02F, h * 0.48F, 0.004F), C.timberLight);
|
|
|
|
|
|
|
+ QVector3D(window_w * 0.02F, window_h * 0.48F, 0.004F),
|
|
|
|
|
+ C.timberLight);
|
|
|
unitBox(out, unit, white, p.model, center + QVector3D(0, 0, 0.02F),
|
|
unitBox(out, unit, white, p.model, center + QVector3D(0, 0, 0.02F),
|
|
|
- QVector3D(w * 0.48F, h * 0.02F, 0.004F), C.timberLight);
|
|
|
|
|
|
|
+ QVector3D(window_w * 0.48F, window_h * 0.02F, 0.004F),
|
|
|
|
|
+ C.timberLight);
|
|
|
|
|
|
|
|
if (shutters) {
|
|
if (shutters) {
|
|
|
unitBox(out, unit, white, p.model,
|
|
unitBox(out, unit, white, p.model,
|
|
|
- center + QVector3D(-w * 0.65F, 0, 0.018F),
|
|
|
|
|
- QVector3D(w * 0.30F, h * 0.55F, 0.004F), C.woodDark);
|
|
|
|
|
|
|
+ center + QVector3D(-window_w * 0.65F, 0, 0.018F),
|
|
|
|
|
+ QVector3D(window_w * 0.30F, window_h * 0.55F, 0.004F),
|
|
|
|
|
+ C.woodDark);
|
|
|
unitBox(out, unit, white, p.model,
|
|
unitBox(out, unit, white, p.model,
|
|
|
- center + QVector3D(+w * 0.65F, 0, 0.018F),
|
|
|
|
|
- QVector3D(w * 0.30F, h * 0.55F, 0.004F), C.woodDark);
|
|
|
|
|
|
|
+ center + QVector3D(+window_w * 0.65F, 0, 0.018F),
|
|
|
|
|
+ QVector3D(window_w * 0.30F, window_h * 0.55F, 0.004F),
|
|
|
|
|
+ C.woodDark);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
framed_window(QVector3D(-0.65F, 0.95F, front_z + 0.01F), true);
|
|
framed_window(QVector3D(-0.65F, 0.95F, front_z + 0.01F), true);
|
|
|
framed_window(QVector3D(+0.65F, 0.95F, front_z + 0.01F), true);
|
|
framed_window(QVector3D(+0.65F, 0.95F, front_z + 0.01F), true);
|
|
|
|
|
+ framed_window(QVector3D(0.0F, 1.00F, back_z - 0.01F), true);
|
|
|
|
|
+
|
|
|
framed_window(QVector3D(left_x + 0.06F, 0.85F, 0.0F), false);
|
|
framed_window(QVector3D(left_x + 0.06F, 0.85F, 0.0F), false);
|
|
|
framed_window(QVector3D(right_x - 0.06F, 0.85F, 0.0F), false);
|
|
framed_window(QVector3D(right_x - 0.06F, 0.85F, 0.0F), false);
|
|
|
- framed_window(QVector3D(0.0F, 1.00F, back_z - 0.01F), true);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
inline void drawAnnex(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
inline void drawAnnex(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
Texture *white, const BarracksPalette &C) {
|
|
Texture *white, const BarracksPalette &C) {
|
|
|
- constexpr float W = BuildingProportions::base_width;
|
|
|
|
|
- constexpr float D = BuildingProportions::base_depth;
|
|
|
|
|
- constexpr float h = BuildingProportions::annex_height;
|
|
|
|
|
- constexpr float w = BuildingProportions::annex_width;
|
|
|
|
|
- constexpr float d = BuildingProportions::annex_depth;
|
|
|
|
|
|
|
+ constexpr float base_w = BuildingProportions::base_width;
|
|
|
|
|
+ constexpr float base_d = BuildingProportions::base_depth;
|
|
|
|
|
+ constexpr float annex_h = BuildingProportions::annex_height;
|
|
|
|
|
+ constexpr float annex_w = BuildingProportions::annex_width;
|
|
|
|
|
+ constexpr float annex_d = BuildingProportions::annex_depth;
|
|
|
|
|
|
|
|
- float const x = W * 0.5F + w * 0.5F - 0.05F;
|
|
|
|
|
|
|
+ float const x = base_w * 0.5F + annex_w * 0.5F - 0.05F;
|
|
|
float const z = 0.05F;
|
|
float const z = 0.05F;
|
|
|
|
|
|
|
|
- unitBox(out, unit, white, p.model, QVector3D(x, h * 0.5F, z),
|
|
|
|
|
- QVector3D(w * 0.5F, h * 0.5F, d * 0.5F), C.plasterShade);
|
|
|
|
|
|
|
+ unitBox(out, unit, white, p.model, QVector3D(x, annex_h * 0.5F, z),
|
|
|
|
|
+ QVector3D(annex_w * 0.5F, annex_h * 0.5F, annex_d * 0.5F),
|
|
|
|
|
+ C.plasterShade);
|
|
|
|
|
|
|
|
- unitBox(out, unit, white, p.model, QVector3D(x, h + 0.02F, z),
|
|
|
|
|
- QVector3D(w * 0.55F, 0.02F, d * 0.55F), C.woodDark);
|
|
|
|
|
|
|
+ unitBox(out, unit, white, p.model, QVector3D(x, annex_h + 0.02F, z),
|
|
|
|
|
+ QVector3D(annex_w * 0.55F, 0.02F, annex_d * 0.55F), C.woodDark);
|
|
|
|
|
|
|
|
- float const plate_y = h;
|
|
|
|
|
- float const front_z = z + d * 0.5F;
|
|
|
|
|
- float const back_z = z - d * 0.5F;
|
|
|
|
|
- drawCylinder(out, p.model, QVector3D(x - w * 0.52F, plate_y, back_z - 0.12F),
|
|
|
|
|
- QVector3D(x + w * 0.52F, plate_y, back_z - 0.12F), 0.05F,
|
|
|
|
|
|
|
+ float const plate_y = annex_h;
|
|
|
|
|
+ float const front_z = z + annex_d * 0.5F;
|
|
|
|
|
+ float const back_z = z - annex_d * 0.5F;
|
|
|
|
|
+ drawCylinder(out, p.model,
|
|
|
|
|
+ QVector3D(x - annex_w * 0.52F, plate_y, back_z - 0.12F),
|
|
|
|
|
+ QVector3D(x + annex_w * 0.52F, plate_y, back_z - 0.12F), 0.05F,
|
|
|
C.woodDark, white);
|
|
C.woodDark, white);
|
|
|
|
|
|
|
|
- float const ridge_y = h + BuildingProportions::annex_roof_height;
|
|
|
|
|
- drawCylinder(out, p.model, QVector3D(x - w * 0.50F, ridge_y, back_z - 0.02F),
|
|
|
|
|
- QVector3D(x + w * 0.50F, ridge_y, back_z - 0.02F), 0.05F,
|
|
|
|
|
|
|
+ float const ridge_y = annex_h + BuildingProportions::annex_roof_height;
|
|
|
|
|
+ drawCylinder(out, p.model,
|
|
|
|
|
+ QVector3D(x - annex_w * 0.50F, ridge_y, back_z - 0.02F),
|
|
|
|
|
+ QVector3D(x + annex_w * 0.50F, ridge_y, back_z - 0.02F), 0.05F,
|
|
|
C.timberLight, white);
|
|
C.timberLight, white);
|
|
|
|
|
|
|
|
int const rows = 6;
|
|
int const rows = 6;
|
|
@@ -495,13 +500,13 @@ inline void drawAnnex(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
float const zrow = back_z - 0.02F - 0.10F * (1.0F - t);
|
|
float const zrow = back_z - 0.02F - 0.10F * (1.0F - t);
|
|
|
QVector3D const col =
|
|
QVector3D const col =
|
|
|
lerp(C.thatchDark, C.thatch, 0.5F + 0.4F * (1.0F - t));
|
|
lerp(C.thatchDark, C.thatch, 0.5F + 0.4F * (1.0F - t));
|
|
|
- drawCylinder(out, p.model, QVector3D(x - w * 0.55F, y, zrow),
|
|
|
|
|
- QVector3D(x + w * 0.55F, y, zrow), 0.06F * (1.15F - 0.6F * t),
|
|
|
|
|
- col, white);
|
|
|
|
|
|
|
+ drawCylinder(out, p.model, QVector3D(x - annex_w * 0.55F, y, zrow),
|
|
|
|
|
+ QVector3D(x + annex_w * 0.55F, y, zrow),
|
|
|
|
|
+ 0.06F * (1.15F - 0.6F * t), col, white);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
unitBox(out, unit, white, p.model,
|
|
unitBox(out, unit, white, p.model,
|
|
|
- QVector3D(x + w * 0.01F, 0.55F, front_z + 0.01F),
|
|
|
|
|
|
|
+ QVector3D(x + annex_w * 0.01F, 0.55F, front_z + 0.01F),
|
|
|
QVector3D(0.20F, 0.18F, 0.01F), C.door);
|
|
QVector3D(0.20F, 0.18F, 0.01F), C.door);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -632,14 +637,14 @@ inline void drawHealthBar(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
constexpr float base_height = BuildingProportions::base_height;
|
|
constexpr float base_height = BuildingProportions::base_height;
|
|
|
constexpr float roof_pitch = BuildingProportions::roof_pitch;
|
|
constexpr float roof_pitch = BuildingProportions::roof_pitch;
|
|
|
float const roof_peak = base_height + roof_pitch;
|
|
float const roof_peak = base_height + roof_pitch;
|
|
|
- float const barY = roof_peak + 0.12F;
|
|
|
|
|
|
|
+ float const bar_y = roof_peak + 0.12F;
|
|
|
|
|
|
|
|
constexpr float bar_width = BuildingProportions::base_width * 0.9F;
|
|
constexpr float bar_width = BuildingProportions::base_width * 0.9F;
|
|
|
constexpr float bar_height = 0.08F;
|
|
constexpr float bar_height = 0.08F;
|
|
|
constexpr float bar_depth = 0.12F;
|
|
constexpr float bar_depth = 0.12F;
|
|
|
|
|
|
|
|
QVector3D const bg_color(0.06F, 0.06F, 0.06F);
|
|
QVector3D const bg_color(0.06F, 0.06F, 0.06F);
|
|
|
- unitBox(out, unit, white, p.model, QVector3D(0.0F, barY, 0.0F),
|
|
|
|
|
|
|
+ unitBox(out, unit, white, p.model, QVector3D(0.0F, bar_y, 0.0F),
|
|
|
QVector3D(bar_width / 2.0F, bar_height / 2.0F, bar_depth / 2.0F),
|
|
QVector3D(bar_width / 2.0F, bar_height / 2.0F, bar_depth / 2.0F),
|
|
|
bg_color);
|
|
bg_color);
|
|
|
|
|
|
|
@@ -650,21 +655,21 @@ inline void drawHealthBar(const DrawContext &p, ISubmitter &out, Mesh *unit,
|
|
|
QVector3D const green(0.22F, 0.78F, 0.22F);
|
|
QVector3D const green(0.22F, 0.78F, 0.22F);
|
|
|
QVector3D const fg_color = green * ratio + red * (1.0F - ratio);
|
|
QVector3D const fg_color = green * ratio + red * (1.0F - ratio);
|
|
|
|
|
|
|
|
- unitBox(out, unit, white, p.model, QVector3D(fill_x, barY + 0.005F, 0.0F),
|
|
|
|
|
|
|
+ unitBox(out, unit, white, p.model, QVector3D(fill_x, bar_y + 0.005F, 0.0F),
|
|
|
QVector3D(fill_width / 2.0F, (bar_height / 2.0F) * 0.9F,
|
|
QVector3D(fill_width / 2.0F, (bar_height / 2.0F) * 0.9F,
|
|
|
(bar_depth / 2.0F) * 0.95F),
|
|
(bar_depth / 2.0F) * 0.95F),
|
|
|
fg_color);
|
|
fg_color);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
inline void drawSelectionFX(const DrawContext &p, ISubmitter &out) {
|
|
inline void drawSelectionFX(const DrawContext &p, ISubmitter &out) {
|
|
|
- QMatrix4x4 M;
|
|
|
|
|
|
|
+ QMatrix4x4 m;
|
|
|
QVector3D const pos = p.model.column(3).toVector3D();
|
|
QVector3D const pos = p.model.column(3).toVector3D();
|
|
|
- M.translate(pos.x(), 0.0F, pos.z());
|
|
|
|
|
- M.scale(2.2F, 1.0F, 2.0F);
|
|
|
|
|
|
|
+ m.translate(pos.x(), 0.0F, pos.z());
|
|
|
|
|
+ m.scale(2.2F, 1.0F, 2.0F);
|
|
|
if (p.selected) {
|
|
if (p.selected) {
|
|
|
- out.selectionSmoke(M, QVector3D(0.2F, 0.85F, 0.2F), 0.35F);
|
|
|
|
|
|
|
+ out.selectionSmoke(m, QVector3D(0.2F, 0.85F, 0.2F), 0.35F);
|
|
|
} else if (p.hovered) {
|
|
} else if (p.hovered) {
|
|
|
- out.selectionSmoke(M, QVector3D(0.95F, 0.92F, 0.25F), 0.22F);
|
|
|
|
|
|
|
+ out.selectionSmoke(m, QVector3D(0.95F, 0.92F, 0.25F), 0.22F);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -683,19 +688,19 @@ void drawBarracks(const DrawContext &p, ISubmitter &out) {
|
|
|
Texture *white = p.resources->white();
|
|
Texture *white = p.resources->white();
|
|
|
|
|
|
|
|
QVector3D const team(r->color[0], r->color[1], r->color[2]);
|
|
QVector3D const team(r->color[0], r->color[1], r->color[2]);
|
|
|
- BarracksPalette const C = makePalette(team);
|
|
|
|
|
-
|
|
|
|
|
- drawFoundation(p, out, unit, white, C);
|
|
|
|
|
- drawAnnex(p, out, unit, white, C);
|
|
|
|
|
- drawWalls(p, out, unit, white, C);
|
|
|
|
|
- ChimneyInfo const ch = drawChimney(p, out, unit, white, C);
|
|
|
|
|
- drawRoofs(p, out, unit, white, C, ch);
|
|
|
|
|
- drawDoor(p, out, unit, white, C);
|
|
|
|
|
- drawWindows(p, out, unit, white, C);
|
|
|
|
|
- drawBannerAndPole(p, out, unit, white, C);
|
|
|
|
|
- drawProps(p, out, unit, white, C);
|
|
|
|
|
-
|
|
|
|
|
- drawRallyFlagIfAny(p, out, white, C);
|
|
|
|
|
|
|
+ BarracksPalette const c = makePalette(team);
|
|
|
|
|
+
|
|
|
|
|
+ drawFoundation(p, out, unit, white, c);
|
|
|
|
|
+ drawAnnex(p, out, unit, white, c);
|
|
|
|
|
+ drawWalls(p, out, unit, white, c);
|
|
|
|
|
+ ChimneyInfo const ch = drawChimney(p, out, unit, white, c);
|
|
|
|
|
+ drawRoofs(p, out, unit, white, c, ch);
|
|
|
|
|
+ drawDoor(p, out, unit, white, c);
|
|
|
|
|
+ drawWindows(p, out, unit, white, c);
|
|
|
|
|
+ drawBannerAndPole(p, out, unit, white, c);
|
|
|
|
|
+ drawProps(p, out, unit, white, c);
|
|
|
|
|
+
|
|
|
|
|
+ drawRallyFlagIfAny(p, out, white, c);
|
|
|
drawHealthBar(p, out, unit, white);
|
|
drawHealthBar(p, out, unit, white);
|
|
|
drawSelectionFX(p, out);
|
|
drawSelectionFX(p, out);
|
|
|
}
|
|
}
|