Debian Codegraph @

src/scene/castlescene_punctuallight.inc

raw
1 {%MainUnit castlescene.pas}
2 {
3 Copyright 2022-2022 Michalis Kamburelis.
4
5 This file is part of "Castle Game Engine".
6
7 "Castle Game Engine" is free software; see the file COPYING.txt,
8 included in this distribution, for details about the copyright.
9
10 "Castle Game Engine" is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
14 ----------------------------------------------------------------------------
15 }
16
17 { Punctual light: point, spot, directional. }
18
19 {$ifdef read_interface}
20
21 type
22 { Ancestor class for all punctual lights: point, spot, directional.
23
24 The name "punctual" follows the glTF terminology,
25 https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_lights_punctual .
26 Punctual lights are infinitely small points that emit light from simple position
27 or direction. This makes them different e.g. from area lights, of environment lights. }
28 TCastlePunctualLight = class(TCastleAbstractLight)
29 strict private
30 FShadows: Boolean;
31 procedure SetShadows(const Value: Boolean);
32 protected
33 FPunctualLight: TAbstractPunctualLightNode; //< Descendants should set it in constructor
34 public
35 constructor Create(AOwner: TComponent); override;
36 function PropertySections(const PropertyName: String): TPropertySections; override;
37 published
38 { Cast shadows from this light.
39
40 Right now this property activates
41 @url(https://castle-engine.io/shadow_volumes shadow volumes).
42 Please consult the @url(https://castle-engine.io/shadow_volumes shadow volumes documentation)
43 about important requirements of this technique,
44 namely: models that cast shadows must be 2-manifold.
45 Moreover, right now, only one light in the world can cast shadows using
46 shadow volumes.
47
48 In the future we want to offer a choice between using
49 @url(https://castle-engine.io/shadow_volumes shadow volumes)
50 and
51 @url(https://castle-engine.io/x3d_extensions_shadow_maps.php shadow maps). }
52 property Shadows: Boolean read FShadows write SetShadows default false;
53 end;
54
55 {$endif read_interface}
56
57 {$ifdef read_implementation}
58
59 constructor TCastlePunctualLight.Create(AOwner: TComponent);
60 begin
61 inherited;
62 end;
63
64 procedure TCastlePunctualLight.SetShadows(const Value: Boolean);
65 begin
66 if FShadows <> Value then
67 begin
68 FShadows := Value;
69 FPunctualLight.ShadowVolumesMain := Value;
70 FPunctualLight.ShadowVolumes := Value;
71 end;
72 end;
73
74 function TCastlePunctualLight.PropertySections(const PropertyName: String): TPropertySections;
75 begin
76 if ArrayContainsString(PropertyName, ['Shadows']) then
77 Result := [psBasic]
78 else
79 Result := inherited PropertySections(PropertyName);
80 end;
81
82 {$endif read_implementation}