opengl: Add texture animation.

This commit is contained in:
Rod Kay
2024-09-24 13:45:18 +10:00
parent d0e3870346
commit ab36317bd2
11 changed files with 259 additions and 54 deletions

View File

@@ -91,6 +91,22 @@ is
overriding
procedure animate (Self : in out Item)
is
use type texture_Set.Animation_view;
begin
if Self.Face.Animation = null
then
return;
end if;
texture_Set.animate (Self.Face.Animation.all,
Self.Face.texture_Applies);
end animate;
---------------------
--- openGL Geometries
--

View File

@@ -15,9 +15,10 @@ is
type Face is
record
Fades : texture_Set.fade_Levels (texture_Set.texture_Id) := [others => 0.0];
texture_Applies : texture_Set.texture_Apply_array := [others => True];
Textures : openGL.asset_Names (1 .. Positive (texture_Set.texture_Id'Last)) := [others => null_Asset]; -- The textures to be applied to the hex.
texture_Count : Natural := 0;
texture_Count : Natural := 0;
texture_Applies : texture_Set.texture_Apply_array := [others => True];
Animation : texture_Set.Animation_view;
end record;
@@ -43,17 +44,17 @@ is
--
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level);
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level);
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in asset_Name);
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in asset_Name);
overriding
function texture_Count (Self : in Item) return Natural;
function texture_Count (Self : in Item) return Natural;
overriding
@@ -63,6 +64,10 @@ is
procedure texture_Applied_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in Boolean);
overriding
procedure animate (Self : in out Item);
private

View File

@@ -90,6 +90,25 @@ is
overriding
procedure animate (Self : in out Item)
is
use type texture_Set.Animation_view;
begin
if Self.Face.Animation = null
then
return;
end if;
texture_Set.animate (Self.Face.Animation.all,
Self.Face.texture_Applies);
end animate;
---------------------
--- openGL Geometries
--
overriding
function to_GL_Geometries (Self : access Item; Textures : access Texture.name_Map_of_texture'Class;

View File

@@ -18,6 +18,7 @@ is
Textures : openGL.asset_Names (1 .. Positive (texture_Set.texture_Id'Last)) := [others => null_Asset]; -- The textures to be applied to the hex.
texture_Count : Natural := 0;
texture_Applies : texture_Set.texture_Apply_array := [others => True];
Animation : texture_Set.Animation_view;
end record;
@@ -42,17 +43,17 @@ is
--
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level);
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level);
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in asset_Name);
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in asset_Name);
overriding
function texture_Count (Self : in Item) return Natural;
function texture_Count (Self : in Item) return Natural;
overriding
@@ -62,6 +63,10 @@ is
procedure texture_Applied_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in Boolean);
overriding
procedure animate (Self : in out Item);
private

View File

@@ -1,7 +1,9 @@
with
openGL.Geometry.lit_textured,
openGL.Primitive.indexed,
openGL.Texture.Coordinates;
openGL.Texture.Coordinates,
ada.Calendar;
package body openGL.Model.polygon.lit_textured
@@ -84,7 +86,7 @@ is
overriding
procedure texture_Applied_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in Boolean)
Now : in Boolean)
is
begin
Self.Face.texture_Applies (Which) := Now;
@@ -93,6 +95,21 @@ is
overriding
procedure animate (Self : in out Item)
is
use type texture_Set.Animation_view;
begin
if Self.Face.Animation = null
then
return;
end if;
texture_Set.animate (Self.Face.Animation.all,
Self.Face.texture_Applies);
end animate;
--------------------
--- to_GL_Geometries
@@ -160,27 +177,17 @@ is
end new_Face;
upper_Face : Geometry.lit_textured.view;
the_Face : Geometry.lit_textured.view;
begin
-- Upper Face
-- Face
--
declare
use openGL.Texture.Coordinates;
the_Vertices : Geometry.lit_textured.Vertex_array (1 .. the_Sites'Length + 1);
Coords_and_Centroid : constant Coords_2D_and_Centroid := to_Coordinates (the_Sites);
-- Centroid : Vector_2 := (0.0, 0.0);
begin
--- Calculate the centroid and min/max of x and y.
--
-- for i in the_Sites'Range
-- loop
-- Centroid := Centroid + the_Sites (i);
-- end loop;
--
-- Centroid := Centroid / Real (the_Sites'Length);
for i in the_Sites'Range
loop
the_Vertices (Index_t (i)) := (Site => Vector_3 (the_Sites (i) & 0.0),
@@ -196,10 +203,10 @@ is
T => 0.5 * Self.Face.texture_Tiling),
Shine => default_Shine);
upper_Face := new_Face (Vertices => the_Vertices);
the_Face := new_Face (Vertices => the_Vertices);
end;
return [1 => upper_Face.all'Access];
return [1 => the_Face.all'Access];
end to_GL_Geometries;

View File

@@ -12,6 +12,11 @@ is
type View is access all Item'Class;
--------
--- Face
--
type Face is
record
Fades : texture_Set.fade_Levels (texture_Set.texture_Id) := [others => 0.0];
@@ -19,6 +24,7 @@ is
texture_Count : Natural := 0;
texture_Tiling : openGL.Real := 1.0; -- The number of times the texture should be wrapped.
texture_Applies : texture_Set.texture_Apply_array := [others => True];
Animation : texture_Set.Animation_view;
end record;
@@ -43,17 +49,17 @@ is
--
overriding
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
overriding
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level);
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level);
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in asset_Name);
procedure Texture_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in asset_Name);
overriding
function texture_Count (Self : in Item) return Natural;
function texture_Count (Self : in Item) return Natural;
overriding
@@ -61,7 +67,11 @@ is
overriding
procedure texture_Applied_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in Boolean);
Now : in Boolean);
overriding
procedure animate (Self : in out Item);
private
@@ -74,4 +84,5 @@ private
Face : lit_textured.Face;
end record;
end openGL.Model.polygon.lit_textured;

View File

@@ -3,10 +3,6 @@ with
openGL.texture_Set,
openGL.Program;
-- limited
-- with
-- openGL.Model;
private
package openGL.Model.texturing

View File

@@ -74,16 +74,18 @@ is
-- Texturing
--
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level);
function Fade (Self : in Item; Which : in texture_Set.texture_Id) return texture_Set.fade_Level;
procedure Fade_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in texture_Set.fade_Level);
function texture_Count (Self : in Item) return Natural;
function texture_Count (Self : in Item) return Natural;
function texture_Applied (Self : in Item; Which : in texture_Set.texture_Id) return Boolean;
procedure texture_Applied_is (Self : in out Item; Which : in texture_Set.texture_Id;
Now : in Boolean);
procedure animate (Self : in out Item) is null;
private