text
stringlengths
0
234
fi.normal := (1.0 / length_N) * N;
end if;
end Calculate_face_invariants;
adjacent_faces : array (o.point'Range) of Natural := (others => 0);
pf : Natural;
length : Real;
begin --Pre_calculate
if full_check_objects then Check_object (o); end if;
for i in o.face'Range loop
begin
-- Geometry
Calculate_face_invariants (o.face (i), o.face_invariant (i));
-- Disable blending when alphas are = 1
case o.face (i).skin is
when material_only | material_texture =>
o.face_invariant (i).blending := Is_to_blend (o.face (i).material);
when colour_only | coloured_texture | texture_only =>
o.face_invariant (i).blending := Is_to_blend (o.face (i).alpha);
when invisible =>
o.face_invariant (i).blending := False;
end case;
o.transparent := o.transparent or o.face_invariant (i).blending;
exception
when zero_summed_normal =>
raise_exception (zero_summed_normal'Identity,
o.id & " face=" & Integer'Image (i));
Function Definition: procedure Display_one (o : in out Object_3D) is
Function Body: -- Display only this object and not connected objects
-- out : object will be initialized if not yet
--
--
-- Display face routine which is optimized to produce a shorter list
-- of GL commands. Runs slower then the original Display face routine
-- yet needs to be executed only once.
--
-- Uwe R. Zimmer, July 2011
--
package Display_face_optimized is
procedure Display_face (First_Face : Boolean; fa : Face_type; fi : in out Face_invariant_type);
private
Previous_face : Face_type;
Previous_face_Invariant : Face_invariant_type;
end Display_face_optimized;
package body Display_face_optimized is
use GL.Materials;
procedure Display_face (First_Face : Boolean; fa : Face_type; fi : in out Face_invariant_type) is
use GL;
blending_hint : Boolean;
begin -- Display_face
if fa.skin = invisible then
Previous_face := fa;
Previous_face_Invariant := fi;
return;
end if;
--------------
-- Material --
--------------
if First_Face
or else Previous_face.skin = invisible
or else fa.skin /= Previous_face.skin
or else (fa.skin = Previous_face.skin
and then fa.material /= Previous_face.material) then
case fa.skin is
when material_only | material_texture =>
Disable (COLOR_MATERIAL);
Set_Material (fa.material);
when others =>
Set_Material (GL.Materials.neutral_material);
end case;
end if;
------------
-- Colour --
------------
if First_Face
or else Previous_face.skin = invisible
or else fa.skin /= Previous_face.skin
or else (fa.skin = Previous_face.skin
and then (fa.colour /= Previous_face.colour
or else fa.alpha /= Previous_face.alpha)) then
case fa.skin is
when material_only | material_texture =>
null; -- done above
when colour_only | coloured_texture =>
Enable (COLOR_MATERIAL);
ColorMaterial (FRONT_AND_BACK, AMBIENT_AND_DIFFUSE);
Color (red => fa.colour.red,
green => fa.colour.green,
blue => fa.colour.blue,
alpha => fa.alpha);
when texture_only =>
Disable (COLOR_MATERIAL);
when invisible =>
null;
end case;
end if;
-------------
-- Texture --
-------------
if First_Face