text stringlengths 0 234 |
|---|
Save_file (Trim (o.ID, Right) & object_extension, o); |
end Save_file; |
------------- |
-- BSP I/O -- |
------------- |
-- Write a BSP tree to a stream |
procedure Write ( |
s : in Ada.Streams.Stream_IO.Stream_Access; |
tree : in BSP.p_BSP_node |
) |
is |
procedure Write_Intel is new Write_Intel_x86_number (s, U32); |
use BSP; |
n : Natural := 0; |
procedure Numbering (node : p_BSP_node) is |
begin |
if node /= null then |
n := n + 1; |
node.node_id := n; |
Numbering (node.front_child); |
Numbering (node.back_child); |
end if; |
end Numbering; |
procedure Save_node (node : p_BSP_node) is |
begin |
if node /= null then |
Write_Intel (U32 (node.node_id)); |
if node.front_child = null then |
Write_Intel (U32' (0)); |
if node.front_leaf = null then |
Write_String (s, empty); |
else |
Write_String (s, node.front_leaf.ID); |
end if; |
else |
Write_Intel (U32 (node.front_child.node_id)); |
end if; |
if node.back_child = null then |
Write_Intel (U32' (0)); |
if node.back_leaf = null then |
Write_String (s, empty); |
else |
Write_String (s, node.back_leaf.ID); |
end if; |
else |
Write_Intel (U32 (node.back_child.node_id)); |
end if; |
for i in node.normal'Range loop |
Write_Double (s, node.normal (i)); |
end loop; |
Write_Double (s, node.distance); |
-- |
Save_node (node.front_child); |
Save_node (node.back_child); |
end if; |
end Save_node; |
begin |
Numbering (tree); -- fill the node_id's |
String'Write (s, signature_bsp); -- header |
Write_Intel (U32 (n)); -- give the number of nodes first |
Save_node (tree); |
end Write; |
-- Write a BSP tree to a file |
procedure Save_file (file_name : String; tree : in BSP.p_BSP_node) is |
use Ada.Streams.Stream_IO; |
f : File_Type; |
begin |
if Index (file_name, ".")=0 then |
Create (f, out_file, file_name & BSP_extension); |
else |
Create (f, out_file, file_name); |
end if; |
Write (Stream (f), tree); |
Close (f); |
end Save_file; |
procedure Load ( |
name_in_resource : in String; |
referred : in Map_of_Visuals; |
tree : out BSP.p_BSP_node |
) |
is |
function Find_object (ID : Ident; tolerant : Boolean) return p_Object_3D is |
begin |
if ID = empty then |
return null; |
else |
return p_Object_3D ( |
Visuals_Mapping.Element ( |
Container => Visuals_Mapping.Map (referred), |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.