text
stringlengths
0
234
begin
Read_Intel (buf, m);
Read_Intel (buf, e);
Merge (Cvt (m), Cvt (e), n);
end Read_Float;
procedure Read_Material_Float_vector (mfv : out GL.Material_Float_vector) is
begin
for i in mfv'Range loop
Read_Float (mfv (i));
end loop;
end Read_Material_Float_vector;
procedure Read_Point_3D (p : out Point_3D) is
begin
for i in p'Range loop
Read_Double (buf, p (i));
end loop;
end Read_Point_3D;
procedure Read_Map_idx_pair_array (m : out Map_idx_pair_array) is
begin
for i in m'Range loop
Read_Double (buf, m (i).U);
Read_Double (buf, m (i).V);
end loop;
end Read_Map_idx_pair_array;
v8 : U8;
v32, mp32, mf32 : U32;
procedure Read_face (face : out Face_type; face_invar : in out Face_invariant_type) is
begin
-- 1/ Points
for i in face.p'Range loop
Read_Intel (buf, v32);
face.p (i) := Integer (v32);
end loop;
-- 2/ Portal connection : object name is stored;
-- access must be found later
Read_String (buf, face_invar.connect_name);
-- 3/ Skin
GL.IO.Get_Byte (buf, v8);
face.skin := Skin_Type'Val (v8);
-- 4/ Mirror
GL.IO.Get_Byte (buf, v8);
face.mirror := Boolean'Val (v8);
-- 5/ Alpha
Read_Double (buf, face.alpha);
-- 6/ Colour
case face.skin is
when colour_only | coloured_texture =>
Read_Double (buf, face.colour.red);
Read_Double (buf, face.colour.green);
Read_Double (buf, face.colour.blue);
when others =>
null;
end case;
-- 7/ Material
case face.skin is
when material_only | material_texture =>
Read_Material_Float_vector (face.material.ambient);
Read_Material_Float_vector (face.material.diffuse);
Read_Material_Float_vector (face.material.specular);
Read_Material_Float_vector (face.material.emission);
Read_Float (face.material.shininess);
when others =>
null;
end case;
-- 8/ Texture : texture name is stored;
-- id must be found later
Read_String (buf, face_invar.texture_name);
GL.IO.Get_Byte (buf, v8);
face.whole_texture := Boolean'Val (v8);
GL.IO.Get_Byte (buf, v8);
face.repeat_U := Positive'Val (v8);
GL.IO.Get_Byte (buf, v8);
face.repeat_V := Positive'Val (v8);
if not face.whole_texture then
Read_Map_idx_pair_array (face.texture_edge_map);
end if;
end Read_face;
test_signature : String (signature_obj'Range);
ID : Ident;
begin
String'Read (s, test_signature);
if test_signature /= signature_obj then
raise Bad_data_format;
end if;
GL.IO.Attach_Stream (b => buf, stm => s);
Read_String (buf, ID);
-- Read the object's dimensions, create object, read its contents
Read_Intel (buf, mp32);
Read_Intel (buf, mf32);
o := new Object_3D (Integer (mp32), Integer (mf32));
o.ID := ID;
for p in o.Point'Range loop
Read_Point_3D (o.Point (p));
end loop;
for f in o.face'Range loop