38 template <
typename CoordinateType, logical_coordinate_system CoordinateSystem>
41 auto const& rectVertices =
rect_vertices(aRect, aMeshType, aTransformation);
42 aResult.
vertices.assign(rectVertices.begin(), rectVertices.end());
47 game::face{ aOffset + 0u, aOffset + 1u, aOffset + 2u },
48 game::face{ aOffset + 3u, aOffset + 4u, aOffset + 5u } };
52 template <
typename CoordinateType, logical_coordinate_system CoordinateSystem>
55 thread_local game::mesh result;
59 template <
typename T, std::
size_t D>
63 std::optional<basic_vector<T, D>> min;
64 std::optional<basic_vector<T, D>> max;
65 for (
auto const& v : aQuad)
76 aCenteringTranslation =
basic_vector<T, D>{ -(max->x - min->x) /
static_cast<T
>(2.0), -(max->y - min->y) /
static_cast<T
>(2.0) };
77 std::array<basic_vector<T, D>, 4> result = aQuad;
78 for (
auto& v : result)
79 v += aCenteringTranslation;
88 aQuad[0], aQuad[3], aQuad[2],
89 aQuad[0], aQuad[1], aQuad[2] };
93 vec3 centeringTranslation;
94 auto centeredQuad =
center_quad(aQuad, centeringTranslation);
95 for (
auto& v : centeredQuad)
96 v = *aTransformation * v + -centeringTranslation;
98 centeredQuad[0], centeredQuad[3], centeredQuad[2],
99 centeredQuad[0], centeredQuad[1], centeredQuad[2] };
105 game::face{ aOffset + 0u, aOffset + 1u, aOffset + 2u },
106 game::face{ aOffset + 3u, aOffset + 4u, aOffset + 5u } };
112 thread_local game::mesh result;
113 return to_ecs_component(result, aQuad, aMeshType, aTransformation, aOffset);
118 return to_ecs_component(aResult,
quad{ aQuad[0], aQuad[1], aQuad[2], aQuad[3] }, aMeshType, aTransformation, aOffset);
123 thread_local game::mesh result;
124 return to_ecs_component(result, aQuad, aMeshType, aTransformation, aOffset);
149 if (std::holds_alternative<color>(aTextColor))
151 else if (std::holds_alternative<gradient>(aTextColor))
176 if (std::holds_alternative<color>(aBrush))
178 else if (std::holds_alternative<gradient>(aBrush))
230 newTexture.sampling(),
231 newTexture.dpi_scale_factor(),
232 newTexture.extents().to_vec2(),
244 newTexture.sampling(),
245 newTexture.dpi_scale_factor(),
246 newTexture.extents().to_vec2(),
265 for (
u32 y = aCellIndexTopLeft.y; y <= aCellIndexBottomRight.y; ++y)
267 for (
u32 x = aCellIndexTopLeft.x; x <= aCellIndexBottomRight.x; ++x)
269 vec2 const uvOffset{ x * uvCellExtents.
x, 1.0 - (y + 1) * uvCellExtents.y };
279 {
vec3{ -1.0, -1.0, 0.0 },
vec3{ 1.0, -1.0, 0.0 },
vec3{ 1.0, 1.0, 0.0 },
vec3{ -1.0, 1.0, 0.0 } },
280 { uvOffset, uvOffset +
vec2{ uvCellExtents.
x, 0.0 }, uvOffset +
vec2{ uvCellExtents.
x, uvCellExtents.y }, uvOffset +
vec2{ 0.0, uvCellExtents.
y } },
299 aCells, aCellIndexTopLeft, aCellIndexBottomRight, aDefaultFrameDuration);
306 aCells, aDefaultFrameDuration);
333 if (!aTextureTransform.is_identity())
334 for (
auto& uv : patchMesh.
uv)
335 uv = (aTextureTransform *
vec3{ uv.
x, uv.y, 1.0 }).
xy;
336 aMesh.
uv.insert(aMesh.
uv.end(), patchMesh.
uv.begin(), patchMesh.
uv.end());
337 auto& patch = aMeshRenderer.
patches.emplace_back();
338 patch.faces.insert(patch.faces.end(), patchMesh.
faces.begin(), patchMesh.
faces.end());
347 if (!aTextureTransform.is_identity())
348 for (
auto& uv : patchMesh.
uv)
349 uv = (aTextureTransform *
vec3{ uv.
x, uv.y, 1.0 }).
xy;
350 aMesh.
uv.insert(aMesh.
uv.end(), patchMesh.
uv.begin(), patchMesh.
uv.end());
351 auto& patch = aMeshRenderer.
patches.emplace_back();
352 patch.faces.insert(patch.faces.end(), patchMesh.
faces.begin(), patchMesh.
faces.end());
361 if (!aTextureTransform.is_identity())
362 for (
auto& uv : patchMesh.
uv)
363 uv = (aTextureTransform *
vec3{ uv.
x, uv.y, 1.0 }).
xy;
364 aMesh.
uv.insert(aMesh.
uv.end(), patchMesh.
uv.begin(), patchMesh.
uv.end());
365 auto& patch = aMeshRenderer.
patches.emplace_back();
366 patch.faces.insert(patch.faces.end(), patchMesh.
faces.begin(), patchMesh.
faces.end());
const optional_rect & bounding_box() const override
gradient_id id() const override
aabb_2d to_aabb_2d() const
basic_vector< dimension_type, 2 > to_vec2() const
virtual const rect & atlas_location() const =0
virtual const i_sub_texture & as_sub_texture() const =0
virtual texture_id id() const =0
virtual dimension dpi_scale_factor() const =0
virtual texture_type type() const =0
virtual texture_sampling sampling() const =0
virtual size extents() const =0
virtual const i_shared_component & shared_component(component_id aComponentId) const =0
basic_vector< T2, Size, Type > as() const
void add_patch(game::mesh &aMesh, game::mesh_renderer &aMeshRenderer, const quad &aQuad, const neogfx::i_texture &aTexture, const mat33 &aTextureTransform=mat33::identity())
std::array< basic_vector< T, D >, 4 > center_quad(const std::array< basic_vector< T, D >, 4 > &aQuad, basic_vector< T, D > &aCenteringTranslation)
renderable_animation regular_sprite_sheet_to_renderable_animation(game::i_ecs &aEcs, std::string const &aName, const neogfx::image &aSpriteSheet, const vec2u32 &aCells, scalar aDefaultFrameDuration=0.0)
game::mesh const & to_ecs_component(game::mesh &aResult, const basic_rect< CoordinateType, CoordinateSystem > &aRect, mesh_type aMeshType=mesh_type::Triangles, optional_mat44 const &aTransformation={}, uint32_t aOffset=0)
vec3_array< 8 > const & rect_vertices(const basic_rect< CoordinateType, CoordinateSystem > &aRect, mesh_type aType, const optional_mat44 &aTransformation={})
game::animation regular_sprite_sheet_to_animation(const vec2u32 &aSpriteSheetExtents, const vec2u32 &aCells, const vec2u32 &aCellIndexTopLeft, const vec2u32 &aCellIndexBottomRight, scalar aDefaultDuration=0.0)
game::material image_to_material(game::i_ecs &aEcs, std::string const &aName, const neogfx::image &aImage)
std::array< vec2, 4 > quad_2d
std::array< vec3, 4 > quad
basic_cookie_ref_ptr< cookie > cookie_ref_ptr
std::optional< texture > texture
std::optional< shared< texture > > sharedTexture
neolib::cookie_ref_ptr id
game::animation_filter filter