| 1 |
{ -*- buffer-read-only: t -*- |
| 2 |
|
| 3 |
Copyright 2015-2024 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 |
{ Automatically generated node properties. |
| 18 |
|
| 19 |
Do not edit this file manually! |
| 20 |
To add new properties: |
| 21 |
- add them to the text files in tools/internal/x3d-nodes-to-pascal/nodes-specification/ , |
| 22 |
- and regenerate include files by running x3d-nodes-to-pascal } |
| 23 |
|
| 24 |
{$ifdef read_interface} |
| 25 |
|
| 26 |
strict private |
| 27 |
function GetAppearance: TAppearanceNode; |
| 28 |
procedure SetAppearance(const Value: TAppearanceNode); |
| 29 |
function GetGeometry: TAbstractGeometryNode; |
| 30 |
procedure SetGeometry(const Value: TAbstractGeometryNode); |
| 31 |
function GetBBox: TBox3D; |
| 32 |
procedure SetBBox(const Value: TBox3D); |
| 33 |
function GetShading: TShading; |
| 34 |
procedure SetShading(const Value: TShading); |
| 35 |
function GetVisible: Boolean; |
| 36 |
procedure SetVisible(const Value: Boolean); |
| 37 |
function GetCollision: TShapeCollision; |
| 38 |
procedure SetCollision(const Value: TShapeCollision); |
| 39 |
public |
| 40 |
{ Create node fields and events. } |
| 41 |
procedure CreateNode; override; |
| 42 |
class function ClassX3DType: String; override; |
| 43 |
|
| 44 |
strict private FFdAppearance: TSFNode; |
| 45 |
{ Internal wrapper for property @code(Appearance). This wrapper API may change, we advise to access simpler @code(Appearance) instead, if it is defined (TODO: for now, some field types do not have a simpler counterpart). } |
| 46 |
public property FdAppearance: TSFNode read FFdAppearance; |
| 47 |
{ } |
| 48 |
property Appearance: TAppearanceNode read GetAppearance write SetAppearance; |
| 49 |
|
| 50 |
strict private FFdGeometry: TSFNode; |
| 51 |
{ Internal wrapper for property @code(Geometry). This wrapper API may change, we advise to access simpler @code(Geometry) instead, if it is defined (TODO: for now, some field types do not have a simpler counterpart). } |
| 52 |
public property FdGeometry: TSFNode read FFdGeometry; |
| 53 |
{ } |
| 54 |
property Geometry: TAbstractGeometryNode read GetGeometry write SetGeometry; |
| 55 |
|
| 56 |
strict private FFdBboxCenter: TSFVec3f; |
| 57 |
{ Internal wrapper for property @code(BboxCenter). This wrapper API may change, we advise to access simpler @code(BboxCenter) instead, if it is defined (TODO: for now, some field types do not have a simpler counterpart). } |
| 58 |
public property FdBboxCenter: TSFVec3f read FFdBboxCenter; |
| 59 |
{ You can provide a manually-calculated bounding box of the shape here, for optimization purposes. Leave this field as empty (TBox3D.Empty) to let the engine calculate best bounding box automatically. |
| 60 |
|
| 61 |
Manually providing the bounding box makes sense if you can do it more efficiently than the engine. E.g. if the shape vertexes are animated, then the engine would have to recalcualate the perfect bounding box every frame. It is more efficient to calculate a bounding box of all possible animation frames, and store it here. |
| 62 |
|
| 63 |
The glTF skinned animation automatically fills this field for the affected shapes. |
| 64 |
|
| 65 |
@italic(Note: This property is not useful if you want to know the bounding box of a shape, calculated by the engine). This property only allows to override the automatic engine calculation. |
| 66 |
|
| 67 |
To read the calculated bounding box, load the nodes to TCastleScene. You can then use @link(TCastleTransform.BoundingBox Scene.BoundingBox), @link(TCastleTransform.LocalBoundingBox Scene.LocalBoundingBox), @link(TCastleTransform.WorldBoundingBox Scene.WorldBoundingBox) to know bounding box of the scene. To get bounding box of a particular shape, enumerate @link(TCastleSceneCore.Shapes) to find the correct shape (using any criteria you want -- note that the same TShapeNode may be reused multiple times), and then read @link(TShape.BoundingBox), @link(TShape.LocalBoundingBox). } |
| 68 |
property BBox: TBox3D read GetBBox write SetBBox; |
| 69 |
|
| 70 |
strict private FFdBboxSize: TSFVec3f; |
| 71 |
{ Internal wrapper for property @code(BboxSize). This wrapper API may change, we advise to access simpler @code(BboxSize) instead, if it is defined (TODO: for now, some field types do not have a simpler counterpart). } |
| 72 |
public property FdBboxSize: TSFVec3f read FFdBboxSize; |
| 73 |
|
| 74 |
strict private FFdShading: TSFStringEnum; |
| 75 |
{ Internal wrapper for property @code(Shading). This wrapper API may change, we advise to access simpler @code(Shading) instead, if it is defined (TODO: for now, some field types do not have a simpler counterpart). } |
| 76 |
public property FdShading: TSFStringEnum read FFdShading; |
| 77 |
{ How to display given shape. } |
| 78 |
property Shading: TShading read GetShading write SetShading; |
| 79 |
|
| 80 |
strict private FFdVisible: TSFBool; |
| 81 |
{ Internal wrapper for property @code(Visible). This wrapper API may change, we advise to access simpler @code(Visible) instead, if it is defined (TODO: for now, some field types do not have a simpler counterpart). } |
| 82 |
public property FdVisible: TSFBool read FFdVisible; |
| 83 |
{ Is the shape visible. Shapes that are not visible are not rendered, but otherwise are still processed (for example, hidden shapes are still used for collision detection). Toggling this is guaranteed to be ultra-fast. |
| 84 |
|
| 85 |
Note: An alternative method to hide (and more) things in X3D is to wrap them in a @link(TSwitchNode), and toggle @link(TSwitchNode.WhichChoice) between -1 and 0. When @link(TSwitchNode.WhichChoice) is -1, the children are not processed (not rendered, and do not collide). } |
| 86 |
property Visible: Boolean read GetVisible write SetVisible; |
| 87 |
|
| 88 |
strict private FFdCollision: TSFStringEnum; |
| 89 |
{ Internal wrapper for property @code(Collision). This wrapper API may change, we advise to access simpler @code(Collision) instead, if it is defined (TODO: for now, some field types do not have a simpler counterpart). } |
| 90 |
public property FdCollision: TSFStringEnum read FFdCollision; |
| 91 |
{ How does the given shape collide. This only matters if @link(TCastleSceneCore.PreciseCollisions) is @true, otherwise the whole scene (with all shapes) collides as one big bounding box. } |
| 92 |
property Collision: TShapeCollision read GetCollision write SetCollision; |
| 93 |
|
| 94 |
{$endif read_interface} |
| 95 |
|
| 96 |
{$ifdef read_implementation} |
| 97 |
|
| 98 |
{ TAbstractShapeNode ----------------------------------------------- } |
| 99 |
|
| 100 |
function TAbstractShapeNode.GetAppearance: TAppearanceNode; |
| 101 |
begin |
| 102 |
if FdAppearance.Value is TAppearanceNode then |
| 103 |
Result := TAppearanceNode(FdAppearance.Value) |
| 104 |
else |
| 105 |
Result := nil; |
| 106 |
end; |
| 107 |
|
| 108 |
procedure TAbstractShapeNode.SetAppearance(const Value: TAppearanceNode); |
| 109 |
begin |
| 110 |
FdAppearance.Send(Value); |
| 111 |
end; |
| 112 |
|
| 113 |
function TAbstractShapeNode.GetGeometry: TAbstractGeometryNode; |
| 114 |
begin |
| 115 |
if FdGeometry.Value is TAbstractGeometryNode then |
| 116 |
Result := TAbstractGeometryNode(FdGeometry.Value) |
| 117 |
else |
| 118 |
Result := nil; |
| 119 |
end; |
| 120 |
|
| 121 |
procedure TAbstractShapeNode.SetGeometry(const Value: TAbstractGeometryNode); |
| 122 |
begin |
| 123 |
FdGeometry.Send(Value); |
| 124 |
end; |
| 125 |
|
| 126 |
function TAbstractShapeNode.GetBBox: TBox3D; |
| 127 |
begin |
| 128 |
Result := TBox3D.FromCenterSize(FdBBoxCenter.Value, FdBBoxSize.Value); |
| 129 |
end; |
| 130 |
|
| 131 |
procedure TAbstractShapeNode.SetBBox(const Value: TBox3D); |
| 132 |
var |
| 133 |
ValueCenter, ValueSize: TVector3; |
| 134 |
begin |
| 135 |
Value.ToCenterSize(ValueCenter, ValueSize); |
| 136 |
FdBBoxCenter.Send(ValueCenter); |
| 137 |
FdBBoxSize.Send(ValueSize); |
| 138 |
end; |
| 139 |
|
| 140 |
function TAbstractShapeNode.GetShading: TShading; |
| 141 |
begin |
| 142 |
Result := TShading(FdShading.EnumValue); |
| 143 |
end; |
| 144 |
|
| 145 |
procedure TAbstractShapeNode.SetShading(const Value: TShading); |
| 146 |
begin |
| 147 |
FdShading.SendEnumValue(Ord(Value)); |
| 148 |
end; |
| 149 |
|
| 150 |
function TAbstractShapeNode.GetVisible: Boolean; |
| 151 |
begin |
| 152 |
Result := FdVisible.Value; |
| 153 |
end; |
| 154 |
|
| 155 |
procedure TAbstractShapeNode.SetVisible(const Value: Boolean); |
| 156 |
begin |
| 157 |
FdVisible.Send(Value); |
| 158 |
end; |
| 159 |
|
| 160 |
function TAbstractShapeNode.GetCollision: TShapeCollision; |
| 161 |
begin |
| 162 |
Result := TShapeCollision(FdCollision.EnumValue); |
| 163 |
end; |
| 164 |
|
| 165 |
procedure TAbstractShapeNode.SetCollision(const Value: TShapeCollision); |
| 166 |
begin |
| 167 |
FdCollision.SendEnumValue(Ord(Value)); |
| 168 |
end; |
| 169 |
|
| 170 |
class function TAbstractShapeNode.ClassX3DType: String; |
| 171 |
begin |
| 172 |
Result := 'X3DShapeNode'; |
| 173 |
end; |
| 174 |
|
| 175 |
procedure TAbstractShapeNode.CreateNode; |
| 176 |
begin |
| 177 |
inherited; |
| 178 |
|
| 179 |
FFdAppearance := TSFNode.Create(Self, True, 'appearance', [TAppearanceNode]); |
| 180 |
FdAppearance.ChangeAlways := chVisibleNonGeometry; |
| 181 |
FdAppearance.OnBeforeValueChange := {$ifdef FPC}@{$endif}SetAppearanceBefore; |
| 182 |
AddField(FFdAppearance); |
| 183 |
|
| 184 |
FFdGeometry := TSFNode.Create(Self, True, 'geometry', [TAbstractGeometryNode]); |
| 185 |
FdGeometry.ChangeAlways := chVisibleNonGeometry; |
| 186 |
AddField(FFdGeometry); |
| 187 |
|
| 188 |
FFdBboxCenter := TSFVec3f.Create(Self, True, 'bboxCenter', Vector3(0, 0, 0)); |
| 189 |
FdBboxCenter.ChangeAlways := chVisibleNonGeometry; |
| 190 |
AddField(FFdBboxCenter); |
| 191 |
|
| 192 |
FFdBboxSize := TSFVec3f.Create(Self, True, 'bboxSize', Vector3(-1, -1, -1)); |
| 193 |
FdBboxSize.ChangeAlways := chVisibleNonGeometry; |
| 194 |
AddField(FFdBboxSize); |
| 195 |
|
| 196 |
FFdShading := TSFStringEnum.Create(Self, True, 'shading', @ShadingNames, Ord(High(ShadingNames)) + 1, Ord(shDefault)); |
| 197 |
FdShading.ChangeAlways := chVisibleNonGeometry; |
| 198 |
AddField(FFdShading); |
| 199 |
|
| 200 |
FFdVisible := TSFBool.Create(Self, True, 'visible', true); |
| 201 |
FdVisible.ChangeAlways := chVisibleNonGeometry; |
| 202 |
AddField(FFdVisible); |
| 203 |
|
| 204 |
FFdCollision := TSFStringEnum.Create(Self, False, 'collision', @ShapeCollisionNames, Ord(High(ShapeCollisionNames)) + 1, Ord(scDefault)); |
| 205 |
FdCollision.ChangeAlways := chVisibleNonGeometry; |
| 206 |
AddField(FFdCollision); |
| 207 |
end; |
| 208 |
|
| 209 |
{$endif read_implementation} |