Debian Codegraph @

src/scene/x3d/x3dnodes_standard_geospatial.inc

raw
1 {%MainUnit x3dnodes.pas}
2 {
3 Copyright 2008-2023 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 { GEO X3D component.
18
19 Note that X3D geospatial nodes are slightly incompatible with the VRML 97 geospatial nodes.
20 We don't implement VRML 97 geospatial nodes -- the effort seems not worth it.
21 Incompatible differences in VRML 97 are mainly caused by the fact
22 that double-precision field types were not available in VRML 97.
23 And GEO really needed them. So many fields had to be defined as SFString
24 type, while in X3D that are SFDouble, SFVec2d, SFVec3d etc.
25 Examples:
26 - GeoElevationGrid: xSpacing, zSpacing, geoGridOrigin
27 - GeoOrigin: geoCoords
28 }
29
30 {$ifdef read_interface}
31 TGeoOriginNode = class;
32
33 { }
34 TGeoCoordinateNode = class(TAbstractCoordinateNode)
35 public
36 function CoordCount: Cardinal; override;
37 {$I auto_generated_node_helpers/x3dnodes_geocoordinate.inc}
38 end;
39
40 { Elevation grid expressed in geo-centric coordinates.
41 @bold(Rendering of this node is not implemented yet.) }
42 TGeoElevationGridNode = class(TAbstractGeometryNode)
43 public
44 function LocalBoundingBox(State: TX3DGraphTraverseState;
45 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override;
46 function VerticesCount(State: TX3DGraphTraverseState;
47 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override;
48 function TrianglesCount(State: TX3DGraphTraverseState;
49 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override;
50 function SolidField: TSFBool; override;
51 {$I auto_generated_node_helpers/x3dnodes_geoelevationgrid.inc}
52 end;
53
54 TGeoLocationNode = class(TAbstractGroupingNode)
55 {$I auto_generated_node_helpers/x3dnodes_geolocation.inc}
56 end;
57
58 TGeoLODNode = class(TAbstractInternalGroupingNode)
59 {$I auto_generated_node_helpers/x3dnodes_geolod.inc}
60 end;
61
62 TGeoMetadataNode = class(TAbstractInfoNode)
63 public
64 constructor Create(const AX3DName: String = ''; const ABaseUrl: String = ''); override;
65 {$I auto_generated_node_helpers/x3dnodes_geometadata.inc}
66 end;
67
68 TGeoOriginNode = class(TAbstractNode)
69 {$I auto_generated_node_helpers/x3dnodes_geoorigin.inc}
70 end;
71
72 TGeoPositionInterpolatorNode = class(TAbstractInterpolatorNode)
73 {$I auto_generated_node_helpers/x3dnodes_geopositioninterpolator.inc}
74 end;
75
76 TGeoProximitySensorNode = class(TAbstractEnvironmentalSensorNode)
77 {$I auto_generated_node_helpers/x3dnodes_geoproximitysensor.inc}
78 end;
79
80 TGeoTouchSensorNode = class(TAbstractTouchSensorNode)
81 {$I auto_generated_node_helpers/x3dnodes_geotouchsensor.inc}
82 end;
83
84 TGeoTransformNode = class(TAbstractGroupingNode)
85 {$I auto_generated_node_helpers/x3dnodes_geotransform.inc}
86 end;
87
88 TGeoViewpointNode = class(TAbstractViewpointNode)
89 strict private
90 DummyPositionSingle: TSFVec3f;
91 strict protected
92 function PositionField: TSFVec3f; override;
93 public
94 constructor Create(const AX3DName: String = ''; const ABaseUrl: String = ''); override;
95 destructor Destroy; override;
96 {$I auto_generated_node_helpers/x3dnodes_geoviewpoint.inc}
97 end;
98
99 {$endif read_interface}
100
101 {$ifdef read_implementation}
102
103 {$I auto_generated_node_helpers/x3dnodes_geocoordinate.inc}
104 {$I auto_generated_node_helpers/x3dnodes_geoelevationgrid.inc}
105 {$I auto_generated_node_helpers/x3dnodes_geolocation.inc}
106 {$I auto_generated_node_helpers/x3dnodes_geolod.inc}
107 {$I auto_generated_node_helpers/x3dnodes_geometadata.inc}
108 {$I auto_generated_node_helpers/x3dnodes_geoorigin.inc}
109 {$I auto_generated_node_helpers/x3dnodes_geopositioninterpolator.inc}
110 {$I auto_generated_node_helpers/x3dnodes_geoproximitysensor.inc}
111 {$I auto_generated_node_helpers/x3dnodes_geotouchsensor.inc}
112 {$I auto_generated_node_helpers/x3dnodes_geotransform.inc}
113 {$I auto_generated_node_helpers/x3dnodes_geoviewpoint.inc}
114
115 { TGeoCoordinateNode --------------------------------------------------------- }
116
117 function TGeoCoordinateNode.CoordCount: Cardinal;
118 begin
119 Result := FdPoint.Items.Count;
120 end;
121
122 { TGeoElevationGridNode ------------------------------------------------------ }
123
124 function TGeoElevationGridNode.LocalBoundingBox(State: TX3DGraphTraverseState;
125 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D;
126 begin
127 { Rendering of TGeoElevationGridNode not implemented. }
128 Result := TBox3D.Empty;
129 end;
130
131 function TGeoElevationGridNode.VerticesCount(State: TX3DGraphTraverseState;
132 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal;
133 begin
134 { Rendering of TGeoElevationGridNode not implemented. }
135 Result := 0;
136 end;
137
138 function TGeoElevationGridNode.TrianglesCount(State: TX3DGraphTraverseState;
139 ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal;
140 begin
141 { Rendering of TGeoElevationGridNode not implemented. }
142 Result := 0;
143 end;
144
145 function TGeoElevationGridNode.SolidField: TSFBool;
146 begin
147 Result := FdSolid;
148 end;
149
150 { TGeoMetadataNode ----------------------------------------------------------- }
151
152 constructor TGeoMetadataNode.Create(const AX3DName, ABaseUrl: String);
153 begin
154 inherited;
155 AddFunctionality(TUrlFunctionality.Create(Self));
156 end;
157
158 { TGeoViewpointNode ---------------------------------------------------------- }
159
160 constructor TGeoViewpointNode.Create(const AX3DName, ABaseUrl: String);
161 begin
162 inherited;
163 DummyPositionSingle := TSFVec3f.Create(Self, true, 'position', Vector3(0, 0, 100000));
164 end;
165
166 destructor TGeoViewpointNode.Destroy;
167 begin
168 FreeAndNil(DummyPositionSingle);
169 inherited;
170 end;
171
172 function TGeoViewpointNode.PositionField: TSFVec3f;
173 begin
174 // TODO: dummy value, just to avoid PositionField crashing
175 Result := DummyPositionSingle;
176 end;
177
178 procedure RegisterGeospatialNodes;
179 begin
180 NodesManager.RegisterNodeClasses([
181 TGeoCoordinateNode,
182 TGeoElevationGridNode,
183 TGeoLocationNode,
184 TGeoLODNode,
185 TGeoMetadataNode,
186 TGeoOriginNode,
187 TGeoPositionInterpolatorNode,
188 TGeoProximitySensorNode,
189 TGeoTouchSensorNode,
190 TGeoTransformNode,
191 TGeoViewpointNode
192 ]);
193 end;
194
195 {$endif read_implementation}