From bd5557cb67aa80a86cb5b36bb461be95c0b0fb6e Mon Sep 17 00:00:00 2001 From: Rod Kay Date: Mon, 24 Apr 2023 16:34:21 +1000 Subject: [PATCH] gel.sprite: Add 'user_Data'. --- 4-high/gel/source/forge/gel-forge.adb | 217 ++++++++++++++------------ 4-high/gel/source/forge/gel-forge.ads | 170 +++++++++++--------- 4-high/gel/source/gel-sprite.adb | 40 ++++- 4-high/gel/source/gel-sprite.ads | 38 +++-- 4 files changed, 271 insertions(+), 194 deletions(-) diff --git a/4-high/gel/source/forge/gel-forge.adb b/4-high/gel/source/forge/gel-forge.adb index d5335ec..55fc1fc 100644 --- a/4-high/gel/source/forge/gel-forge.adb +++ b/4-high/gel/source/forge/gel-forge.adb @@ -115,14 +115,15 @@ is -- 2D -- - function new_circle_Sprite (in_World : in gel.World.view; - Site : in math.Vector_2 := math.Origin_2D; - Mass : in math.Real := 1.0; - Friction : in math.Real := 0.5; - Bounce : in math.Real := 0.5; - Radius : in math.Real := 0.5; - Color : in openGL.Color := opengl.Palette.White; - Texture : in openGL.asset_Name := openGL.null_Asset) return gel.Sprite.view + function new_circle_Sprite (in_World : in gel.World.view; + Site : in math.Vector_2 := math.Origin_2D; + Mass : in math.Real := 1.0; + Friction : in math.Real := 0.5; + Bounce : in math.Real := 0.5; + Radius : in math.Real := 0.5; + Color : in openGL.Color := opengl.Palette.White; + Texture : in openGL.asset_Name := openGL.null_Asset; + user_Data : in any_user_Data_view := null) return gel.Sprite.view is use openGL; use type Vector_2; @@ -152,18 +153,20 @@ is the_physics_Model, owns_graphics => True, owns_physics => True, - is_Kinematic => False); + is_Kinematic => False, + user_Data => user_Data); end new_circle_Sprite; - function new_polygon_Sprite (in_World : in gel.World.view; - Site : in math.Vector_2 := math.Origin_2D; - Mass : in math.Real := 1.0; - Friction : in math.Real := 0.5; - Bounce : in math.Real := 0.5; - Vertices : in Geometry_2d.Sites; - Color : in openGL.Color := opengl.Palette.White) return gel.Sprite.view + function new_polygon_Sprite (in_World : in gel.World.view; + Site : in math.Vector_2 := math.Origin_2D; + Mass : in math.Real := 1.0; + Friction : in math.Real := 0.5; + Bounce : in math.Real := 0.5; + Vertices : in Geometry_2d.Sites; + Color : in openGL.Color := opengl.Palette.White; + user_Data : in any_user_Data_view := null) return gel.Sprite.view is use Math; use type Geometry_2d.Sites; @@ -190,19 +193,21 @@ is the_physics_Model, owns_graphics => True, owns_physics => True, - is_Kinematic => False); + is_Kinematic => False, + user_Data => user_Data); end new_polygon_Sprite; - function new_rectangle_Sprite (in_World : in gel.World.view; - Site : in math.Vector_2 := math.Origin_2D; - Mass : in math.Real := 1.0; - Friction : in math.Real := 0.5; - Bounce : in math.Real := 0.5; + function new_rectangle_Sprite (in_World : in gel.World.view; + Site : in math.Vector_2 := math.Origin_2D; + Mass : in math.Real := 1.0; + Friction : in math.Real := 0.5; + Bounce : in math.Real := 0.5; Width, - Height : in math.Real; - Color : in openGL.Color := opengl.Palette.White) return gel.Sprite.view + Height : in math.Real; + Color : in openGL.Color := opengl.Palette.White; + user_Data : in any_user_Data_view := null) return gel.Sprite.view is use Math; @@ -214,7 +219,7 @@ is [ half_Width, half_Height], [-half_Width, half_Height]]; begin - return new_polygon_Sprite (in_World, Site, Mass, Friction, Bounce, the_Vertices, Color); + return new_polygon_Sprite (in_World, Site, Mass, Friction, Bounce, the_Vertices, Color, user_Data); end new_rectangle_Sprite; @@ -223,14 +228,15 @@ is -- function new_ball_Sprite (in_World : in gel.World.view; - Site : in math.Vector_3 := math.Origin_3D; - Mass : in math.Real := 1.0; - Radius : in math.Real := 0.5; - lat_Count : in Positive := openGL.Model.sphere.default_latitude_Count; - long_Count : in Positive := openGL.Model.sphere.default_longitude_Count; - is_Lit : in Boolean := True; - Color : in openGL.lucid_Color := opengl.no_lucid_Color; - Texture : in openGL.asset_Name := openGL.null_Asset) return gel.Sprite.view + Site : in math.Vector_3 := math.Origin_3D; + Mass : in math.Real := 1.0; + Radius : in math.Real := 0.5; + lat_Count : in Positive := openGL.Model.sphere.default_latitude_Count; + long_Count : in Positive := openGL.Model.sphere.default_longitude_Count; + is_Lit : in Boolean := True; + Color : in openGL.lucid_Color := opengl.no_lucid_Color; + Texture : in openGL.asset_Name := openGL.null_Asset; + user_Data : in any_user_Data_view := null) return gel.Sprite.view is use type openGL.lucid_Color; @@ -268,15 +274,17 @@ is the_physics_Model, owns_Graphics => True, owns_Physics => True, - is_Kinematic => False); + is_Kinematic => False, + user_Data => user_Data); end new_ball_Sprite; - function new_skysphere_Sprite (in_World : in gel.World.view; - Site : in math.Vector_3 := math.Origin_3D; - Radius : in math.Real := 1_000_000.0; - Texture : in openGL.asset_Name) return gel.Sprite.view + function new_skysphere_Sprite (in_World : in gel.World.view; + Site : in math.Vector_3 := math.Origin_3D; + Radius : in math.Real := 1_000_000.0; + Texture : in openGL.asset_Name; + user_Data : in any_user_Data_view := null) return gel.Sprite.view is the_graphics_Model : openGL.Model.sphere.view; @@ -295,17 +303,19 @@ is the_physics_Model, owns_Graphics => True, owns_Physics => True, - is_Kinematic => False); + is_Kinematic => False, + user_Data => user_Data); end new_skysphere_Sprite; function new_box_Sprite (in_World : in gel.World.view; - Site : in math.Vector_3 := math.Origin_3D; - Mass : in math.Real := 1.0; - Size : in math.Vector_3 := [1.0, 1.0, 1.0]; - Colors : in box_Colors := [others => opengl.Palette.random_Color]; - is_Kinematic : in Boolean := False) return gel.Sprite.view + Site : in math.Vector_3 := math.Origin_3D; + Mass : in math.Real := 1.0; + Size : in math.Vector_3 := [1.0, 1.0, 1.0]; + Colors : in box_Colors := [others => opengl.Palette.random_Color]; + is_Kinematic : in Boolean := False; + user_Data : in any_user_Data_view := null) return gel.Sprite.view is use openGL.Model.box, openGL, @@ -332,18 +342,20 @@ is the_box_physics_Model, owns_Graphics => True, owns_Physics => True, - is_Kinematic => is_Kinematic); + is_Kinematic => is_Kinematic, + user_Data => user_Data); begin return the_Box; end new_box_Sprite; - function new_box_Sprite (in_World : in gel.World.view; - Site : in math.Vector_3 := math.Origin_3D; - Mass : in math.Real := 1.0; - Size : in math.Vector_3 := [1.0, 1.0, 1.0]; - Texture : in openGL.asset_Name) return gel.Sprite.view + function new_box_Sprite (in_World : in gel.World.view; + Site : in math.Vector_3 := math.Origin_3D; + Mass : in math.Real := 1.0; + Size : in math.Vector_3 := [1.0, 1.0, 1.0]; + Texture : in openGL.asset_Name; + user_Data : in any_user_Data_view := null) return gel.Sprite.view is use openGL.Model.box, Math; @@ -369,18 +381,20 @@ is the_box_physics_Model, owns_graphics => True, owns_physics => True, - is_Kinematic => False); + is_Kinematic => False, + user_Data => user_Data); begin return the_Box; end new_box_Sprite; - function new_billboard_Sprite (in_World : in gel.World.view; - Site : in math.Vector_3 := math.Origin_3D; - Mass : in math.Real := 1.0; - Size : in math.Vector_3 := [1.0, 1.0, 1.0]; - Texture : in openGL.asset_Name := openGL.null_Asset) return gel.Sprite.view + function new_billboard_Sprite (in_World : in gel.World.view; + Site : in math.Vector_3 := math.Origin_3D; + Mass : in math.Real := 1.0; + Size : in math.Vector_3 := [1.0, 1.0, 1.0]; + Texture : in openGL.asset_Name := openGL.null_Asset; + user_Data : in any_user_Data_view := null) return gel.Sprite.view is use Math; @@ -404,19 +418,21 @@ is the_billboard_physics_Model, owns_Graphics => True, owns_Physics => True, - is_Kinematic => False); + is_Kinematic => False, + user_Data => user_Data); begin return the_Billboard; end new_billboard_Sprite; - function new_billboard_Sprite (in_World : in gel.World.view; - Site : in math.Vector_3 := math.Origin_3D; - Color : in openGL.lucid_Color; - Mass : in math.Real := 1.0; - Size : in math.Vector_3 := [1.0, 1.0, 1.0]; - Texture : in openGL.asset_Name := openGL.null_Asset) return gel.Sprite.view + function new_billboard_Sprite (in_World : in gel.World.view; + Site : in math.Vector_3 := math.Origin_3D; + Color : in openGL.lucid_Color; + Mass : in math.Real := 1.0; + Size : in math.Vector_3 := [1.0, 1.0, 1.0]; + Texture : in openGL.asset_Name := openGL.null_Asset; + user_Data : in any_user_Data_view := null) return gel.Sprite.view is use Math; @@ -439,20 +455,22 @@ is the_billboard_physics_Model, owns_Graphics => True, owns_Physics => True, - is_Kinematic => False); + is_Kinematic => False, + user_Data => user_Data); begin return the_Billboard; end new_billboard_Sprite; - function new_arrow_Sprite (in_World : in gel.World.view; - Site : in math.Vector_3 := math.Origin_3D; - Mass : in math.Real := 0.0; - Size : in math.Vector_3 := [1.0, 1.0, 1.0]; - Texture : in openGL.asset_Name := openGL.null_Asset; - Color : in openGL.lucid_Color := (openGL.Palette.Black, openGL.Opaque); - line_Width : in openGL.Real := openGL.Primitive.unused_line_Width) return gel.Sprite.view + function new_arrow_Sprite (in_World : in gel.World.view; + Site : in math.Vector_3 := math.Origin_3D; + Mass : in math.Real := 0.0; + Size : in math.Vector_3 := [1.0, 1.0, 1.0]; + Texture : in openGL.asset_Name := openGL.null_Asset; + Color : in openGL.lucid_Color := (openGL.Palette.Black, openGL.Opaque); + line_Width : in openGL.Real := openGL.Primitive.unused_line_Width; + user_Data : in any_user_Data_view := null) return gel.Sprite.view is pragma Unreferenced (Texture); use Math; @@ -474,20 +492,22 @@ is the_physics_Model, owns_Graphics => True, owns_Physics => True, - is_Kinematic => False); + is_Kinematic => False, + user_Data => user_Data); begin return the_Arrow; end new_arrow_Sprite; - function new_line_Sprite (in_World : in gel.World.view; - Site : in math.Vector_3 := math.Origin_3D; - Mass : in math.Real := 0.0; - Size : in math.Vector_3 := [1.0, 1.0, 1.0]; - Texture : in openGL.asset_Name := openGL.null_Asset; - Color : in openGL.lucid_Color := (openGL.Palette.Black, openGL.Opaque); - line_Width : in openGL.Real := openGL.Primitive.unused_line_Width) return gel.Sprite.view + function new_line_Sprite (in_World : in gel.World.view; + Site : in math.Vector_3 := math.Origin_3D; + Mass : in math.Real := 0.0; + Size : in math.Vector_3 := [1.0, 1.0, 1.0]; + Texture : in openGL.asset_Name := openGL.null_Asset; + Color : in openGL.lucid_Color := (openGL.Palette.Black, openGL.Opaque); + line_Width : in openGL.Real := openGL.Primitive.unused_line_Width; + user_Data : in any_user_Data_view := null) return gel.Sprite.view is pragma Unreferenced (Texture, line_Width); use Math; @@ -508,20 +528,22 @@ is the_physics_Model, owns_Graphics => True, owns_Physics => True, - is_Kinematic => False); + is_Kinematic => False, + user_Data => user_Data); begin return the_Line; end new_line_Sprite; - function new_segment_line_Sprite (in_World : in gel.World.view; - Site : in math.Vector_3 := math.Origin_3D; - Mass : in math.Real := 0.0; - Size : in math.Vector_3 := [1.0, 1.0, 1.0]; - Texture : in openGL.asset_Name := openGL.null_Asset; - Color : in openGL.lucid_Color := (openGL.Palette.Black, openGL.Opaque); - line_Width : in openGL.Real := openGL.Primitive.unused_line_Width) return gel.Sprite.view + function new_segment_line_Sprite (in_World : in gel.World.view; + Site : in math.Vector_3 := math.Origin_3D; + Mass : in math.Real := 0.0; + Size : in math.Vector_3 := [1.0, 1.0, 1.0]; + Texture : in openGL.asset_Name := openGL.null_Asset; + Color : in openGL.lucid_Color := (openGL.Palette.Black, openGL.Opaque); + line_Width : in openGL.Real := openGL.Primitive.unused_line_Width; + user_Data : in any_user_Data_view := null) return gel.Sprite.view is pragma Unreferenced (Texture, line_Width); use Math; @@ -541,7 +563,8 @@ is the_physics_Model, owns_Graphics => True, owns_Physics => True, - is_Kinematic => False); + is_Kinematic => False, + user_Data => user_Data); begin return the_Line; end new_segment_line_Sprite; @@ -551,13 +574,14 @@ is -- Text -- - function new_text_Sprite (in_World : in gel.World.view; - Site : in math.Vector_3 := math.Origin_3D; - Text : in String; - Font : in openGL.Font.font_Id; - Color : in openGL.Color := opengl.Palette.Black; - Size : in math.Vector_3 := [1.0, 1.0, 1.0]; - Centered : in Boolean := True) return gel.Sprite.view + function new_text_Sprite (in_World : in gel.World.view; + Site : in math.Vector_3 := math.Origin_3D; + Text : in String; + Font : in openGL.Font.font_Id; + Color : in openGL.Color := opengl.Palette.Black; + Size : in math.Vector_3 := [1.0, 1.0, 1.0]; + Centered : in Boolean := True; + user_Data : in any_user_Data_view := null) return gel.Sprite.view is use Math; use type Physics.space_Kind; @@ -597,7 +621,8 @@ is the_physics_Model, owns_Graphics => True, owns_Physics => True, - is_Kinematic => False); + is_Kinematic => False, + user_Data => user_Data); end new_text_Sprite; diff --git a/4-high/gel/source/forge/gel-forge.ads b/4-high/gel/source/forge/gel-forge.ads index 4a94c04..7e19192 100644 --- a/4-high/gel/source/forge/gel-forge.ads +++ b/4-high/gel/source/forge/gel-forge.ads @@ -47,34 +47,40 @@ is --- Sprites -- + use gel.Sprite; + + -- 2D -- - function new_circle_Sprite (in_World : in gel.World.view; - Site : in math.Vector_2 := math.Origin_2D; - Mass : in math.Real := 1.0; - Friction : in math.Real := 0.5; - Bounce : in math.Real := 0.5; - Radius : in math.Real := 0.5; - Color : in openGL.Color := opengl.Palette.White; - Texture : in openGL.asset_Name := openGL.null_Asset) return gel.Sprite.view; + function new_circle_Sprite (in_World : in gel.World.view; + Site : in math.Vector_2 := math.Origin_2D; + Mass : in math.Real := 1.0; + Friction : in math.Real := 0.5; + Bounce : in math.Real := 0.5; + Radius : in math.Real := 0.5; + Color : in openGL.Color := opengl.Palette.White; + Texture : in openGL.asset_Name := openGL.null_Asset; + user_Data : in any_user_Data_view := null) return gel.Sprite.view; - function new_polygon_Sprite (in_World : in gel.World.view; - Site : in math.Vector_2 := math.Origin_2D; - Mass : in math.Real := 1.0; - Friction : in math.Real := 0.5; - Bounce : in math.Real := 0.5; - Vertices : in Geometry_2d.Sites; - Color : in openGL.Color := opengl.Palette.White) return gel.Sprite.view; + function new_polygon_Sprite (in_World : in gel.World.view; + Site : in math.Vector_2 := math.Origin_2D; + Mass : in math.Real := 1.0; + Friction : in math.Real := 0.5; + Bounce : in math.Real := 0.5; + Vertices : in Geometry_2d.Sites; + Color : in openGL.Color := opengl.Palette.White; + user_Data : in any_user_Data_view := null) return gel.Sprite.view; - function new_rectangle_Sprite (in_World : in gel.World.view; - Site : in math.Vector_2 := math.Origin_2D; - Mass : in math.Real := 1.0; - Friction : in math.Real := 0.5; - Bounce : in math.Real := 0.5; + function new_rectangle_Sprite (in_World : in gel.World.view; + Site : in math.Vector_2 := math.Origin_2D; + Mass : in math.Real := 1.0; + Friction : in math.Real := 0.5; + Bounce : in math.Real := 0.5; Width, - Height : in math.Real; - Color : in openGL.Color := opengl.Palette.White) return gel.Sprite.view; + Height : in math.Real; + Color : in openGL.Color := opengl.Palette.White; + user_Data : in any_user_Data_view := null) return gel.Sprite.view; -- 3D -- @@ -86,74 +92,84 @@ is long_Count : in Positive := openGL.Model.sphere.default_longitude_Count; is_Lit : in Boolean := True; Color : in openGL.lucid_Color := opengl.no_lucid_Color; - Texture : in openGL.asset_Name := openGL.null_Asset) return gel.Sprite.view; + Texture : in openGL.asset_Name := openGL.null_Asset; + user_Data : in any_user_Data_view := null) return gel.Sprite.view; - function new_skysphere_Sprite (in_World : in gel.World.view; - Site : in math.Vector_3 := math.Origin_3D; - Radius : in math.Real := 1_000_000.0; - Texture : in openGL.asset_Name) return gel.Sprite.view; + function new_skysphere_Sprite (in_World : in gel.World.view; + Site : in math.Vector_3 := math.Origin_3D; + Radius : in math.Real := 1_000_000.0; + Texture : in openGL.asset_Name; + user_Data : in any_user_Data_view := null) return gel.Sprite.view; subtype box_Colors is openGL.Colors (1 .. 6); - function new_box_Sprite (in_World : in gel.World.view; - Site : in math.Vector_3 := math.Origin_3D; - Mass : in math.Real := 1.0; - Size : in math.Vector_3 := [1.0, 1.0, 1.0]; - Colors : in box_Colors := [others => opengl.Palette.random_Color]; - is_Kinematic : in Boolean := False) return gel.Sprite.view; + function new_box_Sprite (in_World : in gel.World.view; + Site : in math.Vector_3 := math.Origin_3D; + Mass : in math.Real := 1.0; + Size : in math.Vector_3 := [1.0, 1.0, 1.0]; + Colors : in box_Colors := [others => opengl.Palette.random_Color]; + is_Kinematic : in Boolean := False; + user_Data : in any_user_Data_view := null) return gel.Sprite.view; - function new_box_Sprite (in_World : in gel.World.view; - Site : in math.Vector_3 := math.Origin_3D; - Mass : in math.Real := 1.0; - Size : in math.Vector_3 := [1.0, 1.0, 1.0]; - Texture : in openGL.asset_Name) return gel.Sprite.view; + function new_box_Sprite (in_World : in gel.World.view; + Site : in math.Vector_3 := math.Origin_3D; + Mass : in math.Real := 1.0; + Size : in math.Vector_3 := [1.0, 1.0, 1.0]; + Texture : in openGL.asset_Name; + user_Data : in any_user_Data_view := null) return gel.Sprite.view; - function new_billboard_Sprite (in_World : in gel.World.view; - Site : in math.Vector_3 := math.Origin_3D; - Mass : in math.Real := 1.0; - Size : in math.Vector_3 := [1.0, 1.0, 1.0]; - Texture : in openGL.asset_Name := openGL.null_Asset) return gel.Sprite.view; + function new_billboard_Sprite (in_World : in gel.World.view; + Site : in math.Vector_3 := math.Origin_3D; + Mass : in math.Real := 1.0; + Size : in math.Vector_3 := [1.0, 1.0, 1.0]; + Texture : in openGL.asset_Name := openGL.null_Asset; + user_Data : in any_user_Data_view := null) return gel.Sprite.view; - function new_billboard_Sprite (in_World : in gel.World.view; - Site : in math.Vector_3 := math.Origin_3D; - Color : in openGL.lucid_Color; - Mass : in math.Real := 1.0; - Size : in math.Vector_3 := [1.0, 1.0, 1.0]; - Texture : in openGL.asset_Name := openGL.null_Asset) return gel.Sprite.view; + function new_billboard_Sprite (in_World : in gel.World.view; + Site : in math.Vector_3 := math.Origin_3D; + Color : in openGL.lucid_Color; + Mass : in math.Real := 1.0; + Size : in math.Vector_3 := [1.0, 1.0, 1.0]; + Texture : in openGL.asset_Name := openGL.null_Asset; + user_Data : in any_user_Data_view := null) return gel.Sprite.view; - function new_arrow_Sprite (in_World : in gel.World.view; - Site : in math.Vector_3 := math.Origin_3D; - Mass : in math.Real := 0.0; - Size : in math.Vector_3 := [1.0, 1.0, 1.0]; - Texture : in openGL.asset_Name := openGL.null_Asset; - Color : in openGL.lucid_Color := (openGL.Palette.Black, openGL.Opaque); - line_Width : in openGL.Real := openGL.Primitive.unused_line_Width) return gel.Sprite.view; + function new_arrow_Sprite (in_World : in gel.World.view; + Site : in math.Vector_3 := math.Origin_3D; + Mass : in math.Real := 0.0; + Size : in math.Vector_3 := [1.0, 1.0, 1.0]; + Texture : in openGL.asset_Name := openGL.null_Asset; + Color : in openGL.lucid_Color := (openGL.Palette.Black, openGL.Opaque); + line_Width : in openGL.Real := openGL.Primitive.unused_line_Width; + user_Data : in any_user_Data_view := null) return gel.Sprite.view; - function new_line_Sprite (in_World : in gel.World.view; - Site : in math.Vector_3 := math.Origin_3D; - Mass : in math.Real := 0.0; - Size : in math.Vector_3 := [1.0, 1.0, 1.0]; - Texture : in openGL.asset_Name := openGL.null_Asset; - Color : in openGL.lucid_Color := (openGL.Palette.Black, openGL.Opaque); - line_Width : in openGL.Real := openGL.Primitive.unused_line_Width) return gel.Sprite.view; + function new_line_Sprite (in_World : in gel.World.view; + Site : in math.Vector_3 := math.Origin_3D; + Mass : in math.Real := 0.0; + Size : in math.Vector_3 := [1.0, 1.0, 1.0]; + Texture : in openGL.asset_Name := openGL.null_Asset; + Color : in openGL.lucid_Color := (openGL.Palette.Black, openGL.Opaque); + line_Width : in openGL.Real := openGL.Primitive.unused_line_Width; + user_Data : in any_user_Data_view := null) return gel.Sprite.view; - function new_segment_line_Sprite (in_World : in gel.World.view; - Site : in math.Vector_3 := math.Origin_3D; - Mass : in math.Real := 0.0; - Size : in math.Vector_3 := [1.0, 1.0, 1.0]; - Texture : in openGL.asset_Name := openGL.null_Asset; - Color : in openGL.lucid_Color := (openGL.Palette.Black, openGL.Opaque); - line_Width : in openGL.Real := openGL.Primitive.unused_line_Width) return gel.Sprite.view; + function new_segment_line_Sprite (in_World : in gel.World.view; + Site : in math.Vector_3 := math.Origin_3D; + Mass : in math.Real := 0.0; + Size : in math.Vector_3 := [1.0, 1.0, 1.0]; + Texture : in openGL.asset_Name := openGL.null_Asset; + Color : in openGL.lucid_Color := (openGL.Palette.Black, openGL.Opaque); + line_Width : in openGL.Real := openGL.Primitive.unused_line_Width; + user_Data : in any_user_Data_view := null) return gel.Sprite.view; -- Text -- - function new_text_Sprite (in_World : in gel.World.view; - Site : in math.Vector_3 := math.Origin_3D; - Text : in String; - Font : in openGL.Font.font_Id; - Color : in openGL.Color := opengl.Palette.Black; - Size : in math.Vector_3 := [1.0, 1.0, 1.0]; - Centered : in Boolean := True) return gel.Sprite.view; + function new_text_Sprite (in_World : in gel.World.view; + Site : in math.Vector_3 := math.Origin_3D; + Text : in String; + Font : in openGL.Font.font_Id; + Color : in openGL.Color := opengl.Palette.Black; + Size : in math.Vector_3 := [1.0, 1.0, 1.0]; + Centered : in Boolean := True; + user_Data : in any_user_Data_view := null) return gel.Sprite.view; end gel.Forge; diff --git a/4-high/gel/source/gel-sprite.adb b/4-high/gel/source/gel-sprite.adb index 06e365a..c0b9768 100644 --- a/4-high/gel/source/gel-sprite.adb +++ b/4-high/gel/source/gel-sprite.adb @@ -107,7 +107,8 @@ is physics_Model : access physics.Model.item'Class; owns_Graphics : in Boolean; owns_Physics : in Boolean; - is_Kinematic : in Boolean := False) + is_Kinematic : in Boolean := False; + user_Data : in any_user_Data_view := null) is use type physics.Model.view; begin @@ -120,6 +121,8 @@ is Self.owns_Physics := owns_Physics; Self.is_Kinematic := is_Kinematic; + Self.user_Data := user_Data; + -- set_Translation (Self.Transform, To => physics_Model.Site); -- Physics @@ -128,7 +131,6 @@ is then Self.rebuild_Shape; Self.rebuild_Solid (at_Site); - null; end if; end define; @@ -228,13 +230,14 @@ is physics_Model : access physics.Model.item'Class; owns_Graphics : in Boolean; owns_Physics : in Boolean; - is_Kinematic : in Boolean := False) return Item + is_Kinematic : in Boolean := False; + user_Data : in any_user_Data_view := null) return Item is begin return Self : Item := (lace.Subject_and_deferred_Observer.forge.to_Subject_and_Observer (Name) with others => <>) do - Self.define (World, at_Site, graphics_Model, physics_Model, owns_Graphics, owns_Physics, is_Kinematic); + Self.define (World, at_Site, graphics_Model, physics_Model, owns_Graphics, owns_Physics, is_Kinematic, user_Data); end return; end to_Sprite; @@ -245,9 +248,10 @@ is at_Site : in Vector_3; graphics_Model : access openGL. Model.item'Class; physics_Model : access physics.Model.item'Class; - owns_Graphics : in Boolean := True; - owns_Physics : in Boolean := True; - is_Kinematic : in Boolean := False) return View + owns_Graphics : in Boolean := True; + owns_Physics : in Boolean := True; + is_Kinematic : in Boolean := False; + user_Data : in any_user_Data_view := null) return View is Self : constant View := new Item' (to_Sprite (Name, World, @@ -256,8 +260,10 @@ is physics_Model, owns_Graphics, owns_Physics, - is_Kinematic)); + is_Kinematic, + user_Data => user_Data)); begin + return Self; end new_Sprite; @@ -469,6 +475,24 @@ is end Shape; + + function user_Data (Self : in Item) return any_user_Data_view + is + begin + return Self.user_Data; + end user_Data; + + + + procedure user_Data_is (Self : in out Item; Now : in any_user_Data_view) + is + begin + Self.user_Data := Now; + end user_Data_is; + + + + ------------- --- Dynamics -- diff --git a/4-high/gel/source/gel-sprite.ads b/4-high/gel/source/gel-sprite.ads index 419d2dd..cfadf40 100644 --- a/4-high/gel/source/gel-sprite.ads +++ b/4-high/gel/source/gel-sprite.ads @@ -12,6 +12,7 @@ with lace.Subject_and_deferred_Observer, lace.Response, + lace.Any, ada.Containers.Vectors; @@ -35,7 +36,10 @@ is type physics_Space_view is access all physics.Space.item'Class; - type World_view is access all gel.World.item'Class; + type World_view is access all gel.World .item'Class; + + type any_user_Data is new lace.Any.limited_item with null record; + type any_user_Data_view is access all any_user_Data'Class; use Math; @@ -56,13 +60,14 @@ is --- Forge -- - procedure define (Self : access Item; World : in World_view; - at_Site : in Vector_3; - graphics_Model : access openGL. Model.item'Class; - physics_Model : access physics.Model.item'Class; - owns_Graphics : in Boolean; - owns_Physics : in Boolean; - is_Kinematic : in Boolean := False); + procedure define (Self : access Item; World : in World_view; + at_Site : in Vector_3; + graphics_Model : access openGL. Model.item'Class; + physics_Model : access physics.Model.item'Class; + owns_Graphics : in Boolean; + owns_Physics : in Boolean; + is_Kinematic : in Boolean := False; + user_Data : in any_user_Data_view := null); procedure destroy (Self : access Item; and_Children : in Boolean); function is_Destroyed (Self : in Item) return Boolean; @@ -78,16 +83,18 @@ is physics_Model : access physics.Model.item'Class; owns_Graphics : in Boolean; owns_Physics : in Boolean; - is_Kinematic : in Boolean := False) return Item; + is_Kinematic : in Boolean := False; + user_Data : in any_user_Data_view := null) return Item; function new_Sprite (Name : in String; World : in World_view; at_Site : in Vector_3; graphics_Model : access openGL. Model.item'Class; physics_Model : access physics.Model.item'Class; - owns_Graphics : in Boolean := True; - owns_Physics : in Boolean := True; - is_Kinematic : in Boolean := False) return View; + owns_Graphics : in Boolean := True; + owns_Physics : in Boolean := True; + is_Kinematic : in Boolean := False; + user_Data : in any_user_Data_view := null) return View; end Forge; @@ -95,7 +102,7 @@ is --- Attributes -- - function World (Self : in Item) return access gel.World.item'Class; + function World (Self : in Item) return access gel.World.item'Class; function Id (Self : in Item) return gel.sprite_Id; procedure Id_is (Self : in out Item; Now : in gel.sprite_Id); @@ -140,6 +147,10 @@ is function to_GEL (the_Solid : in physics_Object_view) return gel.Sprite.view; + function user_Data (Self : in Item) return any_user_Data_view; + procedure user_Data_is (Self : in out Item; Now : in any_user_Data_view); + + ------------- --- Dynamics -- @@ -406,6 +417,7 @@ private is_Visible : Boolean := True; key_Response : lace.Response.view; + user_Data : any_user_Data_view; is_Destroyed : Boolean := False; end record;