gel.world: Fix sprite naming.
This commit is contained in:
@@ -123,6 +123,7 @@ is
|
|||||||
--
|
--
|
||||||
|
|
||||||
function new_circle_Sprite (in_World : in gel.World.view;
|
function new_circle_Sprite (in_World : in gel.World.view;
|
||||||
|
Name : in String;
|
||||||
Site : in math.Vector_3 := math.Origin_3D;
|
Site : in math.Vector_3 := math.Origin_3D;
|
||||||
Mass : in math.Real := 1.0;
|
Mass : in math.Real := 1.0;
|
||||||
Friction : in math.Real := 0.5;
|
Friction : in math.Real := 0.5;
|
||||||
@@ -158,7 +159,7 @@ is
|
|||||||
texture_Count => 1)).all'Access;
|
texture_Count => 1)).all'Access;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
return gel.Sprite.Forge.new_Sprite ("circle_Sprite",
|
return gel.Sprite.Forge.new_Sprite (Name,
|
||||||
sprite.World_view (in_World),
|
sprite.World_view (in_World),
|
||||||
Site,
|
Site,
|
||||||
the_graphics_Model,
|
the_graphics_Model,
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ is
|
|||||||
--
|
--
|
||||||
|
|
||||||
function new_circle_Sprite (in_World : in gel.World.view;
|
function new_circle_Sprite (in_World : in gel.World.view;
|
||||||
|
Name : in String;
|
||||||
Site : in math.Vector_3 := math.Origin_3D;
|
Site : in math.Vector_3 := math.Origin_3D;
|
||||||
Mass : in math.Real := 1.0;
|
Mass : in math.Real := 1.0;
|
||||||
Friction : in math.Real := 0.5;
|
Friction : in math.Real := 0.5;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ with
|
|||||||
lace.Observer,
|
lace.Observer,
|
||||||
lace.Subject,
|
lace.Subject,
|
||||||
lace.Event,
|
lace.Event,
|
||||||
|
lace.Text,
|
||||||
|
|
||||||
ada.unchecked_Conversion,
|
ada.unchecked_Conversion,
|
||||||
ada.Containers.indefinite_hashed_Maps,
|
ada.Containers.indefinite_hashed_Maps,
|
||||||
@@ -114,6 +115,7 @@ is
|
|||||||
type sprite_model_Pair is
|
type sprite_model_Pair is
|
||||||
record
|
record
|
||||||
sprite_Id : gel .sprite_Id;
|
sprite_Id : gel .sprite_Id;
|
||||||
|
sprite_Name : lace.Text.item_64;
|
||||||
graphics_model_Id : openGL .model_Id;
|
graphics_model_Id : openGL .model_Id;
|
||||||
physics_model_Id : physics.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
|
-- Test/Debug
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -9,8 +9,10 @@ with
|
|||||||
|
|
||||||
lace.Response,
|
lace.Response,
|
||||||
lace.Event.utility,
|
lace.Event.utility,
|
||||||
|
lace.Text,
|
||||||
|
|
||||||
ada.unchecked_Deallocation,
|
ada.unchecked_Deallocation,
|
||||||
|
ada.Exceptions,
|
||||||
ada.Text_IO;
|
ada.Text_IO;
|
||||||
|
|
||||||
|
|
||||||
@@ -96,11 +98,13 @@ is
|
|||||||
the_physics_Models : in Id_Maps_of_physics_Model .Map;
|
the_physics_Models : in Id_Maps_of_physics_Model .Map;
|
||||||
the_World : in gel.World.view) return gel.Sprite.view
|
the_World : in gel.World.view) return gel.Sprite.view
|
||||||
is
|
is
|
||||||
|
use openGL,
|
||||||
|
lace.Text;
|
||||||
|
|
||||||
the_graphics_Model : access openGL .Model.item'Class;
|
the_graphics_Model : access openGL .Model.item'Class;
|
||||||
the_physics_Model : access physics.Model.item'Class;
|
the_physics_Model : access physics.Model.item'Class;
|
||||||
the_Sprite : gel.Sprite.view;
|
the_Sprite : gel.Sprite.view;
|
||||||
|
|
||||||
use openGL;
|
|
||||||
begin
|
begin
|
||||||
-- log ("gel.world.client.to_Sprite ~ the_Pair.graphics_Model_Id:" & the_Pair.graphics_Model_Id'Image);
|
-- 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_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),
|
sprite.World_view (the_World),
|
||||||
get_Translation (the_Pair.Transform),
|
get_Translation (the_Pair.Transform),
|
||||||
the_graphics_Model,
|
the_graphics_Model,
|
||||||
@@ -132,6 +136,8 @@ is
|
|||||||
-- the_Sprite.desired_Site_is (the_Sprite.Site);
|
-- the_Sprite.desired_Site_is (the_Sprite.Site);
|
||||||
-- the_Sprite.desired_Spin_is (to_Quaternion (get_Rotation (the_Sprite.Transform)));
|
-- the_Sprite.desired_Spin_is (to_Quaternion (get_Rotation (the_Sprite.Transform)));
|
||||||
|
|
||||||
|
log ("gel.world.client.to_Sprite");
|
||||||
|
|
||||||
return the_Sprite;
|
return the_Sprite;
|
||||||
end to_Sprite;
|
end to_Sprite;
|
||||||
|
|
||||||
@@ -292,7 +298,6 @@ is
|
|||||||
function Name (Self : in my_new_sprite_Response) return String;
|
function Name (Self : in my_new_sprite_Response) return String;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
overriding
|
overriding
|
||||||
procedure respond (Self : in out my_new_sprite_Response; to_Event : in lace.Event.Item'Class)
|
procedure respond (Self : in out my_new_sprite_Response; to_Event : in lace.Event.Item'Class)
|
||||||
is
|
is
|
||||||
@@ -306,10 +311,15 @@ is
|
|||||||
the_Sprite : constant gel.Sprite.view
|
the_Sprite : constant gel.Sprite.view
|
||||||
:= to_Sprite (the_Event.Pair,
|
:= to_Sprite (the_Event.Pair,
|
||||||
Self.graphics_Models.all,
|
Self.graphics_Models.all,
|
||||||
Self.physics_Models.all,
|
Self. physics_Models.all,
|
||||||
Self.World);
|
Self.World);
|
||||||
|
added_Event : gel.remote.World.sprite_added_Event;
|
||||||
begin
|
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;
|
||||||
|
|
||||||
end respond;
|
end respond;
|
||||||
@@ -458,7 +468,7 @@ is
|
|||||||
use remote.World.id_Maps_of_graphics_model;
|
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_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
|
begin
|
||||||
-- Create our local graphics graphics_Models.
|
-- Create our local graphics graphics_Models.
|
||||||
--
|
--
|
||||||
@@ -498,6 +508,7 @@ is
|
|||||||
declare
|
declare
|
||||||
the_Sprite : gel.Sprite.view;
|
the_Sprite : gel.Sprite.view;
|
||||||
the_server_Sprites : constant remote.World.sprite_model_Pairs := of_World.Sprites;
|
the_server_Sprites : constant remote.World.sprite_model_Pairs := of_World.Sprites;
|
||||||
|
-- kkk : gel.remote.World.sprite_added_Event;
|
||||||
begin
|
begin
|
||||||
for i in the_server_Sprites'Range
|
for i in the_server_Sprites'Range
|
||||||
loop
|
loop
|
||||||
@@ -505,7 +516,10 @@ is
|
|||||||
Self.graphics_Models,
|
Self.graphics_Models,
|
||||||
Self. physics_Models,
|
Self. physics_Models,
|
||||||
gel.World.view (Self));
|
gel.World.view (Self));
|
||||||
|
log ("k1");
|
||||||
Self.add (the_Sprite);
|
Self.add (the_Sprite);
|
||||||
|
-- Self.emit (sprite_added_Event' (Sprite => the_Sprite.Id));
|
||||||
|
-- Self.emit (sprite_added_Event' (kkk));
|
||||||
end loop;
|
end loop;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@@ -524,8 +538,16 @@ is
|
|||||||
procedure add (Self : access Item; the_Sprite : in gel.Sprite.view;
|
procedure add (Self : access Item; the_Sprite : in gel.Sprite.view;
|
||||||
and_Children : in Boolean := False)
|
and_Children : in Boolean := False)
|
||||||
is
|
is
|
||||||
|
added_Event : gel.remote.World.sprite_added_Event;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
gel.World.item (Self.all).add (the_Sprite); -- Do base class.
|
||||||
Self.all_Sprites.Map.add (the_Sprite);
|
Self.all_Sprites.Map.add (the_Sprite);
|
||||||
|
|
||||||
|
added_Event.Sprite := the_Sprite.Id;
|
||||||
|
Self.emit (added_Event);
|
||||||
|
|
||||||
|
|
||||||
end add;
|
end add;
|
||||||
|
|
||||||
|
|
||||||
@@ -627,6 +649,41 @@ is
|
|||||||
next (Cursor);
|
next (Cursor);
|
||||||
end loop;
|
end loop;
|
||||||
end;
|
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;
|
end evolve;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,12 @@ is
|
|||||||
procedure motion_Updates_are (Self : in Item; seq_Id : in remote.World.sequence_Id;
|
procedure motion_Updates_are (Self : in Item; seq_Id : in remote.World.sequence_Id;
|
||||||
Now : in remote.World.motion_Updates);
|
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
|
||||||
|
--
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ is
|
|||||||
the_graphics_Model := openGL .Model.view (the_graphics_Models .Element (the_Pair.graphics_Model_Id));
|
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_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),
|
sprite.World_view (the_World),
|
||||||
get_Translation (the_Pair.Transform),
|
get_Translation (the_Pair.Transform),
|
||||||
the_graphics_Model,
|
the_graphics_Model,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ with
|
|||||||
openGL.Renderer.lean,
|
openGL.Renderer.lean,
|
||||||
|
|
||||||
lace.Response,
|
lace.Response,
|
||||||
|
lace.Text.Forge,
|
||||||
|
|
||||||
ada.Text_IO,
|
ada.Text_IO,
|
||||||
ada.Exceptions,
|
ada.Exceptions,
|
||||||
@@ -96,10 +97,12 @@ is
|
|||||||
|
|
||||||
use openGL;
|
use openGL;
|
||||||
begin
|
begin
|
||||||
|
log ("gel.world.to_Sprite");
|
||||||
|
|
||||||
the_graphics_Model := openGL .Model.view (the_graphics_Models.Element (the_Pair.graphics_Model_Id));
|
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_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),
|
sprite.World_view (the_World),
|
||||||
get_Translation (the_Pair.Transform),
|
get_Translation (the_Pair.Transform),
|
||||||
the_graphics_Model,
|
the_graphics_Model,
|
||||||
@@ -1030,7 +1033,8 @@ is
|
|||||||
overriding
|
overriding
|
||||||
function Sprites (Self : in out Item) return remote.World.sprite_model_Pairs
|
function Sprites (Self : in out Item) return remote.World.sprite_model_Pairs
|
||||||
is
|
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;
|
all_Sprites : constant id_Maps_of_sprite.Map := Item'Class (Self).all_Sprites.fetch;
|
||||||
Cursor : id_Maps_of_sprite.Cursor := all_Sprites.First;
|
Cursor : id_Maps_of_sprite.Cursor := all_Sprites.First;
|
||||||
@@ -1044,6 +1048,7 @@ is
|
|||||||
the_Sprite := Element (Cursor);
|
the_Sprite := Element (Cursor);
|
||||||
|
|
||||||
the_Pairs (i) := (sprite_Id => the_Sprite.Id,
|
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,
|
graphics_model_Id => the_Sprite.graphics_Model.Id,
|
||||||
physics_model_Id => the_Sprite. physics_Model.Id,
|
physics_model_Id => the_Sprite. physics_Model.Id,
|
||||||
Mass => the_Sprite.Mass,
|
Mass => the_Sprite.Mass,
|
||||||
|
|||||||
@@ -295,6 +295,8 @@ is
|
|||||||
function local_physics_Models (Self : in Item) return id_Maps_of_physics_model.Map;
|
function local_physics_Models (Self : in Item) return id_Maps_of_physics_model.Map;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
------------------
|
------------------
|
||||||
--- Testing/Debug
|
--- Testing/Debug
|
||||||
--
|
--
|
||||||
|
|||||||
Reference in New Issue
Block a user