Add initial prototype.
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
with
|
||||
openGL.Visual,
|
||||
openGL.Demo,
|
||||
openGL.Model.terrain;
|
||||
|
||||
|
||||
procedure launch_Model_scaling
|
||||
--
|
||||
-- Exercise the scaling of models.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3d;
|
||||
begin
|
||||
Demo.print_Usage;
|
||||
Demo.define ("openGL 'Model Scaling' Demo");
|
||||
Demo.Camera.Position_is ([0.0, 0.0, 20.0],
|
||||
y_Rotation_from (to_Radians (0.0)));
|
||||
declare
|
||||
-- The models.
|
||||
--
|
||||
the_Models : constant openGL.Model.views := openGL.Demo.Models;
|
||||
|
||||
-- The visuals.
|
||||
--
|
||||
the_Visuals : openGL.Visual.views (the_Models'Range);
|
||||
ground_Id : Positive;
|
||||
|
||||
-- Scaling
|
||||
--
|
||||
scaling_Up : Boolean := True;
|
||||
Scale : math.Vector_3 := [1.0, 1.0, 1.0];
|
||||
|
||||
begin
|
||||
for i in the_Visuals'Range
|
||||
loop
|
||||
the_Visuals (i) := Visual.Forge.new_Visual (the_Models (i));
|
||||
|
||||
if the_Models (i).all in openGL.Model.terrain.item'Class
|
||||
then
|
||||
ground_Id := i;
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
Demo.layout (the_Visuals);
|
||||
the_Visuals (ground_Id).Site_is (the_Visuals (ground_Id).Site_of + [0.0, -15.0, 0.0]);
|
||||
|
||||
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
if scaling_Up then Scale := Scale + [0.001, 0.001, 0.001];
|
||||
else Scale := Scale - [0.001, 0.001, 0.001];
|
||||
end if;
|
||||
|
||||
if Scale (1) > 2.0 then scaling_Up := False;
|
||||
elsif Scale (1) < 0.002 then scaling_Up := True;
|
||||
end if;
|
||||
|
||||
for Each of the_Visuals
|
||||
loop
|
||||
Each.Scale_is (Scale);
|
||||
end loop;
|
||||
|
||||
-- Handle user commands.
|
||||
--
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
-- Render the sprites.
|
||||
--
|
||||
Demo.Camera.render (the_Visuals);
|
||||
|
||||
while not Demo.Camera.cull_Completed
|
||||
loop
|
||||
delay Duration'Small;
|
||||
end loop;
|
||||
|
||||
Demo.Renderer.render;
|
||||
Demo.FPS_Counter.increment; -- Frames per second display.
|
||||
end loop;
|
||||
end;
|
||||
|
||||
Demo.destroy;
|
||||
end launch_Model_scaling;
|
||||
@@ -0,0 +1,20 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project Model_scaling
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_model_scaling.adb");
|
||||
|
||||
package Ide renames Lace_shared.Ide;
|
||||
package Builder renames Lace_shared.Builder;
|
||||
package Compiler renames Lace_shared.Compiler;
|
||||
package Binder renames Lace_shared.Binder;
|
||||
|
||||
package Linker is
|
||||
for Default_Switches ("ada") use ("-g", "-lX11", "-lGL", "-lexpat");
|
||||
end Linker;
|
||||
|
||||
end Model_scaling;
|
||||
@@ -0,0 +1,80 @@
|
||||
with
|
||||
openGL.Visual,
|
||||
openGL.Model.Arrow.colored,
|
||||
openGL.Demo;
|
||||
|
||||
|
||||
procedure launch_render_Arrows
|
||||
--
|
||||
-- Exercise the render of arrow models.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Model,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3d;
|
||||
begin
|
||||
Demo.print_Usage;
|
||||
Demo.define ("openGL 'Render Arrows' Demo");
|
||||
Demo.Camera.Position_is ([0.0, 0.0, 10.0],
|
||||
y_Rotation_from (to_Radians (0.0)));
|
||||
declare
|
||||
-- The Models.
|
||||
--
|
||||
the_Arrow_Model : constant Model.Arrow.colored.view
|
||||
:= Model.Arrow.colored.new_Arrow (End_2 => [0.0, 5.0, 0.0]);
|
||||
|
||||
the_spinner_Arrow_Model : constant Model.Arrow.colored.view
|
||||
:= Model.Arrow.colored.new_Arrow (End_1 => [0.0, -2.5, 0.0],
|
||||
End_2 => [0.0, 2.5, 0.0]);
|
||||
-- The Sprites.
|
||||
--
|
||||
use openGL.Visual.Forge;
|
||||
|
||||
the_Sprites : constant openGL.Visual.views := [new_Visual ( the_Arrow_Model.all'Access),
|
||||
new_Visual (the_spinner_Arrow_Model.all'Access)];
|
||||
Angle : Radians := 0.0;
|
||||
Site : openGL.Vector_2;
|
||||
|
||||
use openGL.Geometry_2d;
|
||||
begin
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
Site := to_Site (polar_Site' (Angle => Angle,
|
||||
Extent => 5.0));
|
||||
|
||||
the_Arrow_Model.End_Site_is (Now => math.Vector_3 (Site & 0.0),
|
||||
for_End => 2);
|
||||
|
||||
the_Sprites (2).Spin_is (to_Rotation (Axis => [0.0, 0.0, 1.0],
|
||||
Angle => Angle));
|
||||
-- Handle user commands.
|
||||
--
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
-- Render the sprites.
|
||||
--
|
||||
Demo.Camera.render (the_Sprites);
|
||||
|
||||
while not Demo.Camera.cull_Completed
|
||||
loop
|
||||
delay Duration'Small;
|
||||
end loop;
|
||||
|
||||
Demo.Renderer.render;
|
||||
Demo.FPS_Counter.increment; -- Frames per second display.
|
||||
|
||||
Angle := Angle + 0.001;
|
||||
|
||||
if Angle >= to_Radians (Degrees' (360.0))
|
||||
then
|
||||
Angle := 0.0;
|
||||
end if;
|
||||
end loop;
|
||||
end;
|
||||
|
||||
Demo.destroy;
|
||||
end launch_render_Arrows;
|
||||
@@ -0,0 +1,20 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project render_Arrows
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_render_arrows.adb");
|
||||
|
||||
package Ide renames Lace_shared.Ide;
|
||||
package Builder renames Lace_shared.Builder;
|
||||
package Compiler renames Lace_shared.Compiler;
|
||||
package Binder renames Lace_shared.Binder;
|
||||
|
||||
package Linker is
|
||||
for Default_Switches ("ada") use ("-g", "-lX11", "-lGL");
|
||||
end Linker;
|
||||
|
||||
end render_Arrows;
|
||||
2701
3-mid/opengl/applet/demo/models/render_asteroids/assets/gaspra.tab
Normal file
2701
3-mid/opengl/applet/demo/models/render_asteroids/assets/gaspra.tab
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,95 @@
|
||||
with
|
||||
openGL.Model.any,
|
||||
openGL.Visual,
|
||||
openGL.Light.directional,
|
||||
openGL.Demo;
|
||||
|
||||
procedure launch_render_Asteroids
|
||||
--
|
||||
-- Render with a few asteroids.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3d;
|
||||
|
||||
begin
|
||||
Demo.define ("openGL 'Render Asteroids' Demo");
|
||||
Demo.print_Usage ("Use space ' ' to cycle through models.");
|
||||
Demo.Camera.Position_is ((0.0, 0.0, 200.0),
|
||||
y_Rotation_from (to_Radians (0.0)));
|
||||
|
||||
declare
|
||||
the_Light : openGL.Light.directional.item := Demo.Renderer.Light (1);
|
||||
begin
|
||||
the_Light.Site_is ((5_000.0, 2_000.0, 5_000.0));
|
||||
Demo.Renderer.Light_is (1, the_Light);
|
||||
end;
|
||||
|
||||
declare
|
||||
-- The models.
|
||||
--
|
||||
|
||||
gaspra_Model : constant openGL.Model.any.view := openGL.Model.any.new_Model (Model => to_Asset ("assets/gaspra.tab"),
|
||||
Texture => null_Asset,
|
||||
Texture_is_lucid => False);
|
||||
the_Models : constant openGL.Model.views := (1 => gaspra_Model.all'unchecked_Access);
|
||||
|
||||
-- The visuals.
|
||||
--
|
||||
use openGL.Visual.Forge;
|
||||
|
||||
the_Visuals : openGL.Visual.views (the_Models'Range);
|
||||
Current : Integer := the_Visuals'First;
|
||||
|
||||
begin
|
||||
for i in the_Visuals'Range
|
||||
loop
|
||||
the_Visuals (i) := new_Visual (the_Models (i));
|
||||
end loop;
|
||||
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
declare
|
||||
Command : Character;
|
||||
Avail : Boolean;
|
||||
begin
|
||||
Demo.Dolly.get_last_Character (Command, Avail);
|
||||
|
||||
if Avail
|
||||
then
|
||||
case Command
|
||||
is
|
||||
when ' ' =>
|
||||
if Current = the_Visuals'Last
|
||||
then Current := the_Visuals'First;
|
||||
else Current := Current + 1;
|
||||
end if;
|
||||
|
||||
when others =>
|
||||
null;
|
||||
end case;
|
||||
end if;
|
||||
end;
|
||||
|
||||
-- Render all visuals.
|
||||
--
|
||||
Demo.Camera.render ((1 => the_Visuals (Current)));
|
||||
|
||||
while not Demo.Camera.cull_Completed
|
||||
loop
|
||||
delay Duration'Small;
|
||||
end loop;
|
||||
|
||||
Demo.Renderer.render;
|
||||
Demo.FPS_Counter.increment; -- Frames per second display.
|
||||
end loop;
|
||||
end;
|
||||
|
||||
Demo.destroy;
|
||||
end launch_render_Asteroids;
|
||||
@@ -0,0 +1,16 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project render_Asteroids
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_render_asteroids.adb");
|
||||
|
||||
package Ide renames Lace_shared.Ide;
|
||||
package Builder renames Lace_shared.Builder;
|
||||
package Compiler renames Lace_shared.Compiler;
|
||||
package Binder renames Lace_shared.Binder;
|
||||
|
||||
end render_Asteroids;
|
||||
@@ -0,0 +1,70 @@
|
||||
with
|
||||
openGL.Visual,
|
||||
openGL.Model.Billboard. textured,
|
||||
openGL.Model.Billboard.colored_textured,
|
||||
openGL.Palette,
|
||||
openGL.Demo;
|
||||
|
||||
procedure launch_render_Billboards
|
||||
--
|
||||
-- Exercise the render of billboard models.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Model,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3d;
|
||||
|
||||
the_Texture : constant openGL.asset_Name := to_Asset ("assets/opengl/texture/Face1.bmp");
|
||||
begin
|
||||
Demo.print_Usage;
|
||||
Demo.define ("openGL 'Render Billboards' Demo");
|
||||
Demo.Camera.Position_is ([0.0, 0.0, 10.0],
|
||||
y_Rotation_from (to_Radians (0.0)));
|
||||
declare
|
||||
-- The Models.
|
||||
--
|
||||
the_Billboard_Model : constant Model.Billboard.textured.view
|
||||
:= Model.Billboard.textured.forge.new_Billboard (--Scale => (1.0, 1.0, 1.0),
|
||||
Plane => Billboard.xy,
|
||||
Texture => the_Texture);
|
||||
|
||||
the_colored_Billboard_Model : constant Model.Billboard.colored_textured.view
|
||||
:= Model.Billboard.colored_textured.new_Billboard (--Scale => (1.0, 1.0, 1.0),
|
||||
Plane => Billboard.xy,
|
||||
Color => (Palette.Green, Opaque),
|
||||
Texture => the_Texture);
|
||||
-- The Sprites.
|
||||
--
|
||||
use openGL.Visual.Forge;
|
||||
|
||||
the_Sprites : constant openGL.Visual.views := [new_Visual ( the_Billboard_Model.all'Access),
|
||||
new_Visual (the_colored_Billboard_Model.all'Access)];
|
||||
begin
|
||||
the_Sprites (2).Site_is ([3.0, 0.0, 0.0]);
|
||||
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
-- Handle user commands.
|
||||
--
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
-- Render the sprites.
|
||||
--
|
||||
Demo.Camera.render (the_Sprites);
|
||||
|
||||
while not Demo.Camera.cull_Completed
|
||||
loop
|
||||
delay Duration'Small;
|
||||
end loop;
|
||||
|
||||
Demo.Renderer.render;
|
||||
Demo.FPS_Counter.increment; -- Frames per second display.
|
||||
end loop;
|
||||
end;
|
||||
|
||||
Demo.destroy;
|
||||
end launch_render_Billboards;
|
||||
@@ -0,0 +1,21 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project render_Billboards
|
||||
is
|
||||
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_render_billboards.adb");
|
||||
|
||||
package Ide renames Lace_shared.Ide;
|
||||
package Builder renames Lace_shared.Builder;
|
||||
package Compiler renames Lace_shared.Compiler;
|
||||
package Binder renames Lace_shared.Binder;
|
||||
|
||||
package Linker is
|
||||
for Default_Switches ("ada") use ("-g", "-lX11", "-lGL");
|
||||
end Linker;
|
||||
|
||||
end render_Billboards;
|
||||
@@ -0,0 +1,99 @@
|
||||
with
|
||||
openGL.Visual,
|
||||
|
||||
openGL.Model.Box. colored,
|
||||
openGL.Model.Box.textured,
|
||||
openGL.Model.Box.lit_colored_textured,
|
||||
|
||||
openGL.Palette,
|
||||
openGL.Demo;
|
||||
|
||||
procedure launch_render_Boxes
|
||||
--
|
||||
-- Exercise the rendering of box models.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Model,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3d;
|
||||
|
||||
the_Texture : constant openGL.asset_Name := to_Asset ("assets/opengl/texture/Face1.bmp");
|
||||
begin
|
||||
Demo.print_Usage;
|
||||
Demo.define ("openGL 'Render Boxes' Demo");
|
||||
Demo.Camera.Position_is ([0.0, 0.0, 10.0],
|
||||
y_Rotation_from (to_Radians (0.0)));
|
||||
declare
|
||||
use openGL.Model.box,
|
||||
openGL.Palette;
|
||||
|
||||
-- The Models.
|
||||
--
|
||||
the_Box_1_Model : constant Model.Box.colored.view
|
||||
:= Model.Box.colored.new_Box
|
||||
(Size => [1.0, 2.0, 1.0],
|
||||
Faces => [Front => (Colors => [others => (Blue, Opaque)]),
|
||||
Rear => (Colors => [others => (Blue, Opaque)]),
|
||||
Upper => (Colors => [others => (Green, Opaque)]),
|
||||
Lower => (Colors => [others => (Green, Opaque)]),
|
||||
Left => (Colors => [others => (Dark_Red, Opaque)]),
|
||||
Right => (Colors => [others => (Red, Opaque)])]);
|
||||
|
||||
the_Box_2_Model : constant Model.Box.lit_colored_textured.view
|
||||
:= Model.Box.lit_colored_textured.new_Box
|
||||
(Size => [1.0, 2.0, 1.0],
|
||||
Faces => [Front => (Colors => [others => (Blue, Opaque)], texture_Name => the_Texture),
|
||||
Rear => (Colors => [others => (Blue, Opaque)], texture_Name => the_Texture),
|
||||
Upper => (Colors => [others => (Green, Opaque)], texture_Name => the_Texture),
|
||||
Lower => (Colors => [others => (Green, Opaque)], texture_Name => the_Texture),
|
||||
Left => (Colors => [others => (Dark_Red, Opaque)], texture_Name => the_Texture),
|
||||
Right => (Colors => [others => (Red, Opaque)], texture_Name => the_Texture)]);
|
||||
|
||||
the_Box_3_Model : constant Model.Box.textured.view
|
||||
:= Model.Box.textured.new_Box
|
||||
(Size => [1.0, 2.0, 1.0],
|
||||
Faces => [Front => (texture_Name => the_Texture),
|
||||
Rear => (texture_Name => the_Texture),
|
||||
Upper => (texture_Name => the_Texture),
|
||||
Lower => (texture_Name => the_Texture),
|
||||
Left => (texture_Name => the_Texture),
|
||||
Right => (texture_Name => the_Texture)]);
|
||||
|
||||
-- The Visuals.
|
||||
--
|
||||
use openGL.Visual.Forge;
|
||||
|
||||
the_Visuals : constant openGL.Visual.views := [1 => new_Visual (the_Box_1_Model.all'Access),
|
||||
2 => new_Visual (the_Box_2_Model.all'Access),
|
||||
3 => new_Visual (the_Box_3_Model.all'Access)];
|
||||
begin
|
||||
the_Visuals (1).Site_is ([-3.0, 0.0, 0.0]);
|
||||
the_Visuals (2).Site_is ([ 0.0, 0.0, 0.0]);
|
||||
the_Visuals (3).Site_is ([ 3.0, 0.0, 0.0]);
|
||||
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
-- Handle user commands.
|
||||
--
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
-- Render the sprites.
|
||||
--
|
||||
Demo.Camera.render (the_Visuals);
|
||||
|
||||
while not Demo.Camera.cull_Completed
|
||||
loop
|
||||
delay Duration'Small;
|
||||
end loop;
|
||||
|
||||
Demo.Renderer.render;
|
||||
Demo.FPS_Counter.increment; -- Frames per second display.
|
||||
end loop;
|
||||
end;
|
||||
|
||||
Demo.destroy;
|
||||
end launch_render_Boxes;
|
||||
@@ -0,0 +1,16 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project render_Boxes
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_render_boxes.adb");
|
||||
|
||||
package Ide renames Lace_shared.Ide;
|
||||
package Builder renames Lace_shared.Builder;
|
||||
package Compiler renames Lace_shared.Compiler;
|
||||
package Binder renames Lace_shared.Binder;
|
||||
|
||||
end render_Boxes;
|
||||
@@ -0,0 +1,71 @@
|
||||
with
|
||||
openGL.Visual,
|
||||
openGL.Model.Capsule.lit_colored_textured,
|
||||
openGL.Palette,
|
||||
openGL.Light,
|
||||
openGL.Demo;
|
||||
|
||||
|
||||
procedure launch_render_Capsules
|
||||
--
|
||||
-- Exercise the render of capsule models.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Model,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3d;
|
||||
begin
|
||||
Demo.print_Usage;
|
||||
Demo.define ("openGL 'Render Capsules' Demo");
|
||||
Demo.Camera.Position_is ([0.0, 3.0, 10.0],
|
||||
y_Rotation_from (to_Radians (-0.0)));
|
||||
Demo.Dolly.Speed_is (0.1);
|
||||
|
||||
declare
|
||||
use openGL.Palette;
|
||||
|
||||
the_Light : openGL.Light.item := Demo.Renderer.new_Light;
|
||||
the_Texture : constant asset_Name := to_Asset ("assets/opengl/texture/Face1.bmp");
|
||||
|
||||
-- The Models.
|
||||
--
|
||||
the_Capsule_Model : constant Model.Capsule.lit_colored_textured.view
|
||||
:= Model.Capsule.lit_colored_textured.new_Capsule (Radius => 0.5,
|
||||
Height => 2.0,
|
||||
Color => (White, Opaque),
|
||||
Image => the_Texture);
|
||||
-- The Visuals.
|
||||
--
|
||||
use openGL.Visual.Forge;
|
||||
|
||||
the_Visuals : constant openGL.Visual.views := [1 => new_Visual (the_Capsule_Model.all'Access)];
|
||||
begin
|
||||
the_Light.Site_is ([0.0, 5.0, 10.0]);
|
||||
Demo.Renderer.set (the_Light);
|
||||
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
-- Handle user commands.
|
||||
--
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
-- Render the sprites.
|
||||
--
|
||||
Demo.Camera.render (the_Visuals);
|
||||
|
||||
while not Demo.Camera.cull_Completed
|
||||
loop
|
||||
delay Duration'Small;
|
||||
end loop;
|
||||
|
||||
Demo.Renderer.render;
|
||||
Demo.FPS_Counter.increment; -- Frames per second display.
|
||||
end loop;
|
||||
end;
|
||||
|
||||
Demo.destroy;
|
||||
end launch_render_Capsules;
|
||||
@@ -0,0 +1,16 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project render_Capsules
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_render_capsules.adb");
|
||||
|
||||
package Ide renames Lace_shared.Ide;
|
||||
package Builder renames Lace_shared.Builder;
|
||||
package Compiler renames Lace_shared.Compiler;
|
||||
package Binder renames Lace_shared.Binder;
|
||||
|
||||
end render_Capsules;
|
||||
@@ -0,0 +1,206 @@
|
||||
with
|
||||
openGL.Model.hex_grid,
|
||||
openGL.Visual,
|
||||
openGL.Light,
|
||||
openGL.Palette,
|
||||
openGL.IO,
|
||||
openGL.Demo;
|
||||
|
||||
|
||||
procedure launch_render_Hex_Grid
|
||||
--
|
||||
-- Renders a hexagon grid.
|
||||
--
|
||||
is
|
||||
use openGL,
|
||||
openGL.Math,
|
||||
openGL.linear_Algebra_3D,
|
||||
openGL.Palette;
|
||||
|
||||
begin
|
||||
Demo.print_Usage;
|
||||
Demo.define ("openGL 'Render Hex Grid' Demo",
|
||||
Width => 1_000,
|
||||
Height =>1_000);
|
||||
|
||||
Demo.Camera.Position_is ([0.0, 40.0, 0.0],
|
||||
x_Rotation_from (to_Radians (90.0)));
|
||||
|
||||
-- declare
|
||||
-- use openGL.Light;
|
||||
-- the_Light : openGL.Light.item := Demo.Renderer.new_Light;
|
||||
-- begin
|
||||
-- the_Light.Site_is ([5_000.0, 2_000.0, 5_000.0]);
|
||||
-- the_Light.Color_is (White);
|
||||
--
|
||||
-- Demo.Renderer.set (the_Light);
|
||||
-- end;
|
||||
|
||||
|
||||
declare
|
||||
-- The models.
|
||||
--
|
||||
|
||||
heights_File : constant asset_Name := to_Asset ("assets/kidwelly-terrain-127x127.png");
|
||||
|
||||
heights_File_1x1 : constant asset_Name := to_Asset ("assets/test-1x1.png");
|
||||
|
||||
heights_File_2x1 : constant asset_Name := to_Asset ("assets/test-2x1.png");
|
||||
heights_File_1x2 : constant asset_Name := to_Asset ("assets/test-1x2.png");
|
||||
heights_File_2x2 : constant asset_Name := to_Asset ("assets/test-2x2.png");
|
||||
|
||||
heights_File_3x1 : constant asset_Name := to_Asset ("assets/test-3x1.png");
|
||||
heights_File_1x3 : constant asset_Name := to_Asset ("assets/test-1x3.png");
|
||||
|
||||
|
||||
heights_File_3x3 : constant asset_Name := to_Asset ("assets/test-3x3.png");
|
||||
heights_File_4x4 : constant asset_Name := to_Asset ("assets/test-4x4.png");
|
||||
heights_File_5x5 : constant asset_Name := to_Asset ("assets/test-5x5.png");
|
||||
|
||||
|
||||
the_Region : constant IO.height_Map_view := IO.to_height_Map (heights_File, 10.0);
|
||||
|
||||
the_Region_1x1 : constant IO.height_Map_view := IO.to_height_Map (heights_File_1x1, 10.0);
|
||||
|
||||
the_Region_2x1 : constant IO.height_Map_view := IO.to_height_Map (heights_File_2x1, 10.0);
|
||||
the_Region_1x2 : constant IO.height_Map_view := IO.to_height_Map (heights_File_1x2, 10.0);
|
||||
the_Region_2x2 : constant IO.height_Map_view := IO.to_height_Map (heights_File_2x2, 10.0);
|
||||
|
||||
the_Region_3x1 : constant IO.height_Map_view := IO.to_height_Map (heights_File_3x1, 10.0);
|
||||
the_Region_1x3 : constant IO.height_Map_view := IO.to_height_Map (heights_File_1x3, 10.0);
|
||||
|
||||
the_Region_3x3 : constant IO.height_Map_view := IO.to_height_Map (heights_File_3x3, 10.0);
|
||||
the_Region_4x4 : constant IO.height_Map_view := IO.to_height_Map (heights_File_4x4, 10.0);
|
||||
the_Region_5x5 : constant IO.height_Map_view := IO.to_height_Map (heights_File_5x5, 10.0);
|
||||
|
||||
Color : constant openGL.lucid_Color := (Green, Opaque);
|
||||
|
||||
the_grid_Model : constant Model.hex_grid.view
|
||||
:= Model.hex_grid.new_Grid (heights_Asset => heights_File,
|
||||
Heights => the_Region.all'Access,
|
||||
Color => Color);
|
||||
|
||||
the_grid_Model_1x1 : constant Model.hex_grid.view
|
||||
:= Model.hex_grid.new_Grid (heights_Asset => heights_File_1x1,
|
||||
Heights => the_Region_1x1.all'Access,
|
||||
Color => Color);
|
||||
|
||||
the_grid_Model_2x1 : constant Model.hex_grid.view
|
||||
:= Model.hex_grid.new_Grid (heights_Asset => heights_File_2x1,
|
||||
Heights => the_Region_2x1.all'Access,
|
||||
Color => Color);
|
||||
|
||||
the_grid_Model_1x2 : constant Model.hex_grid.view
|
||||
:= Model.hex_grid.new_Grid (heights_Asset => heights_File_1x2,
|
||||
Heights => the_Region_1x2.all'Access,
|
||||
Color => Color);
|
||||
|
||||
the_grid_Model_2x2 : constant Model.hex_grid.view
|
||||
:= Model.hex_grid.new_Grid (heights_Asset => heights_File_2x2,
|
||||
Heights => the_Region_2x2.all'Access,
|
||||
Color => Color);
|
||||
|
||||
the_grid_Model_3x1 : constant Model.hex_grid.view
|
||||
:= Model.hex_grid.new_Grid (heights_Asset => heights_File_3x1,
|
||||
Heights => the_Region_3x1.all'Access,
|
||||
Color => Color);
|
||||
|
||||
the_grid_Model_1x3 : constant Model.hex_grid.view
|
||||
:= Model.hex_grid.new_Grid (heights_Asset => heights_File_1x3,
|
||||
Heights => the_Region_1x3.all'Access,
|
||||
Color => Color);
|
||||
|
||||
the_grid_Model_3x3 : constant Model.hex_grid.view
|
||||
:= Model.hex_grid.new_Grid (heights_Asset => heights_File_3x3,
|
||||
Heights => the_Region_3x3.all'Access,
|
||||
Color => Color);
|
||||
|
||||
the_grid_Model_4x4 : constant Model.hex_grid.view
|
||||
:= Model.hex_grid.new_Grid (heights_Asset => heights_File_4x4,
|
||||
Heights => the_Region_4x4.all'Access,
|
||||
Color => Color);
|
||||
|
||||
the_grid_Model_5x5 : constant Model.hex_grid.view
|
||||
:= Model.hex_grid.new_Grid (heights_Asset => heights_File_5x5,
|
||||
Heights => the_Region_5x5.all'Access,
|
||||
Color => Color);
|
||||
|
||||
-- The visual.
|
||||
--
|
||||
use openGL.Visual.Forge;
|
||||
|
||||
the_Grid : constant openGL.Visual.view := new_Visual (the_grid_Model .all'Access);
|
||||
|
||||
the_Grid_1x1 : constant openGL.Visual.view := new_Visual (the_grid_Model_1x1.all'Access);
|
||||
|
||||
the_Grid_2x1 : constant openGL.Visual.view := new_Visual (the_grid_Model_2x1.all'Access);
|
||||
the_Grid_1x2 : constant openGL.Visual.view := new_Visual (the_grid_Model_1x2.all'Access);
|
||||
the_Grid_2x2 : constant openGL.Visual.view := new_Visual (the_grid_Model_2x2.all'Access);
|
||||
|
||||
the_Grid_3x1 : constant openGL.Visual.view := new_Visual (the_grid_Model_3x1.all'Access);
|
||||
the_Grid_1x3 : constant openGL.Visual.view := new_Visual (the_grid_Model_1x3.all'Access);
|
||||
|
||||
the_Grid_3x3 : constant openGL.Visual.view := new_Visual (the_grid_Model_3x3.all'Access);
|
||||
the_Grid_4x4 : constant openGL.Visual.view := new_Visual (the_grid_Model_4x4.all'Access);
|
||||
the_Grid_5x5 : constant openGL.Visual.view := new_Visual (the_grid_Model_5x5.all'Access);
|
||||
|
||||
begin
|
||||
the_Grid .Site_is ([ 0.0, 0.0, 0.0]);
|
||||
|
||||
the_Grid_1x1.Site_is ([ 0.0, 0.0, -10.0]);
|
||||
|
||||
the_Grid_2x1.Site_is ([ 0.0, 0.0, 0.0]);
|
||||
the_Grid_1x2.Site_is ([ 0.0, 0.0, 5.0]);
|
||||
the_Grid_2x2.Site_is ([ 0.0, 0.0, -5.0]);
|
||||
|
||||
the_Grid_3x1.Site_is ([ 5.0, 0.0, 0.0]);
|
||||
the_Grid_1x3.Site_is ([ 5.0, 0.0, 5.0]);
|
||||
|
||||
the_Grid_3x3.Site_is ([-10.0, 0.0, -10.0]);
|
||||
the_Grid_4x4.Site_is ([-10.0, 0.0, 0.0]);
|
||||
the_Grid_5x5.Site_is ([-10.0, 0.0, 10.0]);
|
||||
|
||||
|
||||
-- Main loop.
|
||||
--
|
||||
while not Demo.Done
|
||||
loop
|
||||
Demo.Dolly.evolve;
|
||||
Demo.Done := Demo.Dolly.quit_Requested;
|
||||
|
||||
-- Render all visuals.
|
||||
--
|
||||
|
||||
Demo.Camera.render ([1 => the_Grid]);
|
||||
|
||||
-- Demo.Camera.render ([1 => the_Grid_1x1]);
|
||||
-- Demo.Camera.render ([1 => the_Grid_2x1]);
|
||||
-- Demo.Camera.render ([1 => the_Grid_1x2]);
|
||||
-- Demo.Camera.render ([1 => the_Grid_3x1]);
|
||||
|
||||
-- Demo.Camera.render ([the_Grid_1x1,
|
||||
--
|
||||
-- the_Grid_2x1,
|
||||
-- the_Grid_1x2,
|
||||
-- the_Grid_2x2,
|
||||
--
|
||||
-- the_Grid_3x1,
|
||||
-- the_Grid_1x3,
|
||||
--
|
||||
-- the_Grid_3x3,
|
||||
-- the_Grid_4x4,
|
||||
-- the_Grid_5x5]);
|
||||
|
||||
while not Demo.Camera.cull_Completed
|
||||
loop
|
||||
delay Duration'Small;
|
||||
end loop;
|
||||
|
||||
Demo.Renderer.render;
|
||||
Demo.FPS_Counter.increment; -- Frames per second display.
|
||||
-- delay 1.0 / 60.0;
|
||||
end loop;
|
||||
end;
|
||||
|
||||
Demo.destroy;
|
||||
end launch_render_Hex_Grid;
|
||||
@@ -0,0 +1,16 @@
|
||||
with
|
||||
"opengl_demo",
|
||||
"lace_shared";
|
||||
|
||||
project render_Hex_Grid
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_render_hex_grid.adb");
|
||||
|
||||
package Ide renames Lace_shared.Ide;
|
||||
package Builder renames Lace_shared.Builder;
|
||||
package Compiler renames Lace_shared.Compiler;
|
||||
package Binder renames Lace_shared.Binder;
|
||||
|
||||
end render_Hex_Grid;
|
||||
Reference in New Issue
Block a user