Add initial prototype.

This commit is contained in:
Rod Kay
2022-07-31 17:34:54 +10:00
commit 54a53b2ac0
1421 changed files with 358874 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
with
"physics",
"lace_shared";
project Hello_Physics_2D_Demo
is
for Object_Dir use "build";
for Exec_Dir use ".";
for Main use ("launch_hello_physics_interface_2d_demo.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 Linker_Options use ("-g");
end Linker;
end Hello_Physics_2D_Demo;

View File

@@ -0,0 +1,50 @@
with
physics.Space,
physics.Shape,
physics.Object,
physics.Forge,
ada.Text_IO;
procedure launch_hello_physics_interface_2D_Demo
--
-- Drops a circle onto a rectangle.
--
is
use physics.Math,
physics.Forge,
ada.Text_IO;
the_Space : constant physics.Space .view := new_Space (Physics.Box2d);
the_Sphere : constant physics.Shape .view := the_Space.new_circle_Shape;
the_Box : constant physics.Shape .view := the_Space.new_polygon_Shape (Vertices => (1 => (-1.0, -1.0),
2 => ( 1.0, -1.0),
3 => ( 1.0, 1.0),
4 => (-1.0, 1.0)));
the_Ball : constant physics.Object.view := the_Space.new_Object (of_Shape => the_Sphere,
of_Mass => 1.0,
Friction => 0.5,
Restitution => 0.5,
at_Site => (0.0, 10.0, 0.0),
is_Kinematic => False);
the_Ground : constant physics.Object.view := the_Space.new_Object (of_Shape => the_Box,
of_Mass => 0.0,
Friction => 0.5,
Restitution => 0.5,
at_Site => (0.0, -1.5, 0.0),
is_Kinematic => False);
begin
the_Space.add (the_Ball);
the_Space.add (the_Ground);
for i in 1 .. 200
loop
the_Space.evolve (by => 1.0/60.0);
put_Line ( "Sites ~ Ball => " & Image (the_Ball .Site)
& " Ground => " & Image (the_Ground.Site));
end loop;
end launch_hello_physics_interface_2D_Demo;

View File

@@ -0,0 +1,20 @@
with
"physics",
"lace_shared";
project Hello_Physics_3D_Demo
is
for Object_Dir use "build";
for Exec_Dir use ".";
for Main use ("launch_hello_physics_interface_3d_demo.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 Linker_Options use ("-g");
end Linker;
end Hello_Physics_3D_Demo;

View File

@@ -0,0 +1,47 @@
with
physics.Space,
physics.Shape,
physics.Object,
physics.Forge,
ada.Text_IO;
procedure launch_hello_physics_interface_3D_Demo
--
-- Drops a ball onto a box.
--
is
use physics.Math,
physics.Forge,
ada.Text_IO;
the_Space : constant physics.Space .view := new_Space (physics.Bullet);
the_Sphere : constant physics.Shape .view := the_Space.new_sphere_Shape;
the_Box : constant physics.Shape .view := the_Space.new_box_Shape (half_Extents => (1.0, 1.0, 1.0));
the_Ball : constant physics.Object.view := the_Space.new_Object (of_Shape => the_Sphere,
of_Mass => 1.0,
Friction => 0.5,
Restitution => 0.5,
at_Site => (0.0, 10.0, 0.0),
is_Kinematic => False);
the_Ground : constant physics.Object.view := the_Space.new_Object (of_Shape => the_Box,
of_Mass => 0.0,
Friction => 0.5,
Restitution => 0.5,
at_Site => (0.0, -1.5, 0.0),
is_Kinematic => False);
begin
the_Space.add (the_Ball);
the_Space.add (the_Ground);
for i in 1 .. 150
loop
the_Space.evolve (by => 1.0/60.0);
put_Line ( "Sites ~ Ball => " & Image (the_Ball .Site)
& " Ground => " & Image (the_Ground.Site));
end loop;
end launch_hello_physics_interface_3D_Demo;

View File

@@ -0,0 +1,65 @@
with
physics.Space,
physics.Shape,
physics.Object,
physics.Forge,
physics.Engine,
ada.text_IO;
procedure launch_test_Engine
--
-- Simply exercises the physics engine.
--
is
use physics.Math,
physics.Forge,
ada.text_IO;
the_Space : constant physics.Space.view := new_Space (Physics.Box2d);
the_Sphere : constant physics.Shape .view := the_Space.new_circle_Shape;
the_Box : constant physics.Shape .view := the_Space.new_circle_Shape;
the_Ball : constant physics.Object.view := the_Space.new_Object (of_shape => the_Sphere,
of_mass => 1.0,
friction => 0.5,
restitution => 0.5,
at_site => [0.0, 10.0, 0.0],
is_kinematic => False);
the_Ground : constant physics.Object.view := the_Space.new_Object (of_shape => the_Box,
of_mass => 0.0,
friction => 0.5,
restitution => 0.5,
at_site => [0.0, 0.0, 0.0],
is_kinematic => False);
the_Engine : aliased physics.Engine.item;
begin
-- the_Engine.start (space_Kind => Physics.Box2d);
the_Engine.start (the_Space);
-- the_Engine.add (the_Ground);
the_Engine.add (the_Ball);
-- for Count in 1 .. 100
loop
-- the_Space.evolve (by => 1.0/60.0);
delay 1.0/500.0;
put_Line ( "Sites ~ Ball => " & Image (the_Ball .Site)
& " Ground => " & Image (the_Ground.Site));
end loop;
the_Engine.stop;
-- for Count in 1 .. 100
-- loop
-- the_Space.evolve (by => 1.0/60.0);
--
-- put_Line ( "Sites ~ Ball => " & Image (the_Ball .Site)
-- & " Ground => " & Image (the_Ground.Site));
-- end loop;
end launch_test_Engine;

View File

@@ -0,0 +1,16 @@
with
"physics",
"lace_shared";
project test_Engine
is
for Object_Dir use "build";
for Exec_Dir use ".";
for Main use ("launch_test_engine.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 test_Engine;