text
stringlengths
0
234
Cam.Rotation := Rotate (Cam.Rotation, To_Rotation (0.0, -Element_Pitch, 0.0));
-- Cam.Rotation := Rotate (Cam.Rotation, To_Rotation (-Element_Roll, 0.0, 0.0));
Function Definition: procedure Initialize is
Function Body: begin
for Model in Model_Name loop
case Model is
-- when Arrow => Arrow_P.Create (object => Model_Set (Model), scale => 0.003, centre => (0.0, 0.0, 0.0));
-- when Cube => Cube_P.Create (object => Model_Set (Model), scale => 0.015, centre => (0.0, 0.0, 0.0));
-- when Duck => Duck_P.Create (object => Model_Set (Model), scale => 0.003, centre => (0.0, 0.0, 0.0));
-- when Plane => Plane_P.Create (object => Model_Set (Model), scale => 0.003, centre => (0.0, 0.0, 0.0));
when Spaceship => Spaceship_P.Create (Object => Model_Set (Model), Object_Scale => 0.003, Centre => (0.0, 0.0, 0.0)); Assign_Material (Model_Set (Model), Pearl);
-- when Spaceship_Ruby => Spaceship_P.Create (object => Model_Set (Model), scale => 0.003, centre => (0.0, 0.0, 0.0)); Assign_Material (Model_Set (Model), Ruby);
when Sphere => Sphere_P.Create (object => Model_Set (Model), Object_Scale => 0.015, centre => (0.0, 0.0, 0.0)); Assign_Material (Model_Set (Model), Ruby);
end case;
end loop;
for M in Spaceship_Gradient'Range (1) loop
for i in Spaceship_Gradient'Range (2) loop
Spaceship_P.Create (Object => Spaceship_Gradient (M, i), Object_Scale => 0.003, Centre => (0.0, 0.0, 0.0));
declare
Ratio : constant Ratio_T :=
((Real (i) - Real (Spaceship_Gradient'First (2)))
/ Real (Spaceship_Gradient'Last (2) - Spaceship_Gradient'First (2)))
+ Ratio_T'First;
begin
case M is
when G_Ruby => Assign_Material (Spaceship_Gradient (M, i), Blend_Material (Ruby, Pearl, Ratio));
when G_Turquoise => Assign_Material (Spaceship_Gradient (M, i), Blend_Material (Turquoise, Pearl, Ratio));
end case;
Function Definition: function Mean_Closest_Distance return Real is
Function Body: Acc_Distance : Real := 0.0;
begin
for Element_Index in First_Index (Swarm_State) .. Last_Index (Swarm_State) loop
declare
This_Element : constant Swarm_Element_State := Element (Swarm_State, Element_Index);
Neighbours : constant Distance_Vectors.Vector := This_Element.Neighbours.all;
begin
if Distance_Vectors.Length (Neighbours) > 0 then
declare
Closest_Distance : constant Real :=
Distance_Vectors.Element (Neighbours, Distance_Vectors.First_Index (Neighbours)).Distance;
begin
Acc_Distance := Acc_Distance + Closest_Distance;
Function Definition: procedure Sorted_Close_Distances (Close_Dist : in out Distance_Vectors.Vector;
Function Body: Element_Index : Swarm_Element_Index;
Max_Distance : Distances) is
This_Element : constant Swarm_Element_State := Element (Swarm_State, Element_Index);
This_Position : constant Positions := This_Element.Position.all.Read;
begin
Distance_Vectors.Clear (Close_Dist);
Distance_Vectors.Reserve_Capacity (Close_Dist, Length (Swarm_State) - 1);
for Scan_Index in First_Index (Swarm_State) .. Last_Index (Swarm_State) loop
if Element_Index /= Scan_Index then
declare
Test_Element : constant Swarm_Element_State := Element (Swarm_State, Scan_Index);
Test_Position : constant Positions := Test_Element.Position.all.Read;
Test_Direction : constant Vector_3D := This_Position - Test_Position;
Test_Distance : constant Distances := abs (Test_Direction);
begin
if Test_Distance <= Max_Distance then
Distance_Vectors.Append (Close_Dist, (Index => Scan_Index,
Distance => Test_Distance,
Position_Diff => Test_Direction,
Velocity_Diff => This_Element.Velocity.all.Read - Test_Element.Velocity.all.Read));
end if;
Function Definition: procedure Set_All_Accelerations is
Function Body: begin
for Element_Index in First_Index (Swarm_State) .. Last_Index (Swarm_State) loop
Set_Acceleration (Element_Index);
end loop;
end Set_All_Accelerations;
--
--
--
procedure Forward_Messages (Element_Index : Swarm_Element_Index) is
This_Element : constant Swarm_Element_State := Element (Swarm_State, Element_Index);
Message_To_Be_Distributed : Inter_Vehicle_Messages;
begin
while This_Element.Comms.all.Has_Outgoing_Messages loop
This_Element.Comms.all.Fetch_Message (Message_To_Be_Distributed);
Check_Neighbours : for Distance_Index in Distance_Vectors.First_Index (This_Element.Neighbours.all) .. Distance_Vectors.Last_Index (This_Element.Neighbours.all) loop
declare
Distance_Entry : constant Distance_Entries := Distance_Vectors.Element (This_Element.Neighbours.all, Distance_Index);
begin
if Distance_Entry.Distance <= Comms_Range then
Element (Swarm_State, Distance_Entry.Index).Comms.all.Push_Message (Message_To_Be_Distributed);
else
exit Check_Neighbours;
end if;