32 #include <engine/config.hpp>
41 template <
class T,
class URBG>
44 std::uniform_real_distribution<T> distribution(T{-1}, T{1});
47 for (std::size_t i = 0;
i < 3; ++
i)
57 const float swarm_radius = 25.0f;
58 const std::size_t male_count = 50;
59 const std::size_t queen_count = 50;
60 const std::size_t alate_count = male_count + queen_count;
73 std::uint32_t male_picking_flags = 0b01;
74 std::uint32_t queen_picking_flags = 0b10;
91 steering.agent.velocity = {0, 0, 0};
92 steering.agent.acceleration = {0, 0, 0};
93 steering.agent.max_force = 4.0f;
94 steering.agent.max_speed = 5.0f;
95 steering.agent.max_speed_squared = steering.agent.max_speed * steering.agent.max_speed;
97 steering.agent.forward = steering.agent.orientation * config::global_forward;
98 steering.agent.up = steering.agent.orientation * config::global_up;
99 steering.wander_weight = 1.0f;
101 steering.wander_distance = 10.0f;
102 steering.wander_radius = 8.0f;
103 steering.wander_angle = 0.0f;
104 steering.wander_angle2 = 0.0f;
105 steering.seek_weight = 0.2f;
106 steering.seek_target = swarm_center;
107 steering.flee_weight = 0.0f;
108 steering.sum_weights = steering.wander_weight + steering.seek_weight + steering.flee_weight;
126 for (std::size_t i = 0; i < alate_count; ++i)
129 steering.agent.position = swarm_center + sphere_random<float>(ctx.
rng) * swarm_radius;
148 picking.
flags = male_picking_flags;
161 picking.
flags = queen_picking_flags;
entity::id create_ant_swarm(::game &ctx)
void destroy_ant_swarm(::game &ctx, entity::id swarm_eid)
std::unique_ptr< resource_manager > resource_manager
std::unique_ptr< entity::registry > entity_registry
constexpr void set_mass(float mass) noexcept
Sets mass of the rigid body.
entt::entity id
Entity ID type.
quaternion< T > normalize(const quaternion< T > &q)
Normalizes a quaternion.
constexpr T radians(T degrees) noexcept
Converts an angle given in degrees to radians.
@ position
Vertex position (vec3)
float mass
Mass of the agent.
ant_caste_type type
Caste type.
static constexpr quaternion identity() noexcept
Returns a rotation identity quaternion.
std::uint32_t flags
Picking flags.
geom::sphere< float > sphere
Picking sphere.
ai::steering::agent agent
Steering agent.
Winged aerial locomotion.