gel.world: Fix sprite naming.

This commit is contained in:
Rod Kay
2024-01-03 12:17:59 +11:00
parent ae520b226b
commit a3cf450826
8 changed files with 92 additions and 11 deletions

View File

@@ -123,6 +123,7 @@ is
--
function new_circle_Sprite (in_World : in gel.World.view;
Name : in String;
Site : in math.Vector_3 := math.Origin_3D;
Mass : in math.Real := 1.0;
Friction : in math.Real := 0.5;
@@ -158,7 +159,7 @@ is
texture_Count => 1)).all'Access;
end if;
return gel.Sprite.Forge.new_Sprite ("circle_Sprite",
return gel.Sprite.Forge.new_Sprite (Name,
sprite.World_view (in_World),
Site,
the_graphics_Model,

View File

@@ -54,6 +54,7 @@ is
--
function new_circle_Sprite (in_World : in gel.World.view;
Name : in String;
Site : in math.Vector_3 := math.Origin_3D;
Mass : in math.Real := 1.0;
Friction : in math.Real := 0.5;

View File

@@ -5,6 +5,7 @@ with
lace.Observer,
lace.Subject,
lace.Event,
lace.Text,
ada.unchecked_Conversion,
ada.Containers.indefinite_hashed_Maps,
@@ -114,6 +115,7 @@ is
type sprite_model_Pair is
record
sprite_Id : gel .sprite_Id;
sprite_Name : lace.Text.item_64;
graphics_model_Id : openGL .model_Id;
physics_model_Id : physics.model_Id;
@@ -177,6 +179,14 @@ is
type sprite_added_Event is new lace.Event.item with
record
Sprite : gel.sprite_Id;
end record;
--------------
-- Test/Debug
--

View File

@@ -9,8 +9,10 @@ with
lace.Response,
lace.Event.utility,
lace.Text,
ada.unchecked_Deallocation,
ada.Exceptions,
ada.Text_IO;
@@ -96,11 +98,13 @@ is
the_physics_Models : in Id_Maps_of_physics_Model .Map;
the_World : in gel.World.view) return gel.Sprite.view
is
use openGL,
lace.Text;
the_graphics_Model : access openGL .Model.item'Class;
the_physics_Model : access physics.Model.item'Class;
the_Sprite : gel.Sprite.view;
use openGL;
begin
-- log ("gel.world.client.to_Sprite ~ the_Pair.graphics_Model_Id:" & the_Pair.graphics_Model_Id'Image);
@@ -110,7 +114,7 @@ is
the_physics_Model := physics.Model.view ( the_physics_Models.Element (the_Pair. physics_Model_Id));
the_Sprite := gel.Sprite.forge.new_Sprite ("Sprite" & the_Pair.sprite_Id'Image,
the_Sprite := gel.Sprite.forge.new_Sprite (+the_Pair.sprite_Name,
sprite.World_view (the_World),
get_Translation (the_Pair.Transform),
the_graphics_Model,
@@ -132,6 +136,8 @@ is
-- the_Sprite.desired_Site_is (the_Sprite.Site);
-- the_Sprite.desired_Spin_is (to_Quaternion (get_Rotation (the_Sprite.Transform)));
log ("gel.world.client.to_Sprite");
return the_Sprite;
end to_Sprite;
@@ -292,7 +298,6 @@ is
function Name (Self : in my_new_sprite_Response) return String;
overriding
procedure respond (Self : in out my_new_sprite_Response; to_Event : in lace.Event.Item'Class)
is
@@ -306,10 +311,15 @@ is
the_Sprite : constant gel.Sprite.view
:= to_Sprite (the_Event.Pair,
Self.graphics_Models.all,
Self.physics_Models.all,
Self. physics_Models.all,
Self.World);
added_Event : gel.remote.World.sprite_added_Event;
begin
Self.World.add (the_Sprite);
Self.World.add (the_Sprite);
-- Self.World.emit (sprite_added_Event' (Sprite => the_Sprite.Id));
added_Event.Sprite := the_Sprite.Id;
Self.World.emit (added_Event);
end;
end respond;
@@ -458,7 +468,7 @@ is
use remote.World.id_Maps_of_graphics_model;
the_server_graphics_Models : constant remote.World.id_Map_of_graphics_model := of_World.graphics_Models; -- Fetch graphics graphics_Models from the server.
the_server_physics_Models : constant remote.World. id_Map_of_physics_model := of_World. physics_Models; -- Fetch physics graphics_Models from the server.
the_server_physics_Models : constant remote.World.id_Map_of_physics_model := of_World. physics_Models; -- Fetch physics graphics_Models from the server.
begin
-- Create our local graphics graphics_Models.
--
@@ -498,6 +508,7 @@ is
declare
the_Sprite : gel.Sprite.view;
the_server_Sprites : constant remote.World.sprite_model_Pairs := of_World.Sprites;
-- kkk : gel.remote.World.sprite_added_Event;
begin
for i in the_server_Sprites'Range
loop
@@ -505,7 +516,10 @@ is
Self.graphics_Models,
Self. physics_Models,
gel.World.view (Self));
log ("k1");
Self.add (the_Sprite);
-- Self.emit (sprite_added_Event' (Sprite => the_Sprite.Id));
-- Self.emit (sprite_added_Event' (kkk));
end loop;
end;
end;
@@ -524,8 +538,16 @@ is
procedure add (Self : access Item; the_Sprite : in gel.Sprite.view;
and_Children : in Boolean := False)
is
added_Event : gel.remote.World.sprite_added_Event;
begin
gel.World.item (Self.all).add (the_Sprite); -- Do base class.
Self.all_Sprites.Map.add (the_Sprite);
added_Event.Sprite := the_Sprite.Id;
Self.emit (added_Event);
end add;
@@ -627,6 +649,41 @@ is
next (Cursor);
end loop;
end;
gel.World.item (Self).evolve;
-- -- Perform responses to events for all sprites.
-- --
-- declare
-- use id_Maps_of_sprite;
--
-- all_Sprites : constant id_Maps_of_sprite.Map := Item'Class (Self).all_Sprites.fetch;
-- Cursor : id_Maps_of_sprite.Cursor := all_Sprites.First;
-- the_Sprite : Sprite.view;
-- begin
-- while has_Element (Cursor)
-- loop
-- the_Sprite := Element (Cursor);
--
-- begin
-- if not the_Sprite.is_Destroyed
-- then
-- the_Sprite.respond;
-- end if;
--
-- exception
-- when E : others =>
-- log (""); log ("");
-- log ("Error in 'gel.World.client.evolve' sprite response.");
-- log ("");
-- log (ada.Exceptions.exception_Information (E));
-- log (""); log ("");
-- end;
--
-- next (Cursor);
-- end loop;
-- end;
end evolve;

View File

@@ -63,7 +63,12 @@ is
procedure motion_Updates_are (Self : in Item; seq_Id : in remote.World.sequence_Id;
Now : in remote.World.motion_Updates);
--
-- 'Self' must use 'in' as mode to ensure async transmission with DSA.
-- 'Self' must use 'in' mode to ensure async transmission with DSA.
----------
--- Events
--

View File

@@ -104,7 +104,7 @@ is
the_graphics_Model := openGL .Model.view (the_graphics_Models .Element (the_Pair.graphics_Model_Id));
the_physics_Model := physics.Model.view (the_physics_Models.Element (the_Pair. physics_Model_Id));
the_Sprite := gel.Sprite.forge.new_Sprite ("Sprite" & the_Pair.sprite_Id'Image,
the_Sprite := gel.Sprite.forge.new_Sprite ("2Sprite" & the_Pair.sprite_Id'Image,
sprite.World_view (the_World),
get_Translation (the_Pair.Transform),
the_graphics_Model,

View File

@@ -7,6 +7,7 @@ with
openGL.Renderer.lean,
lace.Response,
lace.Text.Forge,
ada.Text_IO,
ada.Exceptions,
@@ -96,10 +97,12 @@ is
use openGL;
begin
log ("gel.world.to_Sprite");
the_graphics_Model := openGL .Model.view (the_graphics_Models.Element (the_Pair.graphics_Model_Id));
the_physics_Model := physics.Model.view ( the_physics_Models.Element (the_Pair. physics_Model_Id));
the_Sprite := gel.Sprite.forge.new_Sprite ("Sprite" & the_Pair.sprite_Id'Image,
the_Sprite := gel.Sprite.forge.new_Sprite ("1Sprite" & the_Pair.sprite_Id'Image,
sprite.World_view (the_World),
get_Translation (the_Pair.Transform),
the_graphics_Model,
@@ -1030,7 +1033,8 @@ is
overriding
function Sprites (Self : in out Item) return remote.World.sprite_model_Pairs
is
use id_Maps_of_sprite;
use id_Maps_of_sprite,
lace.Text;
all_Sprites : constant id_Maps_of_sprite.Map := Item'Class (Self).all_Sprites.fetch;
Cursor : id_Maps_of_sprite.Cursor := all_Sprites.First;
@@ -1044,6 +1048,7 @@ is
the_Sprite := Element (Cursor);
the_Pairs (i) := (sprite_Id => the_Sprite.Id,
sprite_Name => lace.Text.forge.to_Text_64 (the_Sprite.Name),
graphics_model_Id => the_Sprite.graphics_Model.Id,
physics_model_Id => the_Sprite. physics_Model.Id,
Mass => the_Sprite.Mass,

View File

@@ -295,6 +295,8 @@ is
function local_physics_Models (Self : in Item) return id_Maps_of_physics_model.Map;
------------------
--- Testing/Debug
--