1. -- 
  2. -- Jan & Uwe R. Zimmer, Australia, July 2011 
  3. -- 
  4.  
  5. with Ada.Real_Time;                     use Ada.Real_Time; 
  6. with Exceptions;                        use Exceptions;                        pragma Elaborate_All (Exceptions); 
  7. with Real_Type;                         use Real_Type; 
  8. with Generic_Sliding_Statistics;                                               pragma Elaborate_All (Generic_Sliding_Statistics); 
  9. with Graphics_Configuration;            use Graphics_Configuration; 
  10. with Graphics_Data;                     use Graphics_Data; 
  11. with Graphics_FrameRates;               use Graphics_FrameRates; 
  12. with Graphics_OpenGL;                   use Graphics_OpenGL; 
  13. with Graphics_Structures;               use Graphics_Structures; 
  14. with Keyboard;                          use Keyboard; 
  15. with Models;                            use Models; 
  16. with Rotations;                         use Rotations; 
  17. with Screenshots;                       use Screenshots; 
  18. with Swarm_Configuration;               use Swarm_Configuration; 
  19. with Swarm_Configurations;              use Swarm_Configurations; 
  20. with Swarm_Control;                     use Swarm_Control;                     pragma Elaborate_All (Swarm_Control); 
  21. with Swarm_Control_Concurrent_Generic;                                         pragma Elaborate_All (Swarm_Control_Concurrent_Generic); 
  22. with Swarm_Data;                        use Swarm_Data; 
  23. with Swarm_Structures;                  use Swarm_Structures; 
  24. with Swarm_Structures_Base;             use Swarm_Structures_Base; 
  25. with Vectors_3D;                        use Vectors_3D; 
  26.  
  27. package body Callback_Procedures is 
  28.  
  29.    use Real_Elementary_Functions; 
  30.  
  31.    Smoothing_Time : constant Positive := 10; -- seconds 
  32.  
  33.    package Centre_Of_Gravity_Stats is new Generic_Sliding_Statistics (Element      => Vector_3D, 
  34.                                                                       Buffer_Size  => Smoothing_Time * Positive (Intented_Framerate)); 
  35.    package Mean_Radius_Stats       is new Generic_Sliding_Statistics (Element      => Real, 
  36.                                                                       Buffer_Size  => Smoothing_Time * Positive (Intented_Framerate)); 
  37.  
  38.    package Centre_Of_Gravity_Averages is new Centre_Of_Gravity_Stats.Averages; use Centre_Of_Gravity_Averages; 
  39.    package Mean_Radius_Averages       is new Mean_Radius_Stats.Averages;       use Mean_Radius_Averages; 
  40.  
  41.    use Swarm_Vectors; 
  42.  
  43.    package Swarm_Control_Concurrent is new Swarm_Control_Concurrent_Generic (No_of_Cores_for_Swarm); 
  44.    use Swarm_Control_Concurrent; 
  45.  
  46.    package Execute_Commands is 
  47.       procedure Act_On_Input (Position  : in out Vector_3D; 
  48.                               Rotation  : in out Quaternion_Rotation; 
  49.                               Time      :        Real; 
  50.                               Commands  :        Commands_Array); 
  51.    private 
  52.       Keys_Released : Boolean  := True; 
  53.    end Execute_Commands; 
  54.  
  55.    package body Execute_Commands is 
  56.  
  57.       procedure Act_On_Input (Position  : in out Vector_3D; 
  58.                               Rotation  : in out Quaternion_Rotation; 
  59.                               Time      :        Real; 
  60.                               Commands  :        Commands_Array) is 
  61.  
  62.          Accelerator    : constant Real  :=  4.0; 
  63.          Rotation_Speed :          Real  :=  0.3 * Time; 
  64.          Moving_Speed   :          Real  :=  0.3 * Time; 
  65.          Step           :      Vector_3D := (0.0, 0.0, 0.0); 
  66.  
  67.       begin 
  68.          for Command in Commands'Range loop 
  69.             if Commands (Command) then 
  70.                case Command is 
  71.  
  72.                   when Move_Accelerator => 
  73.                      Rotation_Speed := Rotation_Speed * Accelerator; 
  74.                      Moving_Speed   := Moving_Speed   * Accelerator; 
  75.                   when Full_Screen  => 
  76.                      if Keys_Released then 
  77.                         Full_Screen_Mode.Change_Full_Screen; 
  78.                      end if; 
  79.                   when Reset_Camera => 
  80.                      case Camera_Mode is 
  81.                         when Scene => 
  82.                            Position := Initial_Cams (Camera_Mode).Scene_Offset; 
  83.                            Rotation := Initial_Cams (Camera_Mode).Rotation; 
  84.                         when Chase => 
  85.                            Position := Initial_Cams (Camera_Mode).Object_Offset; 
  86.                            Rotation := Initial_Cams (Camera_Mode).Rotation; 
  87.                      end case; 
  88.                   when Screen_Shot => Take_Shot; 
  89.                   when Toggle_Axis => 
  90.                      if Keys_Released then 
  91.                         Show_Axis := not Show_Axis; 
  92.                      end if; 
  93.                   when Toggle_Lines => 
  94.                      if Keys_Released then 
  95.                         Show_Connecting_Lines := not Show_Connecting_Lines; 
  96.                      end if; 
  97.                   when Text_Overlay => 
  98.                      if Keys_Released then 
  99.                         Show_Text_Overlay := not Show_Text_Overlay; 
  100.                      end if; 
  101.                   when Space => 
  102.                      if Keys_Released then 
  103.                         case Camera_Mode is 
  104.                            when Scene => Camera_Mode := Chase; 
  105.                            when Chase => Camera_Mode := Scene; 
  106.                         end case; 
  107.                      end if; 
  108.  
  109.                      -- Rotation -- 
  110.                   when Rotate_Left => Rotation := Rotate 
  111.                        (Rotation, To_Rotation (0.0, 0.0,  Rotation_Speed)); 
  112.                   when Rotate_Right => Rotation := Rotate 
  113.                        (Rotation, To_Rotation (0.0, 0.0, -Rotation_Speed)); 
  114.                   when Rotate_Up => Rotation := Rotate 
  115.                        (Rotation, To_Rotation (0.0,  Rotation_Speed, 0.0)); 
  116.                   when Rotate_Down => Rotation := Rotate 
  117.                        (Rotation, To_Rotation (0.0, -Rotation_Speed, 0.0)); 
  118.                   when Rotate_CW => Rotation := Rotate 
  119.                        (Rotation, To_Rotation (-Rotation_Speed, 0.0, 0.0)); 
  120.                   when Rotate_AntiCW => Rotation := Rotate 
  121.                        (Rotation, To_Rotation  (Rotation_Speed, 0.0, 0.0)); 
  122.  
  123.                      -- Stepping -- 
  124.                   when Strafe_Left     => Step (x) := Step (x) - Moving_Speed; 
  125.                   when Strafe_Right    => Step (x) := Step (x) + Moving_Speed; 
  126.                   when Strafe_Up       => Step (z) := Step (z) + Moving_Speed; 
  127.                   when Strafe_Down     => Step (z) := Step (z) - Moving_Speed; 
  128.                   when Strafe_Forward  => Step (y) := Step (y) + Moving_Speed; 
  129.                   when Strafe_Backward => Step (y) := Step (y) - Moving_Speed; 
  130.  
  131.                      -- Swarm control -- 
  132.  
  133.                   when Add_Vehicle    => 
  134.                      if Keys_Released then 
  135.                         if Natural (Length (Swarm_State)) = 0 then 
  136.                            Swarm_Monitor.Append_Random_Swarm (1); 
  137.                         else 
  138.                            Swarm_Monitor.Append_Random_Swarm (1, Swarm_Monitor.Centre_Of_Gravity, 0.0001); 
  139.                         end if; 
  140.                      end if; 
  141.                   when Remove_Vehicle => 
  142.                      if Keys_Released then -- and then Natural (Length (Swarm_State)) > 1 then 
  143.                         Remove_Vehicles (1); 
  144.                      end if; 
  145.                end case; 
  146.             end if; 
  147.          end loop; 
  148.  
  149.          Keys_Released := Commands = Command_Set_Reset; 
  150.  
  151.          case Camera_Mode is 
  152.             when Scene => Step := Rotate (Step, Rotation); 
  153.             when Chase => null; 
  154.          end case; 
  155.  
  156.          for Axes in Step'Range loop 
  157.             Position (Axes) := Position (Axes) + Step (Axes); 
  158.          end loop; 
  159.  
  160.       end Act_On_Input; 
  161.    end Execute_Commands; 
  162.  
  163.    -- 
  164.    -- 
  165.    -- 
  166.  
  167.    procedure Main_Operations is 
  168.  
  169.       Time_Interval      : constant Time_Span  := Measure_Interval; -- Time since last call 
  170.       FrameRate          : constant Natural    := Natural (Average_Framerate (Time_Interval)); 
  171.       Time_Interval_Real : constant Real       := Real (To_Duration (Time_Interval)); 
  172.  
  173.       Commands : Commands_Array := Command_Set_Reset; 
  174.  
  175.    begin 
  176.       Framerate_Limiter (Intented_Framerate); 
  177.  
  178.       Get_Keys (Commands); 
  179.  
  180.       case Camera_Mode is 
  181.          when Scene => 
  182.             Execute_Commands.Act_On_Input (Cam.Scene_Offset, Cam.Rotation, Time_Interval_Real, Commands); 
  183.             case Camera_Mode is 
  184.                when Scene => 
  185.                   Cam.Position := Swarm_Monitor.Centre_Of_Gravity; 
  186.                when Chase => 
  187.                   Cam := Initial_Cams (Camera_Mode); 
  188.             end case; 
  189.  
  190.          when Chase => 
  191.             Execute_Commands.Act_On_Input (Cam.Object_Offset, Cam.Rotation, Time_Interval_Real, Commands); 
  192.             case Camera_Mode is 
  193.                when Scene => Cam := Initial_Cams (Camera_Mode); 
  194.                when Chase => 
  195.                   Cam.Position := Element (Swarm_State, 1).Position.all.Read; 
  196.                   declare 
  197.                      --                 Element_Roll  : constant Angle := Roll  (Element (Swarm_State, 1).Rotation); 
  198.                      Element_Pitch : constant Radiants := Pitch (Element (Swarm_State, 1).Rotation.all.Read); 
  199.                      Element_Yaw   : constant Radiants := Yaw   (Element (Swarm_State, 1).Rotation.all.Read); 
  200.                   begin 
  201.                      Cam.Rotation := To_Rotation (0.0, 0.0, -Element_Yaw); 
  202.                      Cam.Rotation := Rotate (Cam.Rotation, To_Rotation (0.0, -Element_Pitch, 0.0)); 
  203.                      --                 Cam.Rotation := Rotate (Cam.Rotation, To_Rotation (-Element_Roll, 0.0, 0.0)); 
  204.                   end; 
  205. --                    Cam.Rotation := Inverse (Element (Swarm_State, 1).Rotation); 
  206.             end case; 
  207.       end case; 
  208.  
  209.       Position_Camera; 
  210.  
  211.       for Element_Index in First_Index (Swarm_State) .. Last_Index (Swarm_State) loop 
  212.          declare 
  213.             This_Element : constant Swarm_Element_State := Element (Swarm_State, Element_Index); 
  214.             Charge_Index : constant Positive            := 
  215.               Positive ((Real (This_Element.Charge.Level) * (Real (Spaceship_Gradient'Last (2) - Spaceship_Gradient'First (2)))) 
  216.                         + Real (Spaceship_Gradient'First (2))); 
  217.          begin 
  218.  
  219.             if This_Element.Controls.all.Read_Throttle /= Idle_Throttle then 
  220.                Draw (Spaceship_Gradient (G_Ruby,      Charge_Index), This_Element.Position.all.Read, This_Element.Rotation.all.Read); 
  221.             else 
  222.                Draw (Spaceship_Gradient (G_Turquoise, Charge_Index), This_Element.Position.all.Read, This_Element.Rotation.all.Read); 
  223.             end if; 
  224.  
  225.             if Show_Connecting_Lines then 
  226.                for Neighbour_Index in Distance_Vectors.First_Index (This_Element.Neighbours.all) .. Distance_Vectors.Last_Index (This_Element.Neighbours.all) loop 
  227.                   declare 
  228.                      Distance_Entry : constant Distance_Entries := Distance_Vectors.Element (This_Element.Neighbours.all, Neighbour_Index); 
  229.                   begin 
  230.                      if Distance_Entry.Distance <= Comms_Range then 
  231.                         Draw_Lines ((This_Element.Position.all.Read, Element (Swarm_State, Distance_Entry.Index).Position.all.Read)); 
  232.                      end if; 
  233.                   exception 
  234.                      when Constraint_Error => null; -- Neighbour died 
  235.                   end; 
  236.                end loop; 
  237.             end if; 
  238.          end; 
  239.       end loop; 
  240.  
  241.       case Configuration is 
  242.  
  243.          when Single_Globe_In_Orbit => 
  244.  
  245.             Sphere_Angles := Sphere_Angles + Sphere_Increment; 
  246.  
  247.             for Globe_Ix in Globes'Range loop 
  248.                declare 
  249.  
  250.                   Sin_x : constant Real := Sin (Sphere_Angles (x)); 
  251.                   Cos_x : constant Real := Cos (Sphere_Angles (x)); 
  252.                   Sin_y : constant Real := Sin (Sphere_Angles (y)); 
  253.                   Cos_y : constant Real := Cos (Sphere_Angles (y)); 
  254.                   Sin_z : constant Real := Sin (Sphere_Angles (z)); 
  255.                   Cos_z : constant Real := Cos (Sphere_Angles (z)); 
  256.  
  257.                   Radius : constant Real := Average (Swarm_Monitor.Mean_Radius); 
  258.  
  259.                   Sphere_Offset : constant Positions := (x => Sin_z * Radius * Cos_x * Cos_y, 
  260.                                                          y => Sin_z * Radius * Cos_x * Sin_y, 
  261.                                                          z => Cos_z * Radius * Sin_x); 
  262.  
  263.                   New_Position : constant Positions := Average (Swarm_Monitor.Centre_Of_Gravity) + Sphere_Offset; 
  264.  
  265.                begin 
  266.                   Globes (Globe_Ix).Velocity.all.Write ((New_Position - Globes (Globe_Ix).Position.all.Read) / Time_Interval_Real); 
  267.                   Globes (Globe_Ix).Position.all.Write (New_Position); 
  268.                   Draw (Model_Set (Sphere), New_Position, Zero_Rotation); 
  269.                end; 
  270.             end loop; 
  271.  
  272.          when Dual_Globes_In_Orbit => 
  273.  
  274.             Sphere_Angles := Sphere_Angles + Sphere_Increment; 
  275.  
  276.             for Globe_Ix in Globes'Range loop 
  277.                declare 
  278.  
  279.                   Sin_x : constant Real := Sin (Sphere_Angles (x)); 
  280.                   Cos_x : constant Real := Cos (Sphere_Angles (x)); 
  281.                   Sin_y : constant Real := Sin (Sphere_Angles (y)); 
  282.                   Cos_y : constant Real := Cos (Sphere_Angles (y)); 
  283.                   Sin_z : constant Real := Sin (Sphere_Angles (z)); 
  284.                   Cos_z : constant Real := Cos (Sphere_Angles (z)); 
  285.  
  286.                   Radius : constant Real := Average (Swarm_Monitor.Mean_Radius); 
  287.  
  288.                   Sphere_Offset_1 : constant Positions := (x => Sin_z * Radius * Cos_x * Cos_y, 
  289.                                                            y => Sin_z * Radius * Cos_x * Sin_y, 
  290.                                                            z => Cos_z * Radius * Sin_x); 
  291.  
  292.                   Sphere_Offset_2 : constant Positions := (x => -Sphere_Offset_1 (x), 
  293.                                                            y => -Sphere_Offset_1 (y), 
  294.                                                            z => -Sphere_Offset_1 (z)); 
  295.  
  296.                   New_Position_1 : constant Positions := Average (Swarm_Monitor.Centre_Of_Gravity) + Sphere_Offset_1; 
  297.                   New_Position_2 : constant Positions := Average (Swarm_Monitor.Centre_Of_Gravity) + Sphere_Offset_2; 
  298.  
  299.                begin 
  300.                   if Globe_Ix = Globes'First then 
  301.                      Globes (Globe_Ix).Velocity.all.Write ((New_Position_1 - Globes (Globe_Ix).Position.all.Read) / Time_Interval_Real); 
  302.                      Globes (Globe_Ix).Position.all.Write (New_Position_1); 
  303.                      Draw (Model_Set (Sphere), New_Position_1, Zero_Rotation); 
  304.  
  305.                   else 
  306.                      Globes (Globe_Ix).Velocity.all.Write ((New_Position_2 - Globes (Globe_Ix).Position.all.Read) / Time_Interval_Real); 
  307.                      Globes (Globe_Ix).Position.all.Write (New_Position_2); 
  308.                      Draw (Model_Set (Sphere), New_Position_2, Zero_Rotation); 
  309.                   end if; 
  310.                end; 
  311.             end loop; 
  312.  
  313.          when Globe_Grid_In_Centre => 
  314.  
  315.             for Globe_Ix in Globes'Range loop 
  316.                declare 
  317.                   New_Position : constant Positions := Average (Swarm_Monitor.Centre_Of_Gravity) + Energy_Globes_Defaults (Globe_Ix).Position; 
  318.                begin 
  319.                   Globes (Globe_Ix).Velocity.all.Write ((New_Position - Globes (Globe_Ix).Position.all.Read) / Time_Interval_Real); 
  320.                   Globes (Globe_Ix).Position.all.Write (New_Position); 
  321.                   Draw (Model_Set (Sphere), Globes (Globe_Ix).Position.all.Read, Zero_Rotation); 
  322.                end; 
  323.             end loop; 
  324.  
  325.          when Globe_Grid_Drifting => 
  326.  
  327.             for Globe_Ix in Globes'Range loop 
  328.                Globes (Globe_Ix).Velocity.all.Write (Energy_Globes_Velocity); 
  329.                Globes (Globe_Ix).Position.all.Write (Globes (Globe_Ix).Position.all.Read + Energy_Globes_Velocity * Time_Interval_Real); 
  330.                Draw (Model_Set (Sphere), Globes (Globe_Ix).Position.all.Read, Zero_Rotation); 
  331.             end loop; 
  332.  
  333.       end case; 
  334.  
  335.       -- Coordinate axes for reference 
  336.       -- 
  337.  
  338. --        Draw_Lines (((-1.0, 0.0, 0.0), (1.0, 0.0, 0.0))); 
  339. --        Draw_Lines (((0.0, -1.0, 0.0), (0.0, 1.0, 0.0))); 
  340. --        Draw_Lines (((0.0, 0.0, -1.0), (0.0, 0.0, 1.0))); 
  341.  
  342.       if Show_Axis then 
  343.          declare 
  344.             Beam_Colour_Red     : constant RGBA_Colour := (Red => 1.00, Green => 0.00, Blue => 0.00, Alpha => 1.00); 
  345.             Beam_Colour_Green   : constant RGBA_Colour := (Red => 0.00, Green => 1.00, Blue => 0.00, Alpha => 1.00); 
  346.             Beam_Colour_Blue    : constant RGBA_Colour := (Red => 0.00, Green => 0.00, Blue => 1.00, Alpha => 1.00); 
  347.             Beam_Colour_Magenta : constant RGBA_Colour := (Red => 1.00, Green => 0.00, Blue => 1.00, Alpha => 1.00); 
  348.             Beam_Colour_Cyan    : constant RGBA_Colour := (Red => 0.00, Green => 1.00, Blue => 1.00, Alpha => 1.00); 
  349.             Beam_Colour_Yellow  : constant RGBA_Colour := (Red => 1.00, Green => 1.00, Blue => 0.00, Alpha => 1.00); 
  350.  
  351.          begin 
  352.             Draw_Laser ((-1.0,  0.0,  0.0), (1.0,  0.0,  0.0), Beam_Radius => 0.0001, Aura_Radius => 0.008, Beam_Colour => Beam_Colour_Red); 
  353.             Draw_Laser ((0.0,  -1.0,  0.0), (0.0,  1.0,  0.0), Beam_Radius => 0.0001, Aura_Radius => 0.008, Beam_Colour => Beam_Colour_Green); 
  354.             Draw_Laser ((0.0,   0.0, -1.0), (0.0,  0.0,  1.0), Beam_Radius => 0.0001, Aura_Radius => 0.008, Beam_Colour => Beam_Colour_Blue); 
  355.  
  356.             Draw_Laser ((-1.0,  0.0, -1.0), (1.0,  0.0,  1.0), Beam_Radius => 0.0001, Aura_Radius => 0.008, Beam_Colour => Beam_Colour_Magenta); 
  357.             Draw_Laser ((-1.0,  0.0,  1.0), (1.0,  0.0, -1.0), Beam_Radius => 0.0001, Aura_Radius => 0.008, Beam_Colour => Beam_Colour_Magenta); 
  358.  
  359.             Draw_Laser ((0.0,  -1.0, -1.0), (0.0,  1.0,  1.0), Beam_Radius => 0.0001, Aura_Radius => 0.008, Beam_Colour => Beam_Colour_Cyan); 
  360.             Draw_Laser ((0.0,  -1.0,  1.0), (0.0,  1.0, -1.0), Beam_Radius => 0.0001, Aura_Radius => 0.008, Beam_Colour => Beam_Colour_Cyan); 
  361.  
  362.             Draw_Laser ((-1.0, -1.0,  0.0), (1.0,  1.0,  0.0), Beam_Radius => 0.0001, Aura_Radius => 0.008, Beam_Colour => Beam_Colour_Yellow); 
  363.             Draw_Laser ((-1.0,  1.0,  0.0), (1.0, -1.0,  0.0), Beam_Radius => 0.0001, Aura_Radius => 0.008, Beam_Colour => Beam_Colour_Yellow); 
  364.          end; 
  365.       end if; 
  366.  
  367.       if Show_Text_Overlay then 
  368.          declare 
  369.             Text_Colour : constant RGBA_Colour := (Red => 0.40, Green => 0.44, Blue => 0.40, Alpha => 0.80); 
  370.             use Cursor_Management; 
  371.          begin 
  372.             Set_Colour (Text_Colour); 
  373.             Home; 
  374.             Text_2D ("Framerate: " & Natural'Image (FrameRate) & " Hz");             Line_Feed; 
  375.             Text_2D ("Number of vehicles"); Indend (105); Text_2D (": " & Natural'Image (Natural (Length (Swarm_State))));  Line_Feed; 
  376.             Text_2D ("Swarm velocity    "); Indend (105); Text_2D (": " & Real'Image (Vectors_3D."abs" (Swarm_Monitor.Mean_Velocity)));   Line_Feed; 
  377.             Text_2D ("Average velocity  "); Indend (105); Text_2D (": " & Real'Image (Swarm_Monitor.Mean_Velocity));         Line_Feed; 
  378.             Text_2D ("Max swarm radius  "); Indend (105); Text_2D (": " & Real'Image (Swarm_Monitor.Maximal_Radius));        Line_Feed; 
  379.             Text_2D ("Mean swarm radius "); Indend (105); Text_2D (": " & Real'Image (Swarm_Monitor.Mean_Radius));           Line_Feed; 
  380.             Text_2D ("Mean spacing      "); Indend (105); Text_2D (": " & Real'Image (Swarm_Monitor.Mean_Closest_Distance)); Paragraph_Feed; 
  381.  
  382.             Text_2D ("Press <space> to change to chase mode");                       Line_Feed; 
  383.             Text_2D ("<alt-.> to toggle neighbourhood lines");                       Line_Feed; 
  384.             Text_2D ("<alt-,> to toggle axis lines");                                Paragraph_Feed; 
  385.  
  386.             Text_2D ("Fullscreen: <alt-f>");                                         Line_Feed; 
  387.             Text_2D ("Screenshot: <alt-s>");                                         Line_Feed; 
  388.             Text_2D ("Reset camera: <alt-c>");                                       Paragraph_Feed; 
  389.  
  390.             Text_2D ("Translations: <a|d|s|w|q|e> - Rotation: <j|l|k|i|u|o>");       Line_Feed; 
  391.             Text_2D ("<alt-t> to make this text disappear");                         Paragraph_Feed; 
  392.  
  393.             Text_2D ("<+> to add a vehicle, <-> to remove one");                     Line_Feed; 
  394.          end; 
  395.       end if; 
  396.  
  397.       Show_Drawing; 
  398.  
  399. --        Set_All_Accelerations; 
  400. --        Forward_All_Messages; 
  401. --        Move_All_Elements; 
  402. --        Update_All_Rotations; 
  403.  
  404.       Distribute_Jobs (Set_Accelerations); 
  405.       Distribute_Jobs (Forward_Messages); 
  406.       Distribute_Jobs (Move_Elements); 
  407.       Distribute_Jobs (Update_Rotations); 
  408.       Remove_Empties; 
  409.  
  410.       Simulator_Tick.Tick; 
  411.  
  412.    exception 
  413.       when E : others => Show_Exception (E); 
  414.  
  415.    end Main_Operations; 
  416.  
  417.    ---------------------------- 
  418.    -- Initialize Environment -- 
  419.    ---------------------------- 
  420.  
  421.    procedure Initialize_Environment is 
  422.  
  423.    begin 
  424.       Cam := Initial_Cams (Camera_Mode); 
  425.       Swarm_Monitor.Append_Random_Swarm; 
  426.    exception 
  427.       when E : others => Show_Exception (E); 
  428.    end Initialize_Environment; 
  429.  
  430. begin 
  431.    Initialize_Environment; 
  432. end Callback_Procedures;