Player12
An open source football management simulator
Loading...
Searching...
No Matches
match_stadium_3d.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2// Football Management Project
3// Copyright (c) 2025 - 2026 Flavio Milinanni. All Rights Reserved.
4//
5// This file is part of the Football Management Project.
6// See the LICENSE file in the project root.
7// -----------------------------------------------------------------------------
8
9#pragma once
10
11#include <imgui.h>
12
13#include <array>
14#include <cstddef>
15#include <cstdint>
16#include <vector>
17
20
30namespace Stadium3D
31{
33
40{
41 std::array<Vec3, 10> points{};
42 std::array<ImU32, 10> colors{};
43 std::uint8_t count = 0;
44};
45
54{
55 int stripes = 0;
57 int rows = 0;
58 std::vector<Vec3> points;
59 std::vector<ImU32> colors;
60
61 int columnVertices() const { return columnsPerStripe + 1; }
62 std::size_t index(int stripe, int column, int row) const
63 {
64 return static_cast<std::size_t>(
65 (stripe * columnVertices() + column) * (rows + 1) + row);
66 }
67};
68
70struct Face
71{
72 std::array<Vec3, 4> corners{};
73 std::array<ImU32, 4> colors{};
76 std::uint32_t clumpBegin = 0;
77 std::uint32_t clumpEnd = 0;
79 std::uint32_t flagBegin = 0;
80 std::uint32_t flagEnd = 0;
82 ImU32 glow = 0;
83};
84
86inline constexpr std::size_t CROWD_PHASES = 16;
87
89namespace CrowdFlags
90{
91inline constexpr std::byte HOME_FAN = std::byte{1} << 0U;
92inline constexpr std::byte AWAY_FAN = std::byte{1} << 1U;
94inline constexpr std::byte CHEERS_HOME = std::byte{1} << 2U;
95inline constexpr std::byte CHEERS_AWAY = std::byte{1} << 3U;
97inline constexpr std::byte SCARF = std::byte{1} << 4U;
98} // namespace CrowdFlags
99
102{
104 ImU32 body = 0;
105 ImU32 head = 0;
106 std::byte flags{};
108 std::uint8_t phase = 0;
109};
110
113{
116 ImU32 primary = 0;
117 ImU32 secondary = 0;
118 std::byte flags{};
119 std::uint8_t phase = 0;
120};
121
130{
133 float halfWidth = 0.0f;
135 ImU32 color = 0;
136 std::uint32_t dotBegin = 0;
137 std::uint32_t dotEnd = 0;
139 std::byte flags{};
140 std::uint8_t phase = 0;
141};
142
144enum class Side : std::uint8_t
145{
146 SOUTH,
147 NORTH,
148 WEST,
149 EAST,
150 NONE,
151};
152
155{
156 std::uint32_t faceBegin = 0;
157 std::uint32_t faceEnd = 0;
160};
161
164{
168 std::uint8_t sponsor = 0;
169};
170
172struct Box
173{
174 std::array<Vec3, 8> corners{};
175 ImU32 color = 0;
176};
177
180{
181 std::array<Vec3, 4> corners{};
182 std::uint8_t rows = 1;
183 std::uint8_t columns = 1;
184};
185
186struct Goal
187{
188 std::array<Box, 3> frame{};
189 std::array<NetPanel, 4> nets{};
190 std::array<std::array<Vec3, 2>, 2> supports{};
191};
192
194{
195 const char* text = "";
196 ImU32 background = 0;
197 ImU32 foreground = 0;
198};
199
201inline constexpr std::array<SponsorStyle, 8> SPONSORS{{
202 {"KESTRELINE", IM_COL32(18, 70, 150, 255), IM_COL32(255, 255, 255, 255)},
203 {"VOLTRIX", IM_COL32(236, 196, 30, 255), IM_COL32(20, 20, 24, 255)},
204 {"ORBANO TELECOM", IM_COL32(200, 30, 48, 255),
205 IM_COL32(255, 255, 255, 255)},
206 {"PINEFORGE", IM_COL32(16, 110, 70, 255), IM_COL32(240, 250, 240, 255)},
207 {"AQUALYNE", IM_COL32(20, 170, 200, 255), IM_COL32(10, 30, 60, 255)},
208 {"SOLENTA", IM_COL32(245, 245, 245, 255), IM_COL32(220, 70, 20, 255)},
209 {"BRIGHTWELL", IM_COL32(30, 30, 36, 255), IM_COL32(250, 210, 60, 255)},
210 {"TORVANA", IM_COL32(120, 40, 150, 255), IM_COL32(255, 255, 255, 255)},
211}};
212
214inline constexpr std::array<std::array<std::uint8_t, 4>, 6> BOX_FACES{{
215 {0, 4, 6, 2},
216 {1, 3, 7, 5},
217 {0, 1, 5, 4},
218 {2, 6, 7, 3},
219 {0, 2, 3, 1},
220 {4, 5, 7, 6},
221}};
222
224Box makeAxisBox(Vec3 minimum, Vec3 maximum, ImU32 color);
225
227{
228 std::vector<GroundPolygon> ground;
231 std::vector<GroundPolygon> wear;
232 std::vector<GroundPolygon> markings;
233 std::vector<Face> faces;
234 std::vector<Section> sections;
235 std::vector<CrowdDot> crowd;
236 std::vector<CrowdClump> clumps;
237 std::vector<CrowdFlag> flags;
238 std::vector<AdBoard> boards;
239 std::array<Goal, 2> goals{};
240 std::array<Vec3, 4> cornerFlags{};
242 bool day = false;
245 std::vector<GroundPolygon> standShadows;
246 std::vector<std::array<Vec3, 4>> shadowAreas;
247
253 void build(const MatchKits& kits, bool daylightView = false);
256 bool inStandShadow(Vec3 point) const;
257};
258} // namespace Stadium3D
const MatchKits & kits
Definition match_stadium_3d.cpp:446
constexpr std::byte CHEERS_AWAY
Definition match_stadium_3d.h:95
constexpr std::byte HOME_FAN
Definition match_stadium_3d.h:91
constexpr std::byte SCARF
Definition match_stadium_3d.h:97
constexpr std::byte CHEERS_HOME
Definition match_stadium_3d.h:94
constexpr std::byte AWAY_FAN
Definition match_stadium_3d.h:92
Definition match_stadium_3d.cpp:19
Box makeAxisBox(Vec3 minimum, Vec3 maximum, ImU32 color)
Definition match_stadium_3d.cpp:1061
constexpr std::array< SponsorStyle, 8 > SPONSORS
Definition match_stadium_3d.h:201
constexpr std::array< std::array< std::uint8_t, 4 >, 6 > BOX_FACES
Definition match_stadium_3d.h:214
Side
Definition match_stadium_3d.h:145
constexpr std::size_t CROWD_PHASES
Definition match_stadium_3d.h:86
std::int64_t minimum
Definition runtime_editor_validation.cpp:46
std::string_view column
Definition runtime_editor_validation.cpp:45
std::int64_t maximum
Definition runtime_editor_validation.cpp:47
Definition match_kit_colors.h:31
Definition match_render_math.h:32
Definition match_stadium_3d.h:164
std::uint8_t sponsor
Definition match_stadium_3d.h:168
Vec3 right
Definition match_stadium_3d.h:166
Vec3 normal
Definition match_stadium_3d.h:167
Vec3 origin
Definition match_stadium_3d.h:165
Definition match_stadium_3d.h:173
ImU32 color
Definition match_stadium_3d.h:175
std::array< Vec3, 8 > corners
Definition match_stadium_3d.h:174
Definition match_stadium_3d.h:130
float halfWidth
Definition match_stadium_3d.h:133
ImU32 color
Definition match_stadium_3d.h:135
std::byte flags
Definition match_stadium_3d.h:139
Vec3 top
Definition match_stadium_3d.h:132
std::uint8_t phase
Definition match_stadium_3d.h:140
std::uint32_t dotBegin
Definition match_stadium_3d.h:136
std::uint32_t dotEnd
Definition match_stadium_3d.h:137
Vec3 base
Definition match_stadium_3d.h:131
Definition match_stadium_3d.h:102
std::byte flags
Definition match_stadium_3d.h:106
ImU32 body
Definition match_stadium_3d.h:104
std::uint8_t phase
Definition match_stadium_3d.h:108
Vec3 base
Definition match_stadium_3d.h:103
ImU32 head
Definition match_stadium_3d.h:105
Definition match_stadium_3d.h:113
Vec3 along
Definition match_stadium_3d.h:115
ImU32 secondary
Definition match_stadium_3d.h:117
Vec3 base
Definition match_stadium_3d.h:114
ImU32 primary
Definition match_stadium_3d.h:116
std::uint8_t phase
Definition match_stadium_3d.h:119
std::byte flags
Definition match_stadium_3d.h:118
Definition match_stadium_3d.h:71
std::array< ImU32, 4 > colors
Definition match_stadium_3d.h:73
std::array< Vec3, 4 > corners
Definition match_stadium_3d.h:72
std::uint32_t flagEnd
Definition match_stadium_3d.h:80
Vec3 normal
Definition match_stadium_3d.h:74
ImU32 glow
Definition match_stadium_3d.h:82
std::uint32_t clumpBegin
Definition match_stadium_3d.h:76
std::uint32_t clumpEnd
Definition match_stadium_3d.h:77
std::uint32_t flagBegin
Definition match_stadium_3d.h:79
Definition match_stadium_3d.h:227
std::array< Vec3, 4 > cornerFlags
Definition match_stadium_3d.h:240
std::array< Goal, 2 > goals
Definition match_stadium_3d.h:239
std::vector< GroundPolygon > ground
Definition match_stadium_3d.h:228
std::vector< GroundPolygon > wear
Definition match_stadium_3d.h:231
std::vector< GroundPolygon > markings
Definition match_stadium_3d.h:232
std::vector< CrowdClump > clumps
Definition match_stadium_3d.h:236
std::vector< AdBoard > boards
Definition match_stadium_3d.h:238
void build(const MatchKits &kits, bool daylightView=false)
Definition match_stadium_3d.cpp:1097
std::vector< CrowdDot > crowd
Definition match_stadium_3d.h:235
bool inStandShadow(Vec3 point) const
Definition match_stadium_3d.cpp:1074
bool day
Definition match_stadium_3d.h:242
std::vector< Face > faces
Definition match_stadium_3d.h:233
std::vector< CrowdFlag > flags
Definition match_stadium_3d.h:237
std::vector< Section > sections
Definition match_stadium_3d.h:234
PitchGrid pitch
Definition match_stadium_3d.h:229
std::vector< GroundPolygon > standShadows
Definition match_stadium_3d.h:245
std::vector< std::array< Vec3, 4 > > shadowAreas
Definition match_stadium_3d.h:246
Definition match_stadium_3d.h:187
std::array< std::array< Vec3, 2 >, 2 > supports
Definition match_stadium_3d.h:190
std::array< NetPanel, 4 > nets
Definition match_stadium_3d.h:189
std::array< Box, 3 > frame
Definition match_stadium_3d.h:188
Definition match_stadium_3d.h:40
std::array< Vec3, 10 > points
Definition match_stadium_3d.h:41
std::uint8_t count
Definition match_stadium_3d.h:43
std::array< ImU32, 10 > colors
Definition match_stadium_3d.h:42
Definition match_stadium_3d.h:180
std::array< Vec3, 4 > corners
Definition match_stadium_3d.h:181
std::uint8_t columns
Definition match_stadium_3d.h:183
std::uint8_t rows
Definition match_stadium_3d.h:182
Definition match_stadium_3d.h:54
int columnVertices() const
Definition match_stadium_3d.h:61
int rows
Definition match_stadium_3d.h:57
std::vector< Vec3 > points
Definition match_stadium_3d.h:58
std::vector< ImU32 > colors
Definition match_stadium_3d.h:59
int stripes
Definition match_stadium_3d.h:55
int columnsPerStripe
Definition match_stadium_3d.h:56
std::size_t index(int stripe, int column, int row) const
Definition match_stadium_3d.h:62
Definition match_stadium_3d.h:155
std::uint32_t faceEnd
Definition match_stadium_3d.h:157
std::uint32_t faceBegin
Definition match_stadium_3d.h:156
Side side
Definition match_stadium_3d.h:159
Vec3 centre
Definition match_stadium_3d.h:158
Definition match_stadium_3d.h:194
ImU32 background
Definition match_stadium_3d.h:196
ImU32 foreground
Definition match_stadium_3d.h:197
const char * text
Definition match_stadium_3d.h:195