Add initial prototype.
This commit is contained in:
17
4-high/gel/applet/demo/sprite/chains_2d/chains_2d.gpr
Normal file
17
4-high/gel/applet/demo/sprite/chains_2d/chains_2d.gpr
Normal file
@@ -0,0 +1,17 @@
|
||||
with
|
||||
"gel",
|
||||
"lace_shared";
|
||||
|
||||
project Chains_2D
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_chains_2d.adb");
|
||||
for Languages use ("Ada");
|
||||
|
||||
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 Chains_2D;
|
||||
73
4-high/gel/applet/demo/sprite/chains_2d/launch_chains_2d.adb
Normal file
73
4-high/gel/applet/demo/sprite/chains_2d/launch_chains_2d.adb
Normal file
@@ -0,0 +1,73 @@
|
||||
with
|
||||
gel.Window.sdl,
|
||||
gel.Applet.gui_world,
|
||||
gel.Forge,
|
||||
gel.Sprite,
|
||||
gel.Joint,
|
||||
|
||||
Physics,
|
||||
openGL.Palette;
|
||||
|
||||
pragma unreferenced (gel.Window.sdl);
|
||||
|
||||
|
||||
procedure launch_Chains_2d
|
||||
--
|
||||
-- Creates a chain of balls in a 2D space.
|
||||
--
|
||||
is
|
||||
use gel.Forge,
|
||||
gel.Applet,
|
||||
gel.Math,
|
||||
opengl.Palette;
|
||||
|
||||
the_Applet : gel.Applet.gui_World.view := new_gui_Applet ("Chains 2D",
|
||||
1536, 864,
|
||||
space_Kind => physics.Box2D);
|
||||
|
||||
the_Ground : constant gel.Sprite.view := new_rectangle_Sprite (the_Applet.gui_World,
|
||||
Mass => 0.0,
|
||||
Width => 100.0,
|
||||
Height => 1.0,
|
||||
Color => apple_Green);
|
||||
begin
|
||||
the_Applet.gui_World .Gravity_is ([0.0, -10.0, 0.0]);
|
||||
the_Applet.gui_Camera.Site_is ([0.0, -30.0, 100.0]);
|
||||
the_Applet.Renderer .Background_is (Grey);
|
||||
the_Applet.enable_simple_Dolly (in_World => gui_World.gui_world_Id);
|
||||
|
||||
the_Ground.Site_is ([0.0, -40.0, 0.0]);
|
||||
the_Applet.gui_World.add (the_Ground, and_Children => False);
|
||||
|
||||
-- Add joints.
|
||||
--
|
||||
declare
|
||||
ball_Count : constant := 39;
|
||||
the_root_Ball : constant gel.Sprite.view := new_circle_Sprite (the_Applet.gui_World, Mass => 0.0);
|
||||
the_Balls : constant gel.Sprite.views := [1 .. ball_Count => new_circle_Sprite (the_Applet.gui_World, Mass => 1.0)];
|
||||
|
||||
Parent : gel.Sprite.view := the_root_Ball;
|
||||
new_Joint : gel.Joint .view;
|
||||
begin
|
||||
for i in the_Balls'Range
|
||||
loop
|
||||
the_Balls (i).Site_is ([Real (-i), 0.0, 0.0]);
|
||||
|
||||
Parent.attach_via_Hinge (the_Child => the_Balls (i),
|
||||
pivot_Axis => [0.0, 0.0, 1.0],
|
||||
low_Limit => to_Radians (-180.0),
|
||||
high_Limit => to_Radians ( 180.0),
|
||||
new_joint => new_Joint);
|
||||
Parent := the_Balls (i);
|
||||
end loop;
|
||||
|
||||
the_Applet.gui_World.add (the_root_Ball, and_Children => True);
|
||||
end;
|
||||
|
||||
while the_Applet.is_open
|
||||
loop
|
||||
the_Applet.freshen; -- Handle any new events, evolve physics and update the screen.
|
||||
end loop;
|
||||
|
||||
gel.Applet.gui_world.free (the_Applet);
|
||||
end launch_Chains_2d;
|
||||
@@ -0,0 +1,22 @@
|
||||
with
|
||||
"gel",
|
||||
"lace_shared";
|
||||
|
||||
project Drop_Ball_On_Box
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_drop_ball_on_box.adb");
|
||||
for Languages use ("Ada");
|
||||
|
||||
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 Linker_Options use ("-g", "-lGL", "-lGLU", "-lglut", "-lSDL2");
|
||||
end Linker;
|
||||
|
||||
end Drop_Ball_On_Box;
|
||||
@@ -0,0 +1,76 @@
|
||||
with
|
||||
gel.Window.setup,
|
||||
gel.Applet.gui_world,
|
||||
gel.Forge,
|
||||
gel.Sprite,
|
||||
gel.World,
|
||||
gel.Camera,
|
||||
|
||||
Physics,
|
||||
|
||||
ada.Text_IO,
|
||||
ada.Exceptions;
|
||||
|
||||
pragma unreferenced (gel.Window.setup);
|
||||
|
||||
|
||||
procedure launch_drop_Ball_on_Box
|
||||
--
|
||||
-- Drops a ball onto a box 'terrain'.
|
||||
--
|
||||
is
|
||||
use gel.Applet,
|
||||
gel.Applet.gui_world,
|
||||
Ada.Text_IO;
|
||||
|
||||
the_Applet : gel.Applet.gui_world.view := gel.Forge.new_gui_Applet ("drop Ball on Box",
|
||||
space_Kind => physics.Bullet);
|
||||
|
||||
function gui_World return gel.World.view
|
||||
is
|
||||
begin
|
||||
return the_Applet.World (gui_world_Id);
|
||||
end gui_World;
|
||||
|
||||
|
||||
function gui_Camera return gel.Camera.view
|
||||
is
|
||||
begin
|
||||
return the_Applet.Camera (gui_world_Id,
|
||||
gui_camera_Id);
|
||||
end gui_Camera;
|
||||
|
||||
|
||||
the_Ball : constant gel.Sprite.view := gel.Forge.new_ball_Sprite (gui_World);
|
||||
the_Box : constant gel.Sprite.view := gel.Forge.new_box_Sprite (gui_World,
|
||||
Mass => 0.0,
|
||||
Size => [20.0, 1.0, 20.0]);
|
||||
begin
|
||||
new_Line;
|
||||
put_Line ("Use arrow keys and PgUp/PgDn to move the camera.");
|
||||
new_Line;
|
||||
|
||||
gui_Camera.Site_is ([0.0, 2.0, 20.0]); -- Position the camera.
|
||||
the_Applet.enable_simple_Dolly (in_World => gui_world_Id); -- Enable user camera control via keyboards.
|
||||
|
||||
the_Ball.Site_is ([0.0, 10.0, 0.0]);
|
||||
|
||||
gui_World.Gravity_is ([0.0, -9.8, 0.0]);
|
||||
gui_World.add (the_Ball); -- Add ball.
|
||||
gui_World.add (the_Box); -- Add box.
|
||||
|
||||
|
||||
while the_Applet.is_open
|
||||
loop
|
||||
the_Applet.freshen; -- Handle any new events and update the screen.
|
||||
end loop;
|
||||
|
||||
free (the_Applet);
|
||||
|
||||
exception
|
||||
when E : others =>
|
||||
new_Line;
|
||||
put_Line ("Unhandled exception in main task ...");
|
||||
put_Line (ada.Exceptions.exception_Information (E));
|
||||
new_Line;
|
||||
end launch_drop_Ball_on_Box;
|
||||
@@ -0,0 +1,17 @@
|
||||
with
|
||||
"gel",
|
||||
"lace_shared";
|
||||
|
||||
project drop_Box_on_Box
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_drop_box_on_box.adb");
|
||||
for Languages use ("Ada");
|
||||
|
||||
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 drop_Box_on_Box;
|
||||
@@ -0,0 +1,98 @@
|
||||
with
|
||||
gel.Forge,
|
||||
gel.Window.sdl,
|
||||
gel.Applet.gui_world,
|
||||
gel.Camera,
|
||||
gel.Sprite,
|
||||
physics.Model,
|
||||
|
||||
openGL.Model.box.colored,
|
||||
openGL.Palette,
|
||||
|
||||
ada.Text_IO,
|
||||
ada.Exceptions;
|
||||
|
||||
pragma unreferenced (gel.window.sdl);
|
||||
|
||||
procedure launch_drop_Box_on_Box
|
||||
--
|
||||
-- Drops a box onto a box 'terrain'.
|
||||
--
|
||||
is
|
||||
use openGL.Model.box,
|
||||
openGL,
|
||||
opengl.Palette,
|
||||
ada.Text_IO;
|
||||
|
||||
the_Applet : constant gel.Applet.gui_World.view
|
||||
:= gel.Forge.new_gui_Applet ("drop Ball on Box");
|
||||
|
||||
|
||||
the_ground_graphics_Model : constant openGL.Model.box.colored.view
|
||||
:= openGL.Model.box.colored.new_Box (Size => [10.0, 0.5, 10.0],
|
||||
Faces => [Front => (Colors => [others => (Red, Opaque)]),
|
||||
Rear => (Colors => [others => (Blue, Opaque)]),
|
||||
Upper => (Colors => [others => (Green, Opaque)]),
|
||||
Lower => (Colors => [others => (Yellow, Opaque)]),
|
||||
Left => (Colors => [others => (Cyan, Opaque)]),
|
||||
Right => (Colors => [others => (Magenta, Opaque)])]);
|
||||
the_ground_physics_Model : constant physics.Model.view
|
||||
:= physics.Model.Forge.new_physics_Model (shape_Info => (Kind => physics.Model.cube,
|
||||
half_Extents => [5.0, 0.25, 5.0]));
|
||||
|
||||
the_Ground : constant gel.Sprite.view
|
||||
:= gel.Sprite.forge.new_Sprite ("demo.Ground",
|
||||
gel.Sprite.World_view (the_Applet.gui_World),
|
||||
math.Origin_3D,
|
||||
the_ground_graphics_Model,
|
||||
the_ground_physics_Model);
|
||||
|
||||
|
||||
the_box_physics_Model : constant physics.Model.view
|
||||
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.cube,
|
||||
half_Extents => [1.0, 0.5, 1.0]),
|
||||
Mass => 1.0);
|
||||
|
||||
the_box_graphics_Model : constant openGL.Model.box.colored.view
|
||||
:= openGL.Model.box.colored.new_Box (Size => [1.0, 1.0, 1.0],
|
||||
Faces => [Front => (Colors => [others => (Red, Opaque)]),
|
||||
Rear => (Colors => [others => (Blue, Opaque)]),
|
||||
Upper => (Colors => [others => (dark_Green, Opaque)]),
|
||||
Lower => (Colors => [others => (Yellow, Opaque)]),
|
||||
Left => (Colors => [others => (Cyan, Opaque)]),
|
||||
Right => (Colors => [others => (Magenta, Opaque)])]);
|
||||
the_Box : constant gel.Sprite.view
|
||||
:= gel.Sprite.forge.new_Sprite ("demo.Box",
|
||||
gel.Sprite.World_view (the_Applet.gui_World),
|
||||
math.Origin_3D,
|
||||
the_box_graphics_Model,
|
||||
the_box_physics_Model);
|
||||
begin
|
||||
new_Line;
|
||||
put_Line ("Use arrow keys and PgUp/PgDn to move the camera.");
|
||||
new_Line;
|
||||
|
||||
the_Applet.gui_Camera.Site_is ([0.0, 5.0, 15.0]); -- Position the camera.
|
||||
the_Applet.enable_simple_Dolly (1); -- Enable user camera control via keyboards.
|
||||
the_Applet.enable_Mouse (detect_Motion => False); -- Enable the mouse.
|
||||
|
||||
the_Applet.gui_World.add (the_Ground, and_children => False); -- Add ground.
|
||||
the_Ground.Site_is (math.Origin_3D);
|
||||
|
||||
the_Applet.gui_World.add (the_Box, and_Children => False); -- Add ball.
|
||||
the_Box.Site_is ([0.0, 10.0, 0.0]);
|
||||
|
||||
while the_Applet.is_open
|
||||
loop
|
||||
the_Applet.freshen; -- Handle any new events and update the screen.
|
||||
end loop;
|
||||
|
||||
the_Applet.destroy;
|
||||
|
||||
exception
|
||||
when E : others =>
|
||||
new_Line;
|
||||
put_Line ("Unhandled exception in main thread ...");
|
||||
put_Line (ada.Exceptions.exception_Information (E));
|
||||
new_Line;
|
||||
end launch_drop_Box_on_Box;
|
||||
17
4-high/gel/applet/demo/sprite/hinged_box/hinged_box.gpr
Normal file
17
4-high/gel/applet/demo/sprite/hinged_box/hinged_box.gpr
Normal file
@@ -0,0 +1,17 @@
|
||||
with
|
||||
"gel",
|
||||
"lace_shared";
|
||||
|
||||
project hinged_Box
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_hinged_box.adb");
|
||||
for Languages use ("Ada");
|
||||
|
||||
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 hinged_Box;
|
||||
165
4-high/gel/applet/demo/sprite/hinged_box/launch_hinged_box.adb
Normal file
165
4-high/gel/applet/demo/sprite/hinged_box/launch_hinged_box.adb
Normal file
@@ -0,0 +1,165 @@
|
||||
with
|
||||
gel.Window.sdl,
|
||||
gel.Applet.gui_world,
|
||||
gel.Forge,
|
||||
gel.Sprite,
|
||||
gel.hinge_Joint,
|
||||
physics.Model,
|
||||
|
||||
openGL.Model.box.colored,
|
||||
openGL.Palette,
|
||||
|
||||
float_math.Algebra.linear.d3,
|
||||
|
||||
ada.Text_IO,
|
||||
ada.Exceptions;
|
||||
|
||||
pragma unreferenced (gel.Window.sdl);
|
||||
|
||||
|
||||
procedure launch_hinged_Box
|
||||
--
|
||||
-- Shows variously hinged boxes.
|
||||
--
|
||||
is
|
||||
package Math renames float_Math;
|
||||
|
||||
use openGL,
|
||||
openGL.Model.box,
|
||||
opengl.Palette,
|
||||
ada.Text_IO;
|
||||
|
||||
the_Applet : constant gel.Applet.gui_World.view := gel.Forge.new_gui_Applet ("hinged Box", 1536, 864);
|
||||
X : float_math.Real := 0.0;
|
||||
|
||||
begin
|
||||
the_Applet.gui_Camera.Site_is ([0.0, 4.0, 30.0]); -- Position the camera.
|
||||
the_Applet.enable_simple_Dolly (1); -- Enable user camera control via keyboard.
|
||||
the_Applet.Renderer.Background_is (Blue);
|
||||
|
||||
-- Add sprites and joints.
|
||||
--
|
||||
declare
|
||||
use float_Math;
|
||||
|
||||
box_Size : constant gel.Math.Vector_3 := [1.0, 1.0, 1.0];
|
||||
|
||||
-- Box
|
||||
--
|
||||
the_box_Model : constant openGL.Model.box.colored.view
|
||||
:= openGL.Model.box.colored.new_Box (Size => box_Size,
|
||||
Faces => [Front => (colors => [others => (Red, Opaque)]),
|
||||
Rear => (colors => [others => (Blue, Opaque)]),
|
||||
Upper => (colors => [others => (Violet, Opaque)]),
|
||||
Lower => (colors => [others => (Yellow, Opaque)]),
|
||||
Left => (colors => [others => (Cyan, Opaque)]),
|
||||
Right => (colors => [others => (Magenta, Opaque)])]);
|
||||
the_static_box_physics_Model : constant physics.Model.view
|
||||
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.cube,
|
||||
half_Extents => box_Size));
|
||||
the_dynamic_box_physics_Model : constant physics.Model.view
|
||||
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.cube,
|
||||
half_Extents => box_Size / 2.0),
|
||||
Mass => 1.0);
|
||||
the_Box_1 : constant gel.Sprite.view
|
||||
:= gel.Sprite.forge.new_Sprite ("demo.Box.static.1",
|
||||
the_Applet.gui_World.all'Access,
|
||||
math.Origin_3d,
|
||||
the_box_Model.all'Access,
|
||||
the_static_box_physics_Model,
|
||||
owns_Graphics => False,
|
||||
owns_Physics => True);
|
||||
|
||||
the_Box_2 : constant gel.Sprite.view
|
||||
:= gel.Sprite.forge.new_Sprite ("demo.Box.dynamic.2",
|
||||
the_Applet.gui_World.all'Access,
|
||||
math.Origin_3d,
|
||||
the_box_Model.all'Access,
|
||||
the_dynamic_box_physics_Model,
|
||||
owns_Graphics => False,
|
||||
owns_Physics => False);
|
||||
|
||||
the_Box_3 : constant gel.Sprite.view
|
||||
:= gel.Sprite.forge.new_Sprite ("demo.Box.dynamic.3",
|
||||
the_Applet.gui_World.all'Access,
|
||||
math.Origin_3d,
|
||||
the_box_Model.all'Access,
|
||||
the_dynamic_box_physics_Model,
|
||||
owns_Graphics => True,
|
||||
owns_Physics => True);
|
||||
|
||||
the_Joint_1 : constant gel.hinge_Joint.view := new gel.hinge_Joint.item;
|
||||
the_Joint_2 : constant gel.hinge_Joint.view := new gel.hinge_Joint.item;
|
||||
|
||||
begin
|
||||
the_Applet.gui_World.Gravity_is ([0.0, -10.0, 0.0]);
|
||||
|
||||
the_Applet.gui_World.add (the_Box_1);
|
||||
the_Applet.gui_World.add (the_Box_2);
|
||||
the_Applet.gui_World.add (the_Box_3);
|
||||
|
||||
the_Box_1.Site_is ([ 0.0, 0.0, 0.0]);
|
||||
the_Box_2.Site_is ([ -1.0, 2.0, 0.0]);
|
||||
the_Box_3.Site_is ([ 10.0, 10.0, 0.0]);
|
||||
-- the_Box_3.Site_is (( 10.0, 10.0, 0.0));
|
||||
|
||||
declare
|
||||
use math.Algebra.linear.d3;
|
||||
|
||||
Frame_1 : constant math.Matrix_4x4 := math.Identity_4x4;
|
||||
Frame_2 : math.Matrix_4x4 := math.Identity_4x4;
|
||||
Frame_3 : math.Matrix_4x4 := math.Identity_4x4;
|
||||
|
||||
y_Rot : math.Matrix_3x3 := y_Rotation_from (to_Radians (180.0));
|
||||
begin
|
||||
set_Translation (Frame_2, [2.0, 2.0, 0.0]);
|
||||
set_Translation (Frame_3, [8.0, 8.0, 0.0]);
|
||||
-- set_Translation (Frame_3, (8.0, 8.0, 0.0));
|
||||
-- set_Translation (Frame_B, y_Rot * math.Vector_3'( -2.0, 0.0, 0.0));
|
||||
--
|
||||
-- set_Rotation (Frame_A, x_Rotation_from (to_Radians (0.0)));
|
||||
-- set_Rotation (Frame_B, y_Rot);
|
||||
|
||||
the_Joint_1.define (the_Applet.gui_World.Space,
|
||||
the_Box_3,
|
||||
Frame_3);
|
||||
|
||||
the_Joint_2.define (the_Applet.gui_World.Space,
|
||||
the_Box_1, the_Box_2,
|
||||
Frame_1, Frame_2,
|
||||
low_Limit => to_Radians (-360.0),
|
||||
high_Limit => to_Radians ( 360.0),
|
||||
collide_Conected => False);
|
||||
|
||||
-- TODO:
|
||||
-- the_Joint_2.define (the_Applet.gui_World.Space,
|
||||
-- the_Box_1, the_Box_2,
|
||||
-- pivot_Axis => (0.0, 0.0, 0.0));
|
||||
|
||||
-- the_Joint.low_Bound_is (Pitch, 0.0);
|
||||
-- the_Joint.low_Bound_is (Yaw, 0.0);
|
||||
-- the_Joint.low_Bound_is (Roll, 0.0);
|
||||
--
|
||||
-- the_Joint.high_Bound_is (Pitch, 0.0);
|
||||
-- the_Joint.high_Bound_is (Yaw, 0.0);
|
||||
-- the_Joint.high_Bound_is (Roll, 0.0);
|
||||
end;
|
||||
|
||||
the_Applet.gui_World.add (the_Joint_1.all'Access); -- Add joint to the world.
|
||||
the_Applet.gui_World.add (the_Joint_2.all'Access); -- Add joint to the world.
|
||||
end;
|
||||
|
||||
while the_Applet.is_open
|
||||
loop
|
||||
the_Applet.freshen; -- Handle any new events and update the screen.
|
||||
end loop;
|
||||
|
||||
the_Applet.destroy;
|
||||
|
||||
exception
|
||||
when E : others =>
|
||||
new_Line;
|
||||
put_Line ("Unhandled exception in main thread !");
|
||||
put_Line (ada.Exceptions.exception_Information (E));
|
||||
new_Line;
|
||||
end launch_hinged_Box;
|
||||
@@ -0,0 +1,180 @@
|
||||
with
|
||||
gel.Window.sdl,
|
||||
gel.Applet.gui_world,
|
||||
gel.Forge,
|
||||
gel.Sprite,
|
||||
gel.hinge_Joint,
|
||||
gel.ball_Joint,
|
||||
gel.cone_twist_Joint,
|
||||
gel.slider_Joint,
|
||||
gel.any_Joint,
|
||||
|
||||
openGL.Palette;
|
||||
|
||||
pragma unreferenced (gel.Window.sdl);
|
||||
|
||||
|
||||
procedure launch_mixed_Joints
|
||||
--
|
||||
-- Shows a variety of joints.
|
||||
--
|
||||
is
|
||||
package Math renames gel.Math;
|
||||
|
||||
use openGL,
|
||||
opengl.Palette;
|
||||
|
||||
the_Applet : constant gel.Applet.gui_World.view := gel.Forge.new_gui_Applet ("mixed Joints", 1536, 864);
|
||||
begin
|
||||
the_Applet.gui_World .Gravity_is ([0.0, -10.0, 0.0]);
|
||||
the_Applet.gui_Camera.Site_is ([0.0, 4.0, 30.0]); -- Position the camera.
|
||||
the_Applet.Renderer .Background_is (Grey);
|
||||
the_Applet.enable_simple_Dolly (gel.Applet.gui_world.gui_world_Id); -- Enable user camera control via keyboard.
|
||||
|
||||
-- Add joints.
|
||||
--
|
||||
declare
|
||||
use gel.Forge,
|
||||
gel.linear_Algebra_3D,
|
||||
Math;
|
||||
begin
|
||||
-- Hinge
|
||||
--
|
||||
declare
|
||||
the_hinge_Box_1 : constant gel.Sprite.view := new_box_Sprite (the_Applet.gui_World, Mass => 0.0);
|
||||
the_hinge_Box_2 : constant gel.Sprite.view := new_box_Sprite (the_Applet.gui_World);
|
||||
the_hinge_Joint : constant gel.hinge_Joint .view := new gel.hinge_Joint.item;
|
||||
|
||||
Frame_A : constant math.Matrix_4x4 := math.Identity_4x4;
|
||||
Frame_B : math.Matrix_4x4 := math.Identity_4x4;
|
||||
begin
|
||||
set_Translation (Frame_B, [2.0, 2.0, 0.0]);
|
||||
|
||||
the_hinge_Joint.define (the_Applet.gui_World.Space,
|
||||
the_hinge_Box_1, the_hinge_Box_2,
|
||||
Frame_A, Frame_B,
|
||||
collide_Conected => False);
|
||||
|
||||
the_hinge_Box_1.Site_is ([ 0.0, 0.0, 0.0]);
|
||||
the_hinge_Box_2.Site_is ([-1.0, 2.0, 0.0]);
|
||||
|
||||
the_Applet.gui_World.add (the_hinge_Box_1, and_Children => False);
|
||||
the_Applet.gui_World.add (the_hinge_Box_2, and_Children => False);
|
||||
the_Applet.gui_World.add (the_hinge_Joint.all'Access);
|
||||
end;
|
||||
|
||||
-- DoF6
|
||||
--
|
||||
declare
|
||||
the_DoF6_Box_1 : constant gel.Sprite .view := new_box_Sprite (the_Applet.gui_World, Mass => 0.0);
|
||||
the_DoF6_Box_2 : constant gel.Sprite .view := new_box_Sprite (the_Applet.gui_World);
|
||||
the_DoF6_Joint : constant gel.any_Joint.view := new gel.any_Joint.item;
|
||||
|
||||
Frame_A : constant math.Matrix_4x4 := math.Identity_4x4;
|
||||
Frame_B : math.Matrix_4x4 := math.Identity_4x4;
|
||||
begin
|
||||
set_Translation (Frame_B, [2.0, 2.0, 0.0]);
|
||||
|
||||
the_DoF6_Joint.define (the_Applet.gui_World.Space,
|
||||
the_DoF6_Box_1, the_DoF6_Box_2,
|
||||
Frame_A, Frame_B);
|
||||
|
||||
the_DoF6_Box_1.Site_is ([-20.0, 0.0, 0.0]);
|
||||
the_DoF6_Box_2.Site_is ([-20.0 - 2.0, 0.0, 2.0]);
|
||||
|
||||
the_Applet.gui_World.add (the_DoF6_Box_1);
|
||||
the_Applet.gui_World.add (the_DoF6_Box_2);
|
||||
the_Applet.gui_World.add (the_DoF6_Joint.all'Access);
|
||||
end;
|
||||
|
||||
-- Ball
|
||||
--
|
||||
declare
|
||||
the_ball_Box_1 : constant gel.Sprite .view := new_box_Sprite (the_Applet.gui_World, Mass => 0.0);
|
||||
the_ball_Box_2 : constant gel.Sprite .view := new_box_Sprite (the_Applet.gui_World);
|
||||
the_ball_Joint : constant gel.ball_Joint.view := new gel.ball_Joint.item;
|
||||
|
||||
Pivot_in_A : constant math.Vector_3 := [0.0, -1.0, 0.0];
|
||||
Pivot_in_B : constant math.Vector_3 := [0.0, 1.0, 0.0];
|
||||
begin
|
||||
the_ball_Joint.define (the_Applet.gui_World.Space,
|
||||
the_ball_Box_1, the_ball_Box_2,
|
||||
Pivot_in_A, Pivot_in_B);
|
||||
|
||||
the_ball_Box_1.Site_is ([-10.0, 0.0, 0.0]);
|
||||
the_ball_Box_2.Site_is ([-10.0 - 2.0, 0.0, 2.0]);
|
||||
|
||||
the_Applet.gui_World.add (the_ball_Box_1);
|
||||
the_Applet.gui_World.add (the_ball_Box_2);
|
||||
the_Applet.gui_World.add (the_ball_Joint.all'Access);
|
||||
end;
|
||||
|
||||
-- Slider
|
||||
--
|
||||
declare
|
||||
the_slider_Box_1 : constant gel.Sprite .view := new_box_Sprite (the_Applet.gui_World, Mass => 0.0);
|
||||
the_slider_Box_2 : constant gel.Sprite .view := new_box_Sprite (the_Applet.gui_World);
|
||||
the_slider_Joint : constant gel.slider_Joint.view := new gel.slider_Joint.item;
|
||||
|
||||
Frame_A : math.Matrix_4x4 := math.Identity_4x4;
|
||||
Frame_B : math.Matrix_4x4 := math.Identity_4x4;
|
||||
|
||||
y_Rot : math.Matrix_3x3 := y_Rotation_from (to_Radians (45.0));
|
||||
x_Rot : math.Matrix_3x3 := x_Rotation_from (to_Radians (45.0));
|
||||
begin
|
||||
set_Translation (Frame_A, [-4.0, 4.0, -4.0]);
|
||||
set_Translation (Frame_B, [ 4.0, 0.0, 0.0]);
|
||||
-- set_Rotation (Frame_A, x_Rot);
|
||||
-- set_Rotation (Frame_B, x_Rot);
|
||||
|
||||
the_slider_Joint.define (the_Applet.gui_World.Space,
|
||||
the_slider_Box_1, the_slider_Box_2,
|
||||
Frame_A, Frame_B);
|
||||
|
||||
the_slider_Box_1.Site_is ([-10.0, 10.0, 0.0]);
|
||||
the_slider_Box_2.Site_is ([-10.0 - 2.0, 15.0, 0.0]);
|
||||
|
||||
the_Applet.gui_World.add (the_slider_Box_1);
|
||||
the_Applet.gui_World.add (the_slider_Box_2);
|
||||
the_Applet.gui_World.add (the_slider_Joint.all'Access);
|
||||
end;
|
||||
|
||||
-- cone Twist
|
||||
--
|
||||
declare
|
||||
the_cone_twist_Box_1 : constant gel.Sprite .view := new_box_Sprite (the_Applet.gui_World, Mass => 0.0);
|
||||
the_cone_twist_Box_2 : constant gel.Sprite .view := new_box_Sprite (the_Applet.gui_World);
|
||||
the_cone_twist_Joint : constant gel.cone_twist_Joint.view := new gel.cone_twist_Joint.item;
|
||||
|
||||
Frame_A : constant math.Matrix_4x4 := math.Identity_4x4;
|
||||
Frame_B : math.Matrix_4x4 := math.Identity_4x4;
|
||||
|
||||
y_Rot : math.Matrix_3x3 := y_Rotation_from (to_Radians (45.0));
|
||||
x_Rot : math.Matrix_3x3 := x_Rotation_from (to_Radians (45.0));
|
||||
begin
|
||||
-- set_Translation (Frame_A, ( -4.0, 4.0, -4.0));
|
||||
set_Translation (Frame_B, [4.0, 0.0, 0.0]);
|
||||
-- set_Rotation (Frame_A, x_Rot);
|
||||
-- set_Rotation (Frame_B, x_Rot);
|
||||
|
||||
the_cone_twist_Joint.define (the_Applet.gui_World.Space,
|
||||
the_cone_twist_Box_1, the_cone_twist_Box_2,
|
||||
Frame_A, Frame_B);
|
||||
|
||||
the_cone_twist_Box_1.Site_is ([10.0, 10.0, 0.0]);
|
||||
the_cone_twist_Box_2.Site_is ([10.0 + 2.0, 10.0, 0.0]);
|
||||
|
||||
the_Applet.gui_World.add (the_cone_twist_Box_1);
|
||||
the_Applet.gui_World.add (the_cone_twist_Box_2);
|
||||
the_Applet.gui_World.add (the_cone_twist_Joint.all'Access);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
while the_Applet.is_open
|
||||
loop
|
||||
the_Applet.freshen; -- Handle any new events, evolve the world and update the screen.
|
||||
end loop;
|
||||
|
||||
the_Applet.destroy;
|
||||
end launch_mixed_Joints;
|
||||
17
4-high/gel/applet/demo/sprite/mixed_joints/mixed_joints.gpr
Normal file
17
4-high/gel/applet/demo/sprite/mixed_joints/mixed_joints.gpr
Normal file
@@ -0,0 +1,17 @@
|
||||
with
|
||||
"gel",
|
||||
"lace_shared";
|
||||
|
||||
project mixed_Joints
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_mixed_joints.adb");
|
||||
for Languages use ("Ada");
|
||||
|
||||
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 mixed_Joints;
|
||||
@@ -0,0 +1,227 @@
|
||||
with
|
||||
gel.Window.setup,
|
||||
gel.Applet.gui_world,
|
||||
|
||||
gel.Forge,
|
||||
gel.Sprite,
|
||||
|
||||
gel.Joint,
|
||||
|
||||
opengl.Palette,
|
||||
Physics,
|
||||
ada.Text_IO,
|
||||
ada.Exceptions;
|
||||
|
||||
pragma unreferenced (gel.Window.setup);
|
||||
|
||||
|
||||
procedure launch_mixed_Joints_2d
|
||||
--
|
||||
-- Drops a variety of shapes a plane terrain.
|
||||
--
|
||||
--
|
||||
is
|
||||
package Math renames gel.Math;
|
||||
|
||||
use openGL,
|
||||
opengl.Palette,
|
||||
ada.Text_IO;
|
||||
|
||||
the_Applet : constant gel.Applet.gui_World.view := gel.Forge.new_gui_Applet ("Mixed 2D Joints",
|
||||
1920, 1200,
|
||||
space_Kind => Physics.Box2D);
|
||||
Counter : Natural := 0;
|
||||
|
||||
begin
|
||||
the_Applet.gui_World .Gravity_is ([0.0, -10.0, 0.0]);
|
||||
the_Applet.gui_Camera.Site_is ([0.0, 4.0, 30.0]); -- Position the camera.
|
||||
the_Applet.Renderer .Background_is (Grey);
|
||||
the_Applet.enable_simple_Dolly (1); -- Enable user camera control via keyboard.
|
||||
|
||||
-- Add joints.
|
||||
--
|
||||
declare
|
||||
use gel.Forge,
|
||||
Math;
|
||||
begin
|
||||
-- Hinge
|
||||
--
|
||||
declare
|
||||
the_hinge_Box_1 : constant gel.Sprite.view := new_circle_Sprite (the_Applet.gui_World, mass => 0.0);
|
||||
the_hinge_Box_2 : constant gel.Sprite.view := new_circle_Sprite (the_Applet.gui_World, mass => 1.0);
|
||||
new_Joint : gel. Joint .view;
|
||||
|
||||
Frame_A : constant math.Matrix_4x4 := math.Identity_4x4;
|
||||
Frame_B : constant math.Matrix_4x4 := math.Identity_4x4;
|
||||
begin
|
||||
the_hinge_Box_1.Site_is ([ 0.0, 0.0, 0.0]);
|
||||
the_hinge_Box_2.Site_is ([-10.0, 0.0, 0.0]);
|
||||
|
||||
|
||||
the_hinge_Box_1.attach_via_Hinge (the_Child => the_hinge_Box_2,
|
||||
Frame_in_parent => Frame_A,
|
||||
Frame_in_child => Frame_B,
|
||||
Limits => (0.0, to_Radians (355.0)),
|
||||
collide_Connected => False,
|
||||
new_joint => new_Joint);
|
||||
-- the_hinge_Joint := gel.hinge_Joint .view (new_Joint);
|
||||
|
||||
the_Applet.gui_World.add (the_hinge_Box_1, and_children => True);
|
||||
end;
|
||||
|
||||
-- -- DoF6
|
||||
-- --
|
||||
-- declare
|
||||
-- use gel.any_Joint,
|
||||
-- math.Vectors;
|
||||
--
|
||||
-- the_dof6_Box_1 : constant gel.Sprite.local.view := new_box_Sprite (the_Applet.gui_World, mass => 0.0);
|
||||
-- the_dof6_Box_2 : constant gel.Sprite.local.view := new_box_Sprite (the_Applet.gui_World);
|
||||
-- the_DoF6_Joint : gel.any_Joint .view := new gel.any_Joint.item;
|
||||
--
|
||||
-- Frame_A : math.Matrix_4x4 := math.Identity_4x4;
|
||||
-- Frame_B : math.Matrix_4x4 := math.Identity_4x4;
|
||||
-- begin
|
||||
-- set_Translation (Frame_B, ( 2.0, 2.0, 0.0));
|
||||
--
|
||||
-- the_dof6_Joint.define (the_Applet.gui_World.Physics,
|
||||
-- the_dof6_Box_1, the_dof6_Box_2,
|
||||
-- Frame_A, Frame_B);
|
||||
--
|
||||
-- the_dof6_Box_1.Site_is ((-20.0, 0.0, 0.0));
|
||||
-- the_dof6_Box_2.Site_is ((-20.0 - 2.0, 0.0, 2.0));
|
||||
--
|
||||
-- the_Applet.gui_World.add (the_dof6_Box_1);
|
||||
-- the_Applet.gui_World.add (the_dof6_Box_2);
|
||||
-- the_Applet.gui_World.add (the_dof6_Joint.all'Access);
|
||||
-- end;
|
||||
--
|
||||
-- -- Ball
|
||||
-- --
|
||||
-- declare
|
||||
-- use gel.any_Joint,
|
||||
-- math.Vectors;
|
||||
--
|
||||
-- the_ball_Box_1 : constant gel.Sprite.local.view := new_box_Sprite (the_Applet.gui_World, mass => 0.0);
|
||||
-- the_ball_Box_2 : constant gel.Sprite.local.view := new_box_Sprite (the_Applet.gui_World);
|
||||
-- the_ball_Joint : gel.ball_Joint .view := new gel.ball_Joint.item;
|
||||
--
|
||||
-- Pivot_in_A : math.Vector_3 := (0.0, -1.0, 0.0);
|
||||
-- Pivot_in_B : math.Vector_3 := (0.0, 1.0, 0.0);
|
||||
-- begin
|
||||
-- the_ball_Joint.define (the_Applet.gui_World.Physics,
|
||||
-- the_ball_Box_1, the_ball_Box_2,
|
||||
-- Pivot_in_A, Pivot_in_B);
|
||||
--
|
||||
-- the_ball_Box_1.Site_is ((-10.0, 0.0, 0.0));
|
||||
-- the_ball_Box_2.Site_is ((-10.0 - 2.0, 0.0, 2.0));
|
||||
--
|
||||
-- the_Applet.gui_World.add (the_ball_Box_1);
|
||||
-- the_Applet.gui_World.add (the_ball_Box_2);
|
||||
-- the_Applet.gui_World.add (the_ball_Joint.all'Access);
|
||||
-- end;
|
||||
--
|
||||
-- -- Slider
|
||||
-- --
|
||||
-- declare
|
||||
-- use gel.any_Joint,
|
||||
-- math.Vectors;
|
||||
--
|
||||
-- the_slider_Box_1 : constant gel.Sprite.local.view := new_box_Sprite (the_Applet.gui_World, mass => 0.0);
|
||||
-- the_slider_Box_2 : constant gel.Sprite.local.view := new_box_Sprite (the_Applet.gui_World);
|
||||
-- the_slider_Joint : gel.slider_Joint.view := new gel.slider_Joint.item;
|
||||
--
|
||||
-- Frame_A : math.Matrix_4x4 := math.Identity_4x4;
|
||||
-- Frame_B : math.Matrix_4x4 := math.Identity_4x4;
|
||||
--
|
||||
-- y_Rot : math.Matrix_3x3 := y_Rotation_from (to_Radians (45.0));
|
||||
-- x_Rot : math.Matrix_3x3 := x_Rotation_from (to_Radians (45.0));
|
||||
-- begin
|
||||
-- set_Translation (Frame_A, ( -4.0, 4.0, -4.0));
|
||||
-- set_Translation (Frame_B, ( 4.0, 0.0, 0.0));
|
||||
-- -- set_Rotation (Frame_A, x_Rot);
|
||||
-- -- set_Rotation (Frame_B, x_Rot);
|
||||
--
|
||||
-- the_slider_Joint.define (the_Applet.gui_World.Physics,
|
||||
-- the_slider_Box_1, the_slider_Box_2,
|
||||
-- Frame_A, Frame_B);
|
||||
--
|
||||
-- the_slider_Box_1.Site_is ((-10.0, 10.0, 0.0));
|
||||
-- the_slider_Box_2.Site_is ((-10.0 - 2.0, 15.0, 0.0));
|
||||
--
|
||||
-- the_Applet.gui_World.add (the_slider_Box_1);
|
||||
-- the_Applet.gui_World.add (the_slider_Box_2);
|
||||
-- the_Applet.gui_World.add (the_slider_Joint.all'Access);
|
||||
-- end;
|
||||
--
|
||||
-- -- cone Twist
|
||||
-- --
|
||||
-- declare
|
||||
-- use gel.any_Joint,
|
||||
-- math.Vectors;
|
||||
--
|
||||
-- the_cone_twist_Box_1 : constant gel.Sprite.local.view := new_box_Sprite (the_Applet.gui_World, mass => 0.0);
|
||||
-- the_cone_twist_Box_2 : constant gel.Sprite.local.view := new_box_Sprite (the_Applet.gui_World);
|
||||
-- the_cone_twist_Joint : gel.cone_twist_Joint.view := new gel.cone_twist_Joint.item;
|
||||
--
|
||||
-- Frame_A : math.Matrix_4x4 := math.Identity_4x4;
|
||||
-- Frame_B : math.Matrix_4x4 := math.Identity_4x4;
|
||||
--
|
||||
-- y_Rot : math.Matrix_3x3 := y_Rotation_from (to_Radians (45.0));
|
||||
-- x_Rot : math.Matrix_3x3 := x_Rotation_from (to_Radians (45.0));
|
||||
-- begin
|
||||
-- -- set_Translation (Frame_A, ( -4.0, 4.0, -4.0));
|
||||
-- set_Translation (Frame_B, ( 4.0, 0.0, 0.0));
|
||||
-- -- set_Rotation (Frame_A, x_Rot);
|
||||
-- -- set_Rotation (Frame_B, x_Rot);
|
||||
--
|
||||
-- the_cone_twist_Joint.define (the_Applet.gui_World.Physics,
|
||||
-- the_cone_twist_Box_1, the_cone_twist_Box_2,
|
||||
-- Frame_A, Frame_B);
|
||||
--
|
||||
-- the_cone_twist_Box_1.Site_is ((10.0, 10.0, 0.0));
|
||||
-- the_cone_twist_Box_2.Site_is ((10.0 + 2.0, 10.0, 0.0));
|
||||
--
|
||||
-- the_Applet.gui_World.add (the_cone_twist_Box_1);
|
||||
-- the_Applet.gui_World.add (the_cone_twist_Box_2);
|
||||
-- the_Applet.gui_World.add (the_cone_twist_Joint.all'Access);
|
||||
-- end;
|
||||
|
||||
declare
|
||||
Added : Boolean := True;
|
||||
begin
|
||||
while the_Applet.is_open
|
||||
loop
|
||||
Counter := Counter + 1;
|
||||
|
||||
-- if false -- Counter mod (1*60) = 0
|
||||
-- then
|
||||
-- if Added then
|
||||
-- the_Applet.gui_World.rid (the_hinge_Joint.all'Access);
|
||||
-- -- the_Applet.gui_World.rid (the_hinge_Box_1);
|
||||
-- -- the_Applet.gui_World.rid (the_hinge_Box_2);
|
||||
-- Added := False;
|
||||
-- else
|
||||
-- -- the_Applet.gui_World.add (the_hinge_Box_1);
|
||||
-- -- the_Applet.gui_World.add (the_hinge_Box_2);
|
||||
-- the_Applet.gui_World.add (the_hinge_Joint.all'Access);
|
||||
-- Added := True;
|
||||
-- end if;
|
||||
-- end if;
|
||||
|
||||
the_Applet.freshen; -- Handle any new events and update the screen.
|
||||
end loop;
|
||||
|
||||
the_Applet.destroy;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
|
||||
exception
|
||||
when E : others =>
|
||||
new_Line;
|
||||
put_Line ("Unhandled exception in main thread !");
|
||||
put_Line (Ada.Exceptions.Exception_Information (E));
|
||||
new_Line;
|
||||
end launch_mixed_Joints_2d;
|
||||
@@ -0,0 +1,17 @@
|
||||
with
|
||||
"gel",
|
||||
"lace_shared";
|
||||
|
||||
project mixed_Joints_2D
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_mixed_joints_2d.adb");
|
||||
for Languages use ("Ada");
|
||||
|
||||
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 mixed_Joints_2D;
|
||||
@@ -0,0 +1,315 @@
|
||||
with
|
||||
gel.Window.sdl,
|
||||
gel.Applet.gui_world,
|
||||
gel.Forge,
|
||||
gel.Sprite,
|
||||
-- gel.Terrain,
|
||||
|
||||
physics.Model,
|
||||
|
||||
openGL.Model.box.colored,
|
||||
openGL.Model.sphere.lit_colored_textured,
|
||||
openGL.Model.capsule.lit_colored_textured,
|
||||
openGL.Model.any,
|
||||
openGL.Model.terrain,
|
||||
openGL.IO,
|
||||
openGL.Light,
|
||||
openGL.Palette;
|
||||
|
||||
pragma unreferenced (gel.Window.sdl);
|
||||
|
||||
|
||||
procedure launch_mixed_Shapes
|
||||
--
|
||||
-- Drops a variety of shapes onto a terrain.
|
||||
--
|
||||
is
|
||||
use gel.Math,
|
||||
openGL,
|
||||
openGL.Model.box,
|
||||
opengl.Palette;
|
||||
|
||||
the_Applet : constant gel.Applet.gui_World.view := gel.Forge.new_gui_Applet ("mixed Shapes", 1536, 864);
|
||||
|
||||
x : math.Real := 0.0;
|
||||
y : math.Real := 2.0;
|
||||
|
||||
-----------
|
||||
-- Terrain
|
||||
--
|
||||
|
||||
-- Plane
|
||||
--
|
||||
-- the_plane_Model : constant openGL.Model.box.colored.view
|
||||
-- := openGL.Model.box.colored.new_Box (size => (1000.0, 0.05, 1000.0),
|
||||
-- faces => (front => (colors => (others => (Red, Opaque))),
|
||||
-- rear => (colors => (others => (Blue, Opaque))),
|
||||
-- upper => (colors => (others => (Green, Opaque))),
|
||||
-- lower => (colors => (others => (Yellow, Opaque))),
|
||||
-- left => (colors => (others => (Cyan, Opaque))),
|
||||
-- right => (colors => (others => (Magenta, Opaque)))));
|
||||
-- the_plane_physics_Model : constant physics.Model.view
|
||||
-- := physics.Model.Forge.new_physics_Model (shape_Info => (kind => physics.Model.Plane,
|
||||
-- plane_Normal => (0.00, 1.0, 0.00),
|
||||
-- plane_Offset => 0.0));
|
||||
-- the_Plane : constant gel.Sprite.view
|
||||
-- := gel.Sprite.forge.new_Sprite ("demo.Plane",
|
||||
-- the_Applet.gui_World.all'Access,
|
||||
-- math.Origin_3d,
|
||||
-- the_plane_Model.all'Access,
|
||||
-- the_plane_physics_Model);
|
||||
|
||||
|
||||
-- Heightfield
|
||||
--
|
||||
function to_Heightfield (From : in openGL.height_Map) return physics.Heightfield
|
||||
is
|
||||
Result : physics.Heightfield (1 .. Integer (From'Last (1)),
|
||||
1 .. Integer (From'Last (2)));
|
||||
Last_i : constant Index_t := From'Last (1);
|
||||
begin
|
||||
for i in Result'Range (1)
|
||||
loop
|
||||
for j in Result'Range (1)
|
||||
loop
|
||||
Result (i, j) := math.Real (From (Last_i - Index_t (i) + 1,
|
||||
Index_t (j)));
|
||||
end loop;
|
||||
end loop;
|
||||
|
||||
return Result;
|
||||
end to_Heightfield;
|
||||
|
||||
|
||||
terrain_Heights : constant openGL.asset_Name := to_Asset ("assets/gel/kidwelly-terrain.png");
|
||||
terrain_Texture : constant openGL.asset_Name := to_Asset ("assets/gel/kidwelly-terrain-texture.png");
|
||||
|
||||
hs : constant := 1.0;
|
||||
|
||||
gl_Heights : constant openGL.IO.height_Map_view := openGL.IO.to_height_Map (image_Filename => terrain_Heights,
|
||||
Scale => 2.0);
|
||||
|
||||
the_heightfield_Model : constant openGL.Model.terrain.view
|
||||
:= openGL.Model.terrain.new_Terrain (heights_Asset => terrain_Heights,
|
||||
Row => 1,
|
||||
Col => 1,
|
||||
Heights => openGL.Model.terrain.height_Map_view (gl_Heights),
|
||||
color_Map => terrain_Texture,
|
||||
Tiling => (s => (0.0, 1.0),
|
||||
t => (0.0, 1.0)));
|
||||
|
||||
the_heightfield_physics_Model : constant physics.Model.view
|
||||
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.heightfield,
|
||||
Heights => new physics.Heightfield' (to_Heightfield (gl_Heights.all)),
|
||||
height_Range => [0.0, 200.0]),
|
||||
Scale => [hs, 1.0, hs]);
|
||||
the_Heightfield : constant gel.Sprite.view
|
||||
:= gel.Sprite.forge.new_Sprite ("demo.Hull",
|
||||
the_Applet.gui_World.all'Access,
|
||||
Origin_3D,
|
||||
the_Heightfield_Model,
|
||||
the_Heightfield_physics_Model);
|
||||
begin
|
||||
-- Applet.
|
||||
--
|
||||
the_Applet.gui_Camera.Site_is ([0.0, 4.0, 30.0]); -- Position the camera.
|
||||
|
||||
the_Applet.enable_simple_Dolly (in_World => the_Applet.gui_World.Id); -- Enable user camera control via keyboard.
|
||||
the_Applet.Dolly.Speed_is (0.1);
|
||||
|
||||
the_Applet.Renderer.Background_is (Blue);
|
||||
|
||||
-- Set the lights position.
|
||||
--
|
||||
declare
|
||||
Light : openGL.Light.item := the_Applet.Renderer.new_Light;
|
||||
begin
|
||||
Light.Site_is ([0.0, 1000.0, 0.0]);
|
||||
the_Applet.Renderer.set (Light);
|
||||
end;
|
||||
|
||||
-- Terrain.
|
||||
--
|
||||
the_Applet.gui_World.add (the_heightfield); -- Add heightfield.
|
||||
|
||||
-- Add several of each shape.
|
||||
--
|
||||
for i in 1 .. 5
|
||||
loop
|
||||
declare
|
||||
-- Box
|
||||
--
|
||||
the_box_Model : constant openGL.Model.box.colored.view
|
||||
:= openGL.Model.box.colored.new_Box (Size => [1.0, 1.0, 1.0],
|
||||
Faces => [Front => (Colors => [others => (Red, Opaque)]),
|
||||
Rear => (Colors => [others => (Blue, Opaque)]),
|
||||
Upper => (Colors => [others => (Violet, Opaque)]),
|
||||
Lower => (Colors => [others => (Yellow, Opaque)]),
|
||||
Left => (Colors => [others => (Cyan, Opaque)]),
|
||||
Right => (Colors => [others => (Magenta, Opaque)])]);
|
||||
the_box_physics_Model : constant physics.Model.view
|
||||
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.Cube,
|
||||
half_Extents => the_box_Model.Size / 2.0),
|
||||
Mass => 1.0);
|
||||
|
||||
the_Box : constant gel.Sprite.view
|
||||
:= gel.Sprite.forge.new_Sprite ("demo.Box",
|
||||
the_Applet.gui_World.all'Access,
|
||||
Origin_3D,
|
||||
the_box_Model.all'Access,
|
||||
the_box_physics_Model);
|
||||
|
||||
-- Ball
|
||||
--
|
||||
the_ball_physics_Model : constant physics.Model.view
|
||||
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.a_sphere,
|
||||
sphere_Radius => 1.0),
|
||||
Mass => 1.0);
|
||||
|
||||
the_ball_Model : constant openGL.Model.sphere.lit_colored_textured.view
|
||||
:= openGL.Model.sphere.lit_colored_textured.new_Sphere (Radius => 1.0,
|
||||
Image => openGL.to_Asset ("assets/gel/golf_green-16x16.tga"));
|
||||
the_Ball : constant gel.Sprite.view
|
||||
:= gel.Sprite.forge.new_Sprite ("demo.Ball",
|
||||
the_Applet.gui_World.all'Access,
|
||||
Origin_3D,
|
||||
the_ball_Model,
|
||||
the_ball_physics_Model);
|
||||
|
||||
-- Cone
|
||||
--
|
||||
the_cone_Model : constant openGL.Model.any.view
|
||||
:= openGL.Model.any.new_Model (Model => openGL.to_Asset ("assets/gel/model/unit_cone.obj"),
|
||||
Texture => openGL.null_Asset,
|
||||
Texture_is_lucid => False);
|
||||
|
||||
the_cone_physics_Model : constant physics.Model.view
|
||||
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.cone),
|
||||
Mass => 1.0);
|
||||
the_Cone : constant gel.Sprite.view
|
||||
:= gel.Sprite.forge.new_Sprite ("demo.Cone",
|
||||
the_Applet.gui_World.all'Access,
|
||||
Origin_3D,
|
||||
the_cone_Model.all'Access,
|
||||
the_cone_physics_Model);
|
||||
-- Cylinder
|
||||
--
|
||||
the_cylinder_Model : constant openGL.Model.any.view
|
||||
:= openGL.Model.any.new_Model (Model => openGL.to_Asset ("assets/gel/model/unit_cylinder.obj"),
|
||||
Texture => openGL.null_Asset,
|
||||
Texture_is_lucid => False);
|
||||
|
||||
the_cylinder_physics_Model : constant physics.Model.view
|
||||
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.cylinder,
|
||||
half_Extents => [1.0, 1.0, 1.0] / 2.0),
|
||||
Mass => 1.0);
|
||||
|
||||
the_Cylinder : constant gel.Sprite.view
|
||||
:= gel.Sprite.forge.new_Sprite ("demo.Cylinder",
|
||||
the_Applet.gui_World.all'Access,
|
||||
Origin_3D,
|
||||
the_cylinder_Model.all'Access,
|
||||
the_cylinder_physics_Model);
|
||||
-- Capsule
|
||||
--
|
||||
the_capsule_Model : constant openGL.Model.capsule.lit_colored_textured.view
|
||||
:= openGL.Model.capsule.lit_colored_textured.new_Capsule (Radius => 0.5,
|
||||
Height => 0.0,
|
||||
Color => (palette.Green, Opaque));
|
||||
|
||||
the_capsule_physics_Model : constant physics.Model.view
|
||||
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.a_Capsule,
|
||||
lower_Radius => 0.5,
|
||||
upper_Radius => 0.5,
|
||||
Height => 1.0),
|
||||
Mass => 1.0);
|
||||
the_Capsule : constant gel.Sprite.view
|
||||
:= gel.Sprite.forge.new_Sprite ("demo.Capsule",
|
||||
the_Applet.gui_World.all'Access,
|
||||
Origin_3D,
|
||||
the_capsule_Model.all'Access,
|
||||
the_capsule_physics_Model);
|
||||
|
||||
-- multi_Sphere
|
||||
--
|
||||
the_multi_Sphere_Model : constant openGL.Model.capsule.lit_colored_textured.view
|
||||
:= openGL.Model.capsule.lit_colored_textured.new_Capsule (Radius => 0.5,
|
||||
Height => 0.0,
|
||||
Color => (palette.Green, Opaque),
|
||||
Image => openGL.to_Asset ("assets/gel/golf_green-16x16.tga"));
|
||||
|
||||
the_multi_Sphere_physics_Model : constant physics.Model.view
|
||||
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.multi_Sphere,
|
||||
Sites => new physics.Vector_3_array' ([-0.5, 0.0, 0.0],
|
||||
[ 0.5, 0.0, 0.0]),
|
||||
Radii => new gel.math.Vector' (1 => 0.5,
|
||||
2 => 0.5)),
|
||||
Mass => 1.0);
|
||||
|
||||
the_multi_Sphere : constant gel.Sprite.view
|
||||
:= gel.Sprite.forge.new_Sprite ("demo.multi_Sphere",
|
||||
the_Applet.gui_World.all'Access,
|
||||
Origin_3D,
|
||||
the_multi_Sphere_Model.all'Access,
|
||||
the_multi_Sphere_physics_Model);
|
||||
|
||||
-- Hull
|
||||
--
|
||||
s : constant := 0.5;
|
||||
the_hull_Model : constant openGL.Model.box.colored.view
|
||||
:= openGL.Model.box.colored.new_Box (Size => [s*2.0, s*2.0, s*2.0],
|
||||
Faces => [Front => (Colors => [others => (Shade_of (Grey, 1.0), Opaque)]),
|
||||
Rear => (Colors => [others => (Shade_of (Grey, 0.5), Opaque)]),
|
||||
Upper => (Colors => [others => (Shade_of (Grey, 0.4), Opaque)]),
|
||||
Lower => (Colors => [others => (Shade_of (Grey, 0.3), Opaque)]),
|
||||
Left => (Colors => [others => (Shade_of (Grey, 0.2), Opaque)]),
|
||||
Right => (Colors => [others => (Shade_of (Grey, 0.1), Opaque)])]);
|
||||
the_hull_physics_Model : constant physics.Model.view
|
||||
:= physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.hull,
|
||||
Points => new physics.Vector_3_array' ([-s, -s, s],
|
||||
[ s, -s, s],
|
||||
[ s, s, s],
|
||||
[-s, s, s],
|
||||
|
||||
[-s, -s, -s],
|
||||
[ s, -s, -s],
|
||||
[ s, s, -s],
|
||||
[-s, s, -s])),
|
||||
Mass => 1.0);
|
||||
the_Hull : constant gel.Sprite.view
|
||||
:= gel.Sprite.forge.new_Sprite ("demo.Hull",
|
||||
the_Applet.gui_World.all'Access,
|
||||
Origin_3D,
|
||||
the_hull_Model.all'Access,
|
||||
the_hull_physics_Model);
|
||||
begin
|
||||
the_Applet.gui_World.add (the_Ball);
|
||||
the_Applet.gui_World.add (the_Box);
|
||||
the_Applet.gui_World.add (the_Cone);
|
||||
the_Applet.gui_World.add (the_Cylinder);
|
||||
the_Applet.gui_World.add (the_Capsule);
|
||||
the_Applet.gui_World.add (the_multi_Sphere);
|
||||
the_Applet.gui_World.add (the_Hull);
|
||||
|
||||
the_Ball .Site_is ([ x, y, 0.0]);
|
||||
the_Box .Site_is ([ 0.0, y, -2.5]);
|
||||
the_Cone .Site_is ([ 0.0, y, 0.0]);
|
||||
the_Capsule .Site_is ([ 0.0 + X, y, 0.0 + x]);
|
||||
the_Cylinder .Site_is ([ 0.0, y, 4.4]);
|
||||
the_Hull .Site_is ([ 4.0, y, 4.4]);
|
||||
the_multi_Sphere.Site_is ([-4.0, y, 4.4]);
|
||||
|
||||
x := x + 2.0;
|
||||
y := y + 2.0;
|
||||
end;
|
||||
|
||||
end loop;
|
||||
|
||||
|
||||
while the_Applet.is_open
|
||||
loop
|
||||
the_Applet.freshen; -- Handle any new events, evolve physics and update the screen.
|
||||
end loop;
|
||||
|
||||
the_Applet.destroy;
|
||||
end launch_mixed_Shapes;
|
||||
17
4-high/gel/applet/demo/sprite/mixed_shapes/mixed_shapes.gpr
Normal file
17
4-high/gel/applet/demo/sprite/mixed_shapes/mixed_shapes.gpr
Normal file
@@ -0,0 +1,17 @@
|
||||
with
|
||||
"gel",
|
||||
"lace_shared";
|
||||
|
||||
project mixed_Shapes
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_mixed_shapes.adb");
|
||||
for Languages use ("Ada");
|
||||
|
||||
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 mixed_Shapes;
|
||||
@@ -0,0 +1,64 @@
|
||||
with
|
||||
gel.Window.sdl,
|
||||
gel.Applet.gui_world,
|
||||
gel.Forge,
|
||||
gel.Sprite,
|
||||
|
||||
openGL.Palette,
|
||||
openGL.Model.text.lit_colored,
|
||||
|
||||
Physics;
|
||||
|
||||
pragma unreferenced (gel.Window.sdl);
|
||||
|
||||
|
||||
procedure launch_text_sprite_Demo
|
||||
--
|
||||
-- Shows a few text sprites.
|
||||
--
|
||||
is
|
||||
use gel.Math,
|
||||
openGL.Palette;
|
||||
|
||||
the_Applet : constant gel.Applet.gui_World.view := gel.forge.new_gui_Applet ("text sprite Demo",
|
||||
space_Kind => physics.Bullet);
|
||||
|
||||
the_Text_1 : constant gel.Sprite.view := gel.forge.new_text_Sprite (the_Applet.gui_World,
|
||||
Origin_3D,
|
||||
"Howdy",
|
||||
the_Applet.Font,
|
||||
Green);
|
||||
|
||||
the_Text_2 : constant gel.Sprite.view := gel.forge.new_text_Sprite (the_Applet.gui_World,
|
||||
Origin_3D,
|
||||
"Doody",
|
||||
the_Applet.Font,
|
||||
Green);
|
||||
text_1_Model : constant openGL.Model.text.lit_colored.view
|
||||
:= openGL.Model.text.lit_colored.view (the_Text_1.graphics_Model);
|
||||
begin
|
||||
the_Applet.gui_Camera.Site_is ([0.0, 0.0, 50.0]); -- Position the camera.
|
||||
the_Applet.enable_simple_Dolly (1); -- Enable user camera control via keyboards.
|
||||
|
||||
the_Applet.gui_World.add (the_Text_1);
|
||||
the_Applet.gui_World.add (the_Text_2);
|
||||
|
||||
the_Text_2.Site_is ([0.0, 10.0, 0.0]);
|
||||
|
||||
while the_Applet.is_open
|
||||
loop
|
||||
if text_1_Model.Text = "Yay"
|
||||
then
|
||||
text_1_Model.Text_is ("Howdy");
|
||||
else
|
||||
text_1_Model.Text_is ("Yay");
|
||||
end if;
|
||||
|
||||
the_Applet.gui_World.evolve;
|
||||
the_Applet.freshen; -- Handle any new events and update the screen.
|
||||
|
||||
delay 0.5;
|
||||
end loop;
|
||||
|
||||
the_Applet.destroy;
|
||||
end launch_text_sprite_Demo;
|
||||
17
4-high/gel/applet/demo/sprite/text/text_sprite_demo.gpr
Normal file
17
4-high/gel/applet/demo/sprite/text/text_sprite_demo.gpr
Normal file
@@ -0,0 +1,17 @@
|
||||
with
|
||||
"gel",
|
||||
"lace_shared";
|
||||
|
||||
project text_sprite_Demo
|
||||
is
|
||||
for Object_Dir use "build";
|
||||
for Exec_Dir use ".";
|
||||
for Main use ("launch_text_sprite_demo.adb");
|
||||
for Languages use ("Ada");
|
||||
|
||||
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 text_sprite_Demo;
|
||||
Reference in New Issue
Block a user