Work on hinges.

This commit is contained in:
Rod Kay
2025-09-05 02:43:49 +10:00
parent 61d6e359ae
commit 7c3ba40482
22 changed files with 2106 additions and 2259 deletions

View File

@@ -25,6 +25,8 @@ is
low_Limit => to_Radians (-180.0),
high_Limit => to_Radians ( 180.0),
collide_Conected => False);
Self.pivot_Anchor := pivot_Anchor;
end define;
@@ -162,11 +164,50 @@ is
function Angle (Self : in Item'Class) return Real
function Anchor_on_A (Self : in Item) return Vector_3
is
begin
raise Error with "TODO";
return 0.0;
return Self.Physics.local_Anchor_on_A;
end Anchor_on_A;
function Anchor_on_B (Self : in Item) return Vector_3
is
begin
return Self.Physics.local_Anchor_on_B;
end Anchor_on_B;
function pivot_Anchor (Self : in Item) return Vector_3
is
begin
return Self.pivot_Anchor;
end pivot_Anchor;
function reference_Angle (Self : in Item) return Radians
is
begin
return Self.Physics.reference_Angle;
end reference_Angle;
function limit_Enabled (Self : in Item) return Boolean
is
begin
return Self.Physics.limit_Enabled;
end limit_Enabled;
function Angle (Self : in Item) return Real
is
begin
return Self.Physics.Angle;
end Angle;
@@ -210,6 +251,35 @@ is
end Physics;
---------
--- Motor
--
function motor_Enabled (Self : in Item) return Boolean
is
begin
return Self.Physics.motor_Enabled;
end motor_Enabled;
function motor_Speed (Self : in Item) return Real
is
begin
return Self.Physics.motor_Speed;
end motor_Speed;
function max_motor_Torque (Self : in Item) return Real
is
begin
return Self.Physics.max_motor_Torque;
end max_motor_Torque;
----------------
--- Joint Limits
--

View File

@@ -66,11 +66,14 @@ is
procedure destroy (Self : in out Item);
--------------
--- Attributes
--
function Angle (Self : in Item'Class) return Real;
function reference_Angle (Self : in Item) return Radians;
function Angle (Self : in Item) return Real;
overriding
function Physics (Self : in Item) return Joint.Physics_view;
@@ -81,11 +84,13 @@ is
relaxation_Factor : in Real := 1.0);
overriding
function Frame_A (Self : in Item) return Matrix_4x4;
overriding
function Frame_B (Self : in Item) return Matrix_4x4;
overriding
procedure Frame_A_is (Self : in out Item; Now : in Matrix_4x4);
overriding
procedure Frame_B_is (Self : in out Item; Now : in Matrix_4x4);
@@ -93,16 +98,27 @@ is
function Degrees_of_freedom (Self : in Item) return joint.degree_of_Freedom;
function Anchor_on_A (Self : in Item) return Vector_3;
function Anchor_on_B (Self : in Item) return Vector_3;
function pivot_Anchor (Self : in Item) return Vector_3;
function limit_Enabled (Self : in Item) return Boolean;
-- Bounds - limits the range of motion for a degree of freedom.
--
overriding
function low_Bound (Self : access Item; for_Degree : in joint.Degree_of_freedom) return Real;
overriding
procedure low_Bound_is (Self : access Item; for_Degree : in joint.Degree_of_freedom;
Now : in Real);
overriding
function high_Bound (Self : access Item; for_Degree : in joint.Degree_of_freedom) return Real;
overriding
procedure high_Bound_is (Self : access Item; for_Degree : in joint.Degree_of_freedom;
Now : in Real);
@@ -116,11 +132,14 @@ is
procedure Velocity_is (Self : in Item; for_Degree : in joint.Degree_of_freedom;
Now : in Real);
--------------
--- Operations
---------
--- Motor
--
-- Nil.
function motor_Enabled (Self : in Item) return Boolean;
function motor_Speed (Self : in Item) return Real;
function max_motor_Torque (Self : in Item) return Real;
@@ -130,6 +149,8 @@ private
record
Physics : access std_physics.Joint.hinge.item'Class;
pivot_Anchor : Vector_3;
low_Bound,
high_Bound : Real;

View File

@@ -61,26 +61,28 @@ is
--- Hinges
--
function local_Anchor_on_A (Self : in Item) return Vector_3
is
begin
return Self.local_Anchor_on_A;
end local_Anchor_on_A;
function local_Anchor_on_B (Self : in Item) return Vector_3
is
begin
return Self.local_Anchor_on_B;
end local_Anchor_on_B;
-- function local_Anchor_on_A (Self : in Item'Class) return Vector_3
-- is
-- begin
-- return Self.Physics.local_Anchor_on_A;
-- -- return Self.local_Anchor_on_A;
-- end local_Anchor_on_A;
--
--
--
-- function local_Anchor_on_B (Self : in Item'Class) return Vector_3
-- is
-- begin
-- return Self.Physics.local_Anchor_on_B;
-- -- return Self.local_Anchor_on_B;
-- end local_Anchor_on_B;
procedure local_Anchor_on_A_is (Self : out Item; Now : in Vector_3)
is
begin
Self.local_Anchor_on_A := Now;
-- Self.local_Anchor_on_A := Now;
if Self.Sprite_A.World /= null
then
@@ -94,7 +96,7 @@ is
procedure local_Anchor_on_B_is (Self : out Item; Now : in Vector_3)
is
begin
Self.local_Anchor_on_B := Now;
-- Self.local_Anchor_on_B := Now;
if Self.Sprite_B.World /= null
then
@@ -120,4 +122,12 @@ is
end reaction_Torque;
function collide_Connected (Self : in Item'Class) return Boolean
is
begin
return Self.Physics.collide_Connected;
end collide_Connected;
end gel.Joint;

View File

@@ -89,6 +89,13 @@ is
function reaction_Torque (Self : in Item'Class) return Real;
function collide_Connected (Self : in Item'Class) return Boolean;
-- function local_Anchor_on_A (Self : in Item'Class) return Vector_3;
-- function local_Anchor_on_B (Self : in Item'Class) return Vector_3;
--------------
--- Operations
--
@@ -100,8 +107,8 @@ is
--- Hinges
--
function local_Anchor_on_A (Self : in Item) return Vector_3;
function local_Anchor_on_B (Self : in Item) return Vector_3;
-- function local_Anchor_on_A (Self : in Item) return Vector_3;
-- function local_Anchor_on_B (Self : in Item) return Vector_3;
procedure local_Anchor_on_A_is (Self : out Item; Now : in Vector_3);
procedure local_Anchor_on_B_is (Self : out Item; Now : in Vector_3);
@@ -115,8 +122,8 @@ private
Sprite_A : access gel.Sprite.item'Class;
Sprite_B : access gel.Sprite.item'Class;
local_Anchor_on_A : Vector_3;
local_Anchor_on_B : Vector_3;
-- local_Anchor_on_A : Vector_3;
-- local_Anchor_on_B : Vector_3;
end record;
null_Joints : constant Joint.views (1 .. 0) := [others => null];