text
stringlengths
0
234
Key => Ada.Strings.Unbounded.To_Unbounded_String (ID)
)
);
end if;
exception
when Constraint_Error =>
-- GNAT gives also the message:
-- no element available because key not in map
if tolerant then
return null;
else
Raise_Exception (
Missing_object_in_BSP'Identity,
"Object not found : [" & Trim (ID, Right) & ']'
);
end if;
end Find_object;
procedure Read (
s : in Ada.Streams.Stream_IO.Stream_Access;
tree : out BSP.p_BSP_node
)
is
use BSP;
buf : GL.IO.Input_buffer;
procedure Read_Intel is new Read_Intel_x86_number (U32);
test_signature : String (signature_bsp'Range);
n, j, k : U32;
ID : Ident;
tol : constant Boolean := False;
begin
String'Read (s, test_signature);
if test_signature /= signature_bsp then
raise Bad_data_format;
end if;
GL.IO.Attach_Stream (b => buf, stm => s);
Read_Intel (buf, n);
if n < 1 then
tree := null;
return;
end if;
declare
-- We put all the new - born nodes into a farm with numbered boxes,
-- because only the numbers are stored in the BSP file.
-- Once the nodes are linked together through accesses (pointers),
-- we can forget the farm and let the tree float .. .
farm : array (0 .. n) of p_BSP_Node;
begin
farm (0) := null;
for i in 1 .. n loop
farm (i) := new BSP_Node;
end loop;
for i in 1 .. n loop
Read_Intel (buf, j); -- node_id
farm (j).node_id := Integer (j);
Read_Intel (buf, k);
farm (j).front_child := farm (k);
if k = 0 then -- it is a front leaf - > associate object
Read_String (buf, ID);
farm (j).front_leaf := Find_object (ID, tol);
end if;
Read_Intel (buf, k);
farm (j).back_child := farm (k);
if k = 0 then -- it is a back leaf - > associate object
Read_String (buf, ID);
farm (j).back_leaf := Find_object (ID, tol);
end if;
-- The node's geometric information (a plane):
for ii in farm (j).normal'Range loop
Read_Double (buf, farm (j).normal (ii));
end loop;
Read_Double (buf, farm (j).distance);
end loop;
tree := farm (1);
Function Definition: procedure Deallocate is new Ada.Unchecked_Deallocation (Visual'Class, p_Visual);
Function Body: begin
Destroy (o.all);
Deallocate (o);
end Free;
function skinned_Geometrys (o : Visual) return GL.Skinned_Geometry.skinned_Geometrys is
(GL.Skinned_Geometry.null_skinned_Geometrys);
function Width (o : Visual'class) return Real is
(Bounds (o).Box.X_Extent.Max - Bounds (o).Box.X_Extent.Min);
function Height (o : Visual'class) return Real is
(Bounds (o).Box.Y_Extent.Max - Bounds (o).Box.Y_Extent.Min);
function Depth (o : Visual'class) return Real is
(Bounds (o).Box.Z_Extent.Max - Bounds (o).Box.Z_Extent.Min);
-- 'Object_3D'
--
-- object validation
--