text
stringlengths
0
234
if strict_geometry and then Almost_zero (Norm2 (N_contrib)) then
raise_exception (zero_normal'Identity,
Params &
" P0=" & Coords (o.point (Pn0)) &
" P1=" & Coords (o.point (Pn1)) &
" P2=" & Coords (o.point (Pn2)) &
" Nc=" & Coords (N_contrib)
);
end if;
N := N + N_contrib;
exception
when e : others =>
raise_exception (
Exception_Identity (e),
Exception_Message (e) & Params
);
end Add_Normal_of_3p;
-- blending support
--
function Is_to_blend (m : GL.Double) return Boolean is
use GL, G3DM;
begin
return not Almost_zero (m - 1.0);
end Is_to_blend;
function Is_to_blend (m : GL.Float) return Boolean is
use GL, G3DM;
begin
return not Almost_zero (m - 1.0);
end Is_to_blend;
function Is_to_blend (m : GL.Material_Float_vector) return Boolean is
begin
return Is_to_blend (m (3));
end Is_to_blend;
function Is_to_blend (m : GL.Materials.Material_type) return Boolean is
begin
return
Is_to_blend (m.ambient) or
Is_to_blend (m.diffuse) or
Is_to_blend (m.specular);
-- m.emission, m.shininess not relevant
end Is_to_blend;
-- material support
--
procedure Set_Material (m : GL.Materials.Material_type) is
use GL;
begin
Material (FRONT_AND_BACK, AMBIENT, m.ambient);
Material (FRONT_AND_BACK, DIFFUSE, m.diffuse);
Material (FRONT_AND_BACK, SPECULAR, m.specular);
Material (FRONT_AND_BACK, EMISSION, m.emission);
Material (FRONT_AND_BACK, SHININESS, m.shininess);
end Set_Material;
-- 'Visual'
--
procedure free (o : in out p_Visual)
is
procedure deallocate is new ada.unchecked_deallocation (Visual'Class, p_Visual);
begin
destroy (o.all);
deallocate (o);
end free;
function skinned_Geometrys (o : in Visual) return GL.skinned_geometry.skinned_Geometrys
is
begin
return GL.skinned_geometry.null_skinned_Geometrys;
end skinned_Geometrys;
function Width (o : in Visual'class) return Real
is
begin
return bounds (o).box.X_Extent.Max - bounds (o).box.X_Extent.Min;
end Width;
function Height (o : in Visual'class) return Real
is
begin
return bounds (o).box.Y_Extent.Max - bounds (o).box.Y_Extent.Min;
end Height;
function Depth (o : in Visual'class) return Real
is
begin
return bounds (o).box.Z_Extent.Max - bounds (o).box.Z_Extent.Min;
end Depth;
-- 'Object_3D'
--
-- object validation
--
procedure Check_object (o : Object_3D) is
use G3DM;
procedure Check_faces is
procedure Check (f, v : Integer) is
pragma Inline (Check);
begin
if v < 0 or else v > o.max_points then
raise_exception (bad_vertex_number'Identity,
o.id & " face=" & Integer'Image (f) &
" vertex=" & Integer'Image (v));
end if;
end Check;
procedure Check_duplicate (f, Pn1, Pn2 : Integer) is
pragma Inline (Check_duplicate);