| 1 |
{%MainUnit x3dnodes.pas} |
| 2 |
{ |
| 3 |
Copyright 2002-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 |
{ VRML 1.0 specification nodes. |
| 18 |
|
| 19 |
Note: If a node is present in both VRML 1.0 and later VRML / X3D versions |
| 20 |
(VRML 2.0 aka VRML 97, X3D 3, X3D 4...) |
| 21 |
and it's implemented using the same class, |
| 22 |
then it is inside x3d_standard_xxx file, not here. |
| 23 |
In practice there are not so many such nodes: maybe only TNormalNode. |
| 24 |
|
| 25 |
This file is only for VRML 1.0 nodes, that have no purpose |
| 26 |
in later VRML / X3D versions. |
| 27 |
Most nodes in VRML 1.0 vs VRML 2.0 specifications are different |
| 28 |
enough that even when they have the same |
| 29 |
name (like Group) we implement them using different classes (like |
| 30 |
TGroupNode_1 and TGroupNode). |
| 31 |
|
| 32 |
Note that most VRML 1 nodes descend from TAbstractChildNode, |
| 33 |
this way we can use them inside VRML >= 2.0 group nodes and |
| 34 |
mix VRML 1.0 and greater versions. |
| 35 |
} { } |
| 36 |
|
| 37 |
{$ifdef read_interface} |
| 38 |
{ Geometry node allowed only in VRML <= 1.0. |
| 39 |
|
| 40 |
In VRML 1.0 shape nodes are allowed pretty everywhere, |
| 41 |
while VRML 2.0 has different idea of how shapes are handled |
| 42 |
(they must be inside Shape node), so no shape node |
| 43 |
is suitable at the same time for VRML 1.0 and VRML 2.0. } |
| 44 |
TAbstractGeometryNode_1 = class(TAbstractGeometryNode) |
| 45 |
{$I auto_generated_node_helpers/x3dnodes_abstractvrml1geometry_1.inc} |
| 46 |
end; |
| 47 |
|
| 48 |
TAsciiTextNode_1 = class(TAbstractGeometryNode_1) |
| 49 |
strict private |
| 50 |
FFontTextureNode: TPixelTextureNode; |
| 51 |
public |
| 52 |
destructor Destroy; override; |
| 53 |
function Proxy(var State: TX3DGraphTraverseState): TAbstractGeometryNode; override; |
| 54 |
function LocalBoundingBox(State: TX3DGraphTraverseState; |
| 55 |
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override; |
| 56 |
function FontTextureNode: TAbstractTexture2DNode; override; |
| 57 |
|
| 58 |
{ Force recalculating the shape when font changed. |
| 59 |
For now, we don't detect font changes (e.g. when TFontStyleNode.CustomFont changed) |
| 60 |
automatically. } |
| 61 |
procedure FontChanged; |
| 62 |
|
| 63 |
function Justify: TX3DFontJustify; |
| 64 |
{$I auto_generated_node_helpers/x3dnodes_asciitext_1.inc} |
| 65 |
end; |
| 66 |
|
| 67 |
TConeNode_1 = class(TAbstractGeometryNode_1) |
| 68 |
public |
| 69 |
function Proxy(var State: TX3DGraphTraverseState): TAbstractGeometryNode; override; |
| 70 |
|
| 71 |
function BoundingBox(State: TX3DGraphTraverseState; |
| 72 |
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override; |
| 73 |
function LocalBoundingBox(State: TX3DGraphTraverseState; |
| 74 |
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override; |
| 75 |
function TrianglesCount(State: TX3DGraphTraverseState; |
| 76 |
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override; |
| 77 |
|
| 78 |
function AutoGenerate3DTexCoords: boolean; override; |
| 79 |
{$I auto_generated_node_helpers/x3dnodes_cone_1.inc} |
| 80 |
end; |
| 81 |
|
| 82 |
TCubeNode_1 = class(TAbstractGeometryNode_1) |
| 83 |
public |
| 84 |
function Proxy(var State: TX3DGraphTraverseState): TAbstractGeometryNode; override; |
| 85 |
|
| 86 |
function BoundingBox(State: TX3DGraphTraverseState; |
| 87 |
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override; |
| 88 |
function LocalBoundingBox(State: TX3DGraphTraverseState; |
| 89 |
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override; |
| 90 |
function TrianglesCount(State: TX3DGraphTraverseState; |
| 91 |
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override; |
| 92 |
|
| 93 |
function AutoGenerate3DTexCoords: boolean; override; |
| 94 |
{$I auto_generated_node_helpers/x3dnodes_cube_1.inc} |
| 95 |
end; |
| 96 |
|
| 97 |
TCylinderNode_1 = class(TAbstractGeometryNode_1) |
| 98 |
public |
| 99 |
function Proxy(var State: TX3DGraphTraverseState): TAbstractGeometryNode; override; |
| 100 |
|
| 101 |
function BoundingBox(State: TX3DGraphTraverseState; |
| 102 |
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override; |
| 103 |
function LocalBoundingBox(State: TX3DGraphTraverseState; |
| 104 |
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override; |
| 105 |
function TrianglesCount(State: TX3DGraphTraverseState; |
| 106 |
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override; |
| 107 |
|
| 108 |
function AutoGenerate3DTexCoords: boolean; override; |
| 109 |
{$I auto_generated_node_helpers/x3dnodes_cylinder_1.inc} |
| 110 |
end; |
| 111 |
|
| 112 |
{ Common base class for VRML 1.0 indexed nodes |
| 113 |
(IndexedFaceSet, IndexedTriangleMesh, IndexedLineSet). } |
| 114 |
TAbstractIndexedNode_1 = class(TAbstractGeometryNode_1) |
| 115 |
public |
| 116 |
constructor Create(const AX3DName: string = ''; const ABaseUrl: String = ''); override; |
| 117 |
function InternalCoord(State: TX3DGraphTraverseState; |
| 118 |
out ACoord: TMFVec3f): boolean; override; |
| 119 |
function CoordIndexField: TMFLong; override; |
| 120 |
{$I auto_generated_node_helpers/x3dnodes_abstractvrml1indexed_1.inc} |
| 121 |
end; |
| 122 |
|
| 123 |
{ Common base class for VRML 1.0 indexed polygon nodes |
| 124 |
(IndexedFaceSet and IndexedTriangleMesh). } |
| 125 |
TIndexedFacesOrTrianglesNode_1 = class(TAbstractIndexedNode_1) |
| 126 |
function TrianglesCount(State: TX3DGraphTraverseState; |
| 127 |
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override; |
| 128 |
end; |
| 129 |
|
| 130 |
TIndexedFaceSetNode_1 = class(TIndexedFacesOrTrianglesNode_1) |
| 131 |
public |
| 132 |
procedure InternalCoordPolygons( |
| 133 |
State: TX3DGraphTraverseState; |
| 134 |
PolygonHandler: TIndexedPolygonHandler); override; |
| 135 |
|
| 136 |
function InternalTexCoord(State: TX3DGraphTraverseState; |
| 137 |
out ATexCoord: TX3DNode): boolean; override; |
| 138 |
{$I auto_generated_node_helpers/x3dnodes_indexedfaceset_1.inc} |
| 139 |
end; |
| 140 |
|
| 141 |
TIndexedLineSetNode_1 = class(TAbstractIndexedNode_1) |
| 142 |
public |
| 143 |
function TrianglesCount(State: TX3DGraphTraverseState; |
| 144 |
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override; |
| 145 |
function InternalTexCoord(State: TX3DGraphTraverseState; |
| 146 |
out ATexCoord: TX3DNode): boolean; override; |
| 147 |
{ Do we have enough normals information to render this node lit. |
| 148 |
VRML 1.0 specification explicitly mentions that IndexedLineSet is treated |
| 149 |
specially: it's unlit if there are not enough normals specified. } |
| 150 |
function Lit(State: TX3DGraphTraverseState): boolean; override; |
| 151 |
{$I auto_generated_node_helpers/x3dnodes_indexedlineset_1.inc} |
| 152 |
end; |
| 153 |
|
| 154 |
TPointSetNode_1 = class(TAbstractGeometryNode_1) |
| 155 |
strict private |
| 156 |
CoordSubrange: TMFVec3f; |
| 157 |
public |
| 158 |
constructor Create(const AX3DName: string = ''; const ABaseUrl: String = ''); override; |
| 159 |
destructor Destroy; override; |
| 160 |
function InternalCoord(State: TX3DGraphTraverseState; |
| 161 |
out ACoord: TMFVec3f): boolean; override; |
| 162 |
function TrianglesCount(State: TX3DGraphTraverseState; |
| 163 |
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override; |
| 164 |
function Lit(State: TX3DGraphTraverseState): boolean; override; |
| 165 |
{$I auto_generated_node_helpers/x3dnodes_pointset_1.inc} |
| 166 |
end; |
| 167 |
|
| 168 |
TSphereNode_1 = class(TAbstractGeometryNode_1) |
| 169 |
public |
| 170 |
function Proxy(var State: TX3DGraphTraverseState): TAbstractGeometryNode; override; |
| 171 |
|
| 172 |
function BoundingBox(State: TX3DGraphTraverseState; |
| 173 |
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override; |
| 174 |
function LocalBoundingBox(State: TX3DGraphTraverseState; |
| 175 |
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override; |
| 176 |
function TrianglesCount(State: TX3DGraphTraverseState; |
| 177 |
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override; |
| 178 |
|
| 179 |
function AutoGenerate3DTexCoords: boolean; override; |
| 180 |
{$I auto_generated_node_helpers/x3dnodes_sphere_1.inc} |
| 181 |
end; |
| 182 |
|
| 183 |
TCoordinate3Node_1 = class(TAbstractChildNode) |
| 184 |
{$I auto_generated_node_helpers/x3dnodes_coordinate3_1.inc} |
| 185 |
end; |
| 186 |
|
| 187 |
TFontStyleNode_1 = class(TAbstractChildNode) |
| 188 |
public |
| 189 |
function Family: TX3DFontFamily; |
| 190 |
function Bold: boolean; |
| 191 |
function Italic: boolean; |
| 192 |
function Font: TCastleFont; |
| 193 |
{$I auto_generated_node_helpers/x3dnodes_fontstyle_1.inc} |
| 194 |
end; |
| 195 |
|
| 196 |
TInfoNode_1 = class(TAbstractChildNode) |
| 197 |
{$I auto_generated_node_helpers/x3dnodes_info_1.inc} |
| 198 |
end; |
| 199 |
|
| 200 |
TLODNode_1 = class(TAbstractChildNode) |
| 201 |
protected |
| 202 |
function DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer; override; |
| 203 |
public |
| 204 |
constructor Create(const AX3DName: string = ''; const ABaseUrl: String = ''); override; |
| 205 |
{$I auto_generated_node_helpers/x3dnodes_lod_1.inc} |
| 206 |
end; |
| 207 |
|
| 208 |
TMaterialNode_1 = class(TAbstractChildNode) |
| 209 |
strict private |
| 210 |
type |
| 211 |
TMaterialInfo_1 = class(TPhongMaterialInfo) |
| 212 |
strict private |
| 213 |
FNode: TMaterialNode_1; |
| 214 |
FIndex: Integer; |
| 215 |
protected |
| 216 |
function GetDiffuseColor: TVector3; override; |
| 217 |
procedure SetDiffuseColor(const Value: TVector3); override; |
| 218 |
function GetSpecularColor: TVector3; override; |
| 219 |
procedure SetSpecularColor(const Value: TVector3); override; |
| 220 |
function GetEmissiveColor: TVector3; override; |
| 221 |
procedure SetEmissiveColor(const Value: TVector3); override; |
| 222 |
public |
| 223 |
constructor Create(ANode: TMaterialNode_1; const Index: Integer); |
| 224 |
|
| 225 |
function AmbientColor: TVector3; override; |
| 226 |
function Shininess: Single; override; |
| 227 |
function ReflectionColor: TVector3; override; |
| 228 |
function Transparency: Single; override; |
| 229 |
|
| 230 |
function ReflSpecular: TVector3; override; |
| 231 |
function ReflDiffuse: TVector3; override; |
| 232 |
function TransSpecular: TVector3; override; |
| 233 |
function TransDiffuse: TVector3; override; |
| 234 |
|
| 235 |
function ReflSpecularExp: Single; override; |
| 236 |
function TransSpecularExp: Single; override; |
| 237 |
end; |
| 238 |
var |
| 239 |
FMaterialInfo: array of TMaterialInfo_1; |
| 240 |
public |
| 241 |
destructor Destroy; override; |
| 242 |
|
| 243 |
{ Only the emissive color is not black (zero). |
| 244 |
This detects a special case described in VRML 1.0 specification: |
| 245 |
when ambient, diffuse and specular are all empty (no values), |
| 246 |
then emissiveColor should be used at the final color and shape |
| 247 |
should be unlit. |
| 248 |
|
| 249 |
You should use the EmissiveColor4Single in this case. } |
| 250 |
function PureEmissive: boolean; |
| 251 |
|
| 252 |
{ Force the material pure emissive (see @link(PureEmissive)) by setting |
| 253 |
other colors to black. } |
| 254 |
procedure ForcePureEmissive; deprecated 'use X3D with TUnlitMaterialNode'; |
| 255 |
|
| 256 |
{ Material information based on this node. |
| 257 |
It is automatically updated when properties of this material change. |
| 258 |
Do not free it yourself, it will be automatically freed when |
| 259 |
this node is freed. } |
| 260 |
function MaterialInfo(const AIndex: Integer = 0): TPhongMaterialInfo; |
| 261 |
{$I auto_generated_node_helpers/x3dnodes_material_1.inc} |
| 262 |
end; |
| 263 |
|
| 264 |
TMaterialBindingNode_1 = class(TAbstractChildNode) |
| 265 |
{$I auto_generated_node_helpers/x3dnodes_materialbinding_1.inc} |
| 266 |
end; |
| 267 |
|
| 268 |
TNormalBindingNode_1 = class(TAbstractChildNode) |
| 269 |
{$I auto_generated_node_helpers/x3dnodes_normalbinding_1.inc} |
| 270 |
end; |
| 271 |
|
| 272 |
TTexture2Node_1 = class(TAbstractTexture2DNode) |
| 273 |
strict protected |
| 274 |
{ Texture is loaded from file or inlined. |
| 275 |
The priority has the filename, only if it's empty (or an exception |
| 276 |
occurs during file loading) then the inlined texture will be used. |
| 277 |
|
| 278 |
Note that in VRML 1.0 a node without any texture |
| 279 |
(that is, when IsTextureLoaded = true and still |
| 280 |
IsTextureImage = false) is also useful: it turns off using the previous |
| 281 |
texture. } |
| 282 |
procedure LoadTextureData(out CacheUsed: boolean); override; |
| 283 |
protected |
| 284 |
procedure ParseAfter(Reader: TX3DReaderNames); override; |
| 285 |
public |
| 286 |
function TextureDescription: string; override; |
| 287 |
{$I auto_generated_node_helpers/x3dnodes_texture2_1.inc} |
| 288 |
end; |
| 289 |
|
| 290 |
TTexture2TransformNode_1 = class(TAbstractChildNode) |
| 291 |
protected |
| 292 |
procedure MiddleTraverse(StateStack: TX3DGraphTraverseStateStack); override; |
| 293 |
public |
| 294 |
function TextureMatrixTransformation: TMatrix4; |
| 295 |
{$I auto_generated_node_helpers/x3dnodes_texture2transform_1.inc} |
| 296 |
end; |
| 297 |
|
| 298 |
TTextureCoordinate2Node_1 = class(TAbstractChildNode) |
| 299 |
{$I auto_generated_node_helpers/x3dnodes_texturecoordinate2_1.inc} |
| 300 |
end; |
| 301 |
|
| 302 |
TShapeHintsNode_1 = class(TAbstractChildNode) |
| 303 |
protected |
| 304 |
function ParseNodeBodyElement(Lexer: TX3DLexer; Reader: TX3DReaderNames; |
| 305 |
const APositionInParent: Integer): boolean; override; |
| 306 |
{$I auto_generated_node_helpers/x3dnodes_shapehints_1.inc} |
| 307 |
end; |
| 308 |
|
| 309 |
{ Common base class for all VRML 1 nodes that modify the transformation. } |
| 310 |
TAbstractTransformationNode_1 = class(TAbstractChildNode) |
| 311 |
{$I auto_generated_node_helpers/x3dnodes_abstractvrml1transformation_1.inc} |
| 312 |
end; |
| 313 |
|
| 314 |
{ VRML 1.0 MatrixTransform node. } |
| 315 |
TMatrixTransformNode_1 = class(TAbstractTransformationNode_1) |
| 316 |
protected |
| 317 |
procedure MiddleTraverse(StateStack: TX3DGraphTraverseStateStack); override; |
| 318 |
{$I auto_generated_node_helpers/x3dnodes_matrixtransform_1.inc} |
| 319 |
end; |
| 320 |
|
| 321 |
TRotationNode_1 = class(TAbstractTransformationNode_1) |
| 322 |
protected |
| 323 |
procedure MiddleTraverse(StateStack: TX3DGraphTraverseStateStack); override; |
| 324 |
{$I auto_generated_node_helpers/x3dnodes_rotation_1.inc} |
| 325 |
end; |
| 326 |
|
| 327 |
TScaleNode_1 = class(TAbstractTransformationNode_1) |
| 328 |
protected |
| 329 |
procedure MiddleTraverse(StateStack: TX3DGraphTraverseStateStack); override; |
| 330 |
{$I auto_generated_node_helpers/x3dnodes_scale_1.inc} |
| 331 |
end; |
| 332 |
|
| 333 |
TTransformNode_1 = class(TAbstractTransformationNode_1) |
| 334 |
protected |
| 335 |
procedure MiddleTraverse(StateStack: TX3DGraphTraverseStateStack); override; |
| 336 |
{$I auto_generated_node_helpers/x3dnodes_transform_1.inc} |
| 337 |
end; |
| 338 |
|
| 339 |
TTranslationNode_1 = class(TAbstractTransformationNode_1) |
| 340 |
protected |
| 341 |
procedure MiddleTraverse(StateStack: TX3DGraphTraverseStateStack); override; |
| 342 |
{$I auto_generated_node_helpers/x3dnodes_translation_1.inc} |
| 343 |
end; |
| 344 |
|
| 345 |
{ Common base class for all cameras in VRML 1.0. } |
| 346 |
TAbstractCameraNode_1 = class(TAbstractViewpointNode) |
| 347 |
strict protected |
| 348 |
function PositionField: TSFVec3f; override; |
| 349 |
{$I auto_generated_node_helpers/x3dnodes_abstractvrml1camera_1.inc} |
| 350 |
end; |
| 351 |
|
| 352 |
TOrthographicCameraNode_1 = class(TAbstractCameraNode_1) |
| 353 |
public |
| 354 |
class function ProjectionType: TProjectionType; override; |
| 355 |
{$I auto_generated_node_helpers/x3dnodes_orthographiccamera_1.inc} |
| 356 |
end; |
| 357 |
|
| 358 |
TPerspectiveCameraNode_1 = class(TAbstractCameraNode_1) |
| 359 |
public |
| 360 |
class function ProjectionType: TProjectionType; override; |
| 361 |
{$I auto_generated_node_helpers/x3dnodes_perspectivecamera_1.inc} |
| 362 |
end; |
| 363 |
|
| 364 |
TDirectionalLightNode_1 = class(TAbstractDirectionalLightNode) |
| 365 |
public |
| 366 |
function Scope: TLightScope; override; |
| 367 |
{$I auto_generated_node_helpers/x3dnodes_directionallight_1.inc} |
| 368 |
end; |
| 369 |
|
| 370 |
TPointLightNode_1 = class(TAbstractPointLightNode) |
| 371 |
public |
| 372 |
constructor Create(const AX3DName: string = ''; const ABaseUrl: String = ''); override; |
| 373 |
function HasRadius: boolean; override; |
| 374 |
function Scope: TLightScope; override; |
| 375 |
{$I auto_generated_node_helpers/x3dnodes_pointlight_1.inc} |
| 376 |
end; |
| 377 |
|
| 378 |
TSpotLightNode_1 = class(TAbstractPositionalLightNode) |
| 379 |
protected |
| 380 |
function GetProjectionLocationLocal: TVector3; override; |
| 381 |
procedure SetProjectionLocationLocal(const Value: TVector3); override; |
| 382 |
function GetProjectionDirectionLocal: TVector3; override; |
| 383 |
procedure SetProjectionDirectionLocal(const Value: TVector3); override; |
| 384 |
public |
| 385 |
constructor Create(const AX3DName: string = ''; const ABaseUrl: String = ''); override; |
| 386 |
|
| 387 |
{ Spot exponent (based on dropOffRate). |
| 388 |
Not normalized (i.e. is a real exponent, in VRML 1.0 expresses |
| 389 |
in [0..1] range to mean exponents [0..128]). |
| 390 |
Clamp to correct range. } |
| 391 |
function SpotExponent: Single; |
| 392 |
|
| 393 |
{ Spot cutoff angle (based on cutOffAngle). |
| 394 |
|
| 395 |
Expressed in degrees, clamped to correct range |
| 396 |
(see TSpotLightNode.SpotCutoffDeg for reasons). |
| 397 |
(since user can input any value in VRML, and also conversion |
| 398 |
radians -> degrees could accidentally raise value slightly > 90, |
| 399 |
so cutOffAngle = 1.5708 is in degrees 90.0002104591, |
| 400 |
which would cause OpenGL fixed-function error). } |
| 401 |
function SpotCutoffDeg: Single; |
| 402 |
|
| 403 |
function SpotCosCutoff: Single; |
| 404 |
|
| 405 |
procedure UpdateLightInstance(var LightInstance: TLightInstance); override; |
| 406 |
|
| 407 |
function ProjectionMatrix: TMatrix4; override; |
| 408 |
function ModelviewMatrix: TMatrix4; override; |
| 409 |
function ModelviewRotationMatrix: TMatrix4; override; |
| 410 |
procedure Box3DDistances(const Box: TBox3D; |
| 411 |
out MinDistance, MaxDistance: Single); override; |
| 412 |
function HasRadius: boolean; override; |
| 413 |
function Scope: TLightScope; override; |
| 414 |
{$I auto_generated_node_helpers/x3dnodes_spotlight_1.inc} |
| 415 |
end; |
| 416 |
|
| 417 |
TGroupNode_1 = class(TAbstractChildNode) |
| 418 |
public |
| 419 |
constructor Create(const AX3DName: string = ''; const ABaseUrl: String = ''); override; |
| 420 |
{$I auto_generated_node_helpers/x3dnodes_group_1.inc} |
| 421 |
end; |
| 422 |
|
| 423 |
{ Base class for VRML 1.0 nodes that push / pop all attributes and matrices. |
| 424 |
It is used in implementation of VRML 1.0 Separator and WWWAnchor. |
| 425 |
Also WWWInline does the same work, when it's "separate" field is true. } |
| 426 |
TAbstractSeparatorNode_1 = class(TAbstractChildNode) |
| 427 |
protected |
| 428 |
procedure BeforeTraverse(StateStack: TX3DGraphTraverseStateStack); override; |
| 429 |
procedure AfterTraverse(StateStack: TX3DGraphTraverseStateStack); override; |
| 430 |
public |
| 431 |
constructor Create(const AX3DName: string = ''; const ABaseUrl: String = ''); override; |
| 432 |
{$I auto_generated_node_helpers/x3dnodes_abstractvrml1separator_1.inc} |
| 433 |
end; |
| 434 |
|
| 435 |
TSeparatorNode_1 = class(TAbstractSeparatorNode_1) |
| 436 |
{$I auto_generated_node_helpers/x3dnodes_separator_1.inc} |
| 437 |
end; |
| 438 |
|
| 439 |
TSwitchNode_1 = class(TAbstractChildNode) |
| 440 |
protected |
| 441 |
function DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer; override; |
| 442 |
public |
| 443 |
constructor Create(const AX3DName: string = ''; const ABaseUrl: String = ''); override; |
| 444 |
{$I auto_generated_node_helpers/x3dnodes_switch_1.inc} |
| 445 |
end; |
| 446 |
|
| 447 |
TTransformSeparatorNode_1 = class(TAbstractChildNode) |
| 448 |
strict private |
| 449 |
OriginalTransformation: TTransformation; |
| 450 |
protected |
| 451 |
procedure BeforeTraverse(StateStack: TX3DGraphTraverseStateStack); override; |
| 452 |
procedure AfterTraverse(StateStack: TX3DGraphTraverseStateStack); override; |
| 453 |
public |
| 454 |
constructor Create(const AX3DName: string = ''; const ABaseUrl: String = ''); override; |
| 455 |
{$I auto_generated_node_helpers/x3dnodes_transformseparator_1.inc} |
| 456 |
end; |
| 457 |
|
| 458 |
TWWWAnchorNode_1 = class(TAbstractSeparatorNode_1) |
| 459 |
{$I auto_generated_node_helpers/x3dnodes_wwwanchor_1.inc} |
| 460 |
end; |
| 461 |
|
| 462 |
{ VRML 1.0 WWWInline node. |
| 463 |
|
| 464 |
Implemented as a descendant of VRML 2.0/X3D Inline node |
| 465 |
class. This way VRML 1.0 actually gets a couple of VRML 2.0/X3D extensions. |
| 466 |
The VRML 2.0/X3D field "url" is renamed here to VRML 1.0 field "name". |
| 467 |
(Note that this means that WWWInline.name is actually MFString, |
| 468 |
not just SFString like VRML 1.0 spec says.) } |
| 469 |
TWWWInlineNode_1 = class(TInlineNode) |
| 470 |
protected |
| 471 |
function SeparateGroup: boolean; override; |
| 472 |
public |
| 473 |
constructor Create(const AX3DName: string = ''; const ABaseUrl: String = ''); override; |
| 474 |
{$I auto_generated_node_helpers/x3dnodes_wwwinline_1.inc} |
| 475 |
end; |
| 476 |
{$endif read_interface} |
| 477 |
|
| 478 |
{$ifdef read_implementation} |
| 479 |
|
| 480 |
const |
| 481 |
{ Constants for @link(TAsciiTextNode_1.FdJustification).Value. } |
| 482 |
JUSTIFICATION_LEFT = 0; |
| 483 |
JUSTIFICATION_CENTER = 1; |
| 484 |
JUSTIFICATION_RIGHT = 2; |
| 485 |
|
| 486 |
{ Arrays with TSFEnum (VRML 1 specific field) possible values. |
| 487 |
They have to be zero-based (we use High()+1 assuming it). } |
| 488 |
JustificationNames1: array [0..2] of String = ('LEFT', 'CENTER', 'RIGHT'); |
| 489 |
FamilyNames1: array [0..2] of String = ('SERIF', 'SANS', 'TYPEWRITER'); |
| 490 |
BindingNames1: array [0..7] of String = ('DEFAULT', 'OVERALL', 'PER_PART', 'PER_PART_INDEXED', 'PER_FACE', 'PER_FACE_INDEXED', 'PER_VERTEX', 'PER_VERTEX_INDEXED'); |
| 491 |
WrapNames1: array [0..1] of String = ('REPEAT', 'CLAMP'); |
| 492 |
TextureModelNames1: array [0..0] of String = ('DECAL'); |
| 493 |
MapNames1: array [0..1] of String = ('NONE', 'POINT'); |
| 494 |
RenderCullingNames1: array [0..2] of String = ('ON', 'OFF', 'AUTO'); |
| 495 |
FaceTypeNames1: array [0..1] of String = ('UNKNOWN_FACE_TYPE', 'CONVEX'); |
| 496 |
ShapeTypeNames1: array [0..1] of String = ('UNKNOWN_SHAPE_TYPE', 'SOLID'); |
| 497 |
VertexOrderingNames1: array [0..2] of String = ('UNKNOWN_ORDERING', 'CLOCKWISE', 'COUNTERCLOCKWISE'); |
| 498 |
|
| 499 |
destructor TAsciiTextNode_1.Destroy; |
| 500 |
begin |
| 501 |
if X3DCache <> nil then |
| 502 |
X3DCache.FreeFontTexture(FFontTextureNode); |
| 503 |
inherited; |
| 504 |
end; |
| 505 |
|
| 506 |
procedure TAsciiTextNode_1.FontChanged; |
| 507 |
begin |
| 508 |
if X3DCache <> nil then |
| 509 |
X3DCache.FreeFontTexture(FFontTextureNode); |
| 510 |
end; |
| 511 |
|
| 512 |
function TAsciiTextNode_1.Justify: TX3DFontJustify; |
| 513 |
begin |
| 514 |
case FdJustification.Value of |
| 515 |
JUSTIFICATION_LEFT : Result := fjBegin; |
| 516 |
JUSTIFICATION_CENTER: Result := fjMiddle; |
| 517 |
JUSTIFICATION_RIGHT : Result := fjEnd; |
| 518 |
else |
| 519 |
{ something default } |
| 520 |
Result := fjBegin; |
| 521 |
end; |
| 522 |
end; |
| 523 |
|
| 524 |
function TAsciiTextNode_1.Proxy(var State: TX3DGraphTraverseState): TAbstractGeometryNode; |
| 525 |
var |
| 526 |
FaceSet: TIndexedFaceSetNode_1; |
| 527 |
CoordNode: TCoordinate3Node_1; |
| 528 |
TexCoordNode: TTextureCoordinate2Node_1; |
| 529 |
I: Integer; |
| 530 |
begin |
| 531 |
FaceSet := TIndexedFaceSetNode_1.Create(X3DName, BaseUrl); |
| 532 |
try |
| 533 |
{ we have to modify State, so make a copy of it } |
| 534 |
State := TX3DGraphTraverseState.CreateCopy(State); |
| 535 |
|
| 536 |
CoordNode := TCoordinate3Node_1.Create('', BaseUrl); |
| 537 |
CoordNode.FdPoint.Items.Clear; |
| 538 |
State.VRML1State.SetOwnNode(vsCoordinate3, CoordNode); |
| 539 |
|
| 540 |
TexCoordNode := TTextureCoordinate2Node_1.Create('', BaseUrl); |
| 541 |
TexCoordNode.FdPoint.Items.Clear; |
| 542 |
State.VRML1State.SetOwnNode(vsTextureCoordinate2, TexCoordNode); |
| 543 |
|
| 544 |
TextProxy(Self, |
| 545 |
State.VRML1State.FontStyle.FdSize.Value, FdSpacing.Value, Justify, fjFirst, |
| 546 |
FdString.Items, -1, State.VRML1State.FontStyle.Font, |
| 547 |
false, nil, nil, nil, |
| 548 |
CoordNode.FdPoint, TexCoordNode.FdPoint, nil); |
| 549 |
|
| 550 |
{ calculate FaceSet.FdCoordIndex, just include all quads from CoordNode } |
| 551 |
FaceSet.FdCoordIndex.Items.Clear; |
| 552 |
for I := 0 to CoordNode.FdPoint.Count - 1 do |
| 553 |
begin |
| 554 |
FaceSet.FdCoordIndex.Items.Add(I); |
| 555 |
if (I + 1) mod 4 = 0 then |
| 556 |
FaceSet.FdCoordIndex.Items.Add(-1); |
| 557 |
end; |
| 558 |
|
| 559 |
{ For VRML 1.0, unfortunately textureCoordIndex must be set |
| 560 |
(even though it's exactly equivalent to coordIndex). } |
| 561 |
FaceSet.FdTextureCoordIndex.Items.Assign(FaceSet.FdCoordIndex.Items); |
| 562 |
|
| 563 |
Result := FaceSet; |
| 564 |
except FreeAndNil(FaceSet); raise end; |
| 565 |
|
| 566 |
if FFontTextureNode = nil then |
| 567 |
FFontTextureNode := X3DCache.LoadFontTexture( |
| 568 |
State.VRML1State.FontStyle.Font, |
| 569 |
State.VRML1State.FontStyle.Blending); |
| 570 |
end; |
| 571 |
|
| 572 |
function TAsciiTextNode_1.FontTextureNode: TAbstractTexture2DNode; |
| 573 |
begin |
| 574 |
Result := FFontTextureNode; |
| 575 |
end; |
| 576 |
|
| 577 |
function TConeNode_1.AutoGenerate3DTexCoords: boolean; |
| 578 |
begin |
| 579 |
Result := true; |
| 580 |
end; |
| 581 |
|
| 582 |
function TCubeNode_1.AutoGenerate3DTexCoords: boolean; |
| 583 |
begin |
| 584 |
Result := true; |
| 585 |
end; |
| 586 |
|
| 587 |
function TCylinderNode_1.AutoGenerate3DTexCoords: boolean; |
| 588 |
begin |
| 589 |
Result := true; |
| 590 |
end; |
| 591 |
|
| 592 |
constructor TAbstractIndexedNode_1.Create(const AX3DName: string = ''; const ABaseUrl: String = ''); |
| 593 |
begin |
| 594 |
inherited; |
| 595 |
FdCoordIndex.SaveToStreamLineUptoNegative := true; |
| 596 |
FdTextureCoordIndex.SaveToStreamLineUptoNegative := true; |
| 597 |
end; |
| 598 |
|
| 599 |
function TAbstractIndexedNode_1.InternalCoord(State: TX3DGraphTraverseState; |
| 600 |
out ACoord: TMFVec3f): boolean; |
| 601 |
begin |
| 602 |
Result := true; |
| 603 |
ACoord := State.VRML1State.Coordinate3.FdPoint; |
| 604 |
end; |
| 605 |
|
| 606 |
function TAbstractIndexedNode_1.CoordIndexField: TMFLong; |
| 607 |
begin |
| 608 |
Result := FdCoordIndex; |
| 609 |
end; |
| 610 |
|
| 611 |
function TIndexedFaceSetNode_1.InternalTexCoord(State: TX3DGraphTraverseState; |
| 612 |
out ATexCoord: TX3DNode): boolean; |
| 613 |
begin |
| 614 |
Result := true; |
| 615 |
ATexCoord := State.VRML1State.TextureCoordinate2; |
| 616 |
end; |
| 617 |
|
| 618 |
function TIndexedLineSetNode_1.InternalTexCoord(State: TX3DGraphTraverseState; |
| 619 |
out ATexCoord: TX3DNode): boolean; |
| 620 |
begin |
| 621 |
Result := true; |
| 622 |
ATexCoord := State.VRML1State.TextureCoordinate2; |
| 623 |
end; |
| 624 |
|
| 625 |
{$warnings off} // using deprecated to keep supporting VRML 1 |
| 626 |
function TIndexedLineSetNode_1.Lit(State: TX3DGraphTraverseState): boolean; |
| 627 |
begin |
| 628 |
{ This somewhat follows the logic of |
| 629 |
TAbstractNormalGenerator.NorImplementationFromVRML1Binding, |
| 630 |
answering "false" when NorImplementationFromVRML1Binding sets "niNone". } |
| 631 |
|
| 632 |
{ for _INDEXED normal binding, check normalIndex non-empty } |
| 633 |
case State.VRML1State.NormalBinding.FdValue.Value of |
| 634 |
BIND_DEFAULT, |
| 635 |
BIND_PER_VERTEX_INDEXED, |
| 636 |
BIND_PER_PART_INDEXED, |
| 637 |
BIND_PER_FACE_INDEXED: |
| 638 |
Result := (FdNormalIndex.Count <> 0) and |
| 639 |
(FdNormalIndex.Items.L[0] >= 0); |
| 640 |
else |
| 641 |
Result := true; |
| 642 |
end; |
| 643 |
|
| 644 |
{ check Normal.vector non-empty } |
| 645 |
if State.VRML1State.Normal.FdVector.Count = 0 then |
| 646 |
Result := false; |
| 647 |
end; |
| 648 |
{$warnings on} |
| 649 |
|
| 650 |
constructor TPointSetNode_1.Create(const AX3DName: string = ''; const ABaseUrl: String = ''); |
| 651 |
begin |
| 652 |
inherited; |
| 653 |
CoordSubrange := TMFVec3f.Create(Self, true, '', []); |
| 654 |
end; |
| 655 |
|
| 656 |
destructor TPointSetNode_1.Destroy; |
| 657 |
begin |
| 658 |
FreeAndNil(CoordSubrange); |
| 659 |
inherited; |
| 660 |
end; |
| 661 |
|
| 662 |
function TPointSetNode_1.InternalCoord(State: TX3DGraphTraverseState; |
| 663 |
out ACoord: TMFVec3f): boolean; |
| 664 |
|
| 665 |
procedure CalculateRange(CoordsCount: Cardinal; |
| 666 |
out StartIndex, NumPoints: integer); |
| 667 |
begin |
| 668 |
startIndex := FdStartIndex.Value; |
| 669 |
numPoints := FdNumPoints.Value; |
| 670 |
if startIndex >= CoordsCount then |
| 671 |
begin |
| 672 |
startIndex := 0; |
| 673 |
numPoints := 0; |
| 674 |
end else |
| 675 |
begin |
| 676 |
if startIndex < 0 then |
| 677 |
begin |
| 678 |
if numPoints >= 0 then numPoints := numPoints + startIndex; |
| 679 |
startIndex := 0; |
| 680 |
end; |
| 681 |
|
| 682 |
{startIndex juz jest na pewno dobry, teraz ew. popraw numPoints} |
| 683 |
if numPoints >= 0 then |
| 684 |
begin |
| 685 |
if startIndex + numPoints > CoordsCount then |
| 686 |
numPoints := CoordsCount - startIndex; |
| 687 |
end else |
| 688 |
numPoints := CoordsCount - startIndex; |
| 689 |
end; |
| 690 |
end; |
| 691 |
|
| 692 |
var |
| 693 |
FullCoord: TMFVec3f; |
| 694 |
StartIndex, NumPoints: integer; |
| 695 |
begin |
| 696 |
Result := true; |
| 697 |
|
| 698 |
FullCoord := State.VRML1State.Coordinate3.FdPoint; |
| 699 |
CalculateRange(FullCoord.Count, StartIndex, NumPoints); |
| 700 |
|
| 701 |
if (StartIndex = 0) and (NumPoints = FullCoord.Count) then |
| 702 |
ACoord := FullCoord else |
| 703 |
begin |
| 704 |
{ It's incredibly non-efficient to copy here, each time, coordinates |
| 705 |
contents. However, it's also the simplest correct implementation |
| 706 |
of the extremely-rare feature of startIndex / numPoints |
| 707 |
(VRML 1.0 is rare and outdated already!). |
| 708 |
|
| 709 |
As long as model stays static (and for strict VRML 1.0, it should |
| 710 |
always remain static), this will not be actually often called. } |
| 711 |
CoordSubrange.Items.Count := 0; |
| 712 |
CoordSubrange.Items.AddSubRange(FullCoord.Items, StartIndex, NumPoints); |
| 713 |
ACoord := CoordSubrange; |
| 714 |
end; |
| 715 |
end; |
| 716 |
|
| 717 |
function TPointSetNode_1.Lit(State: TX3DGraphTraverseState): boolean; |
| 718 |
begin |
| 719 |
Result := false; |
| 720 |
end; |
| 721 |
|
| 722 |
function TSphereNode_1.AutoGenerate3DTexCoords: boolean; |
| 723 |
begin |
| 724 |
Result := true; |
| 725 |
end; |
| 726 |
|
| 727 |
function TFontStyleNode_1.Family: TX3DFontFamily; |
| 728 |
begin |
| 729 |
Result := TX3DFontFamily(FdFamily.Value); |
| 730 |
end; |
| 731 |
|
| 732 |
{$warnings off} |
| 733 |
function TFontStyleNode_1.Bold: boolean; |
| 734 |
begin |
| 735 |
Result := FdStyle.Flags[FSSTYLE_BOLD]; |
| 736 |
end; |
| 737 |
|
| 738 |
function TFontStyleNode_1.Italic: boolean; |
| 739 |
begin |
| 740 |
Result := FdStyle.Flags[FSSTYLE_ITALIC]; |
| 741 |
end; |
| 742 |
{$warnings on} |
| 743 |
|
| 744 |
function TFontStyleNode_1.Font: TCastleFont; |
| 745 |
begin |
| 746 |
Result := TFontStyleNode.GetDefaultFont(Family, Bold, Italic); |
| 747 |
end; |
| 748 |
|
| 749 |
constructor TLODNode_1.Create(const AX3DName: string = ''; const ABaseUrl: String = ''); |
| 750 |
begin |
| 751 |
inherited; |
| 752 |
VRML1ChildrenAllowed := true; |
| 753 |
VRML1ChildrenParsingAllowed := true; |
| 754 |
end; |
| 755 |
|
| 756 |
function TLODNode_1.DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer; |
| 757 |
begin |
| 758 |
{ TODO: we should use here the LOD matching camera distance. |
| 759 |
For now, just like TLODNode.DirectEnumerateActive, we ignore the issue. } |
| 760 |
if VRML1ChildrenCount = 0 then |
| 761 |
raise EX3DError.Create('LOD node must have at least one child'); |
| 762 |
|
| 763 |
Result := Func(Self, VRML1Children[0]); |
| 764 |
if Result <> nil then Exit; |
| 765 |
end; |
| 766 |
|
| 767 |
destructor TMaterialNode_1.Destroy; |
| 768 |
var |
| 769 |
I: Integer; |
| 770 |
begin |
| 771 |
for I := 0 to Length(FMaterialInfo) - 1 do |
| 772 |
FreeAndNil(FMaterialInfo[I]); |
| 773 |
inherited; |
| 774 |
end; |
| 775 |
|
| 776 |
function TMaterialNode_1.PureEmissive: boolean; |
| 777 |
begin |
| 778 |
Result := (FdAmbientColor.Count = 0) and |
| 779 |
(FdDiffuseColor.Count = 0) and |
| 780 |
(FdSpecularColor.Count = 0); |
| 781 |
end; |
| 782 |
|
| 783 |
procedure TMaterialNode_1.ForcePureEmissive; |
| 784 |
begin |
| 785 |
FdAmbientColor .Count := 0; FdAmbientColor .Changed; |
| 786 |
FdDiffuseColor .Count := 0; FdDiffuseColor .Changed; |
| 787 |
FdSpecularColor.Count := 0; FdSpecularColor.Changed; |
| 788 |
Assert(PureEmissive); |
| 789 |
end; |
| 790 |
|
| 791 |
function TMaterialNode_1.MaterialInfo(const AIndex: Integer): TPhongMaterialInfo; |
| 792 |
begin |
| 793 |
if AIndex >= Length(FMaterialInfo) then |
| 794 |
SetLength(FMaterialInfo, AIndex + 1); |
| 795 |
if FMaterialInfo[AIndex] = nil then |
| 796 |
FMaterialInfo[AIndex] := TMaterialInfo_1.Create(Self, AIndex); |
| 797 |
Result := FMaterialInfo[AIndex]; |
| 798 |
end; |
| 799 |
|
| 800 |
{ TMaterialInfo_1 --------------------------------------------------------- } |
| 801 |
|
| 802 |
constructor TMaterialNode_1.TMaterialInfo_1.Create(ANode: TMaterialNode_1; const Index: Integer); |
| 803 |
begin |
| 804 |
inherited Create(ANode); |
| 805 |
FNode := ANode; |
| 806 |
FIndex := Index; |
| 807 |
end; |
| 808 |
|
| 809 |
function TMaterialNode_1.TMaterialInfo_1.AmbientColor: TVector3; |
| 810 |
var |
| 811 |
A: TVector3List; |
| 812 |
begin |
| 813 |
A := FNode.FdAmbientColor.Items; |
| 814 |
if A.Count = 0 then |
| 815 |
Result := TPhongMaterialInfo.DefaultAmbientColor |
| 816 |
else |
| 817 |
Result := A.L[Min(FIndex, A.Count - 1)]; |
| 818 |
end; |
| 819 |
|
| 820 |
function TMaterialNode_1.TMaterialInfo_1.GetDiffuseColor: TVector3; |
| 821 |
var |
| 822 |
A: TVector3List; |
| 823 |
begin |
| 824 |
A := FNode.FdDiffuseColor.Items; |
| 825 |
if A.Count = 0 then |
| 826 |
Result := TPhongMaterialInfo.DefaultDiffuseColor |
| 827 |
else |
| 828 |
Result := A.L[Min(FIndex, A.Count - 1)]; |
| 829 |
end; |
| 830 |
|
| 831 |
procedure TMaterialNode_1.TMaterialInfo_1.SetDiffuseColor(const Value: TVector3); |
| 832 |
begin |
| 833 |
FNode.FdDiffuseColor.Send([Value]); |
| 834 |
end; |
| 835 |
|
| 836 |
function TMaterialNode_1.TMaterialInfo_1.GetSpecularColor: TVector3; |
| 837 |
var |
| 838 |
A: TVector3List; |
| 839 |
begin |
| 840 |
A := FNode.FdSpecularColor.Items; |
| 841 |
if A.Count = 0 then |
| 842 |
Result := TPhongMaterialInfo.DefaultSpecularColor |
| 843 |
else |
| 844 |
Result := A.L[Min(FIndex, A.Count - 1)]; |
| 845 |
end; |
| 846 |
|
| 847 |
procedure TMaterialNode_1.TMaterialInfo_1.SetSpecularColor(const Value: TVector3); |
| 848 |
begin |
| 849 |
FNode.FdSpecularColor.Send([Value]); |
| 850 |
end; |
| 851 |
|
| 852 |
function TMaterialNode_1.TMaterialInfo_1.GetEmissiveColor: TVector3; |
| 853 |
var |
| 854 |
A: TVector3List; |
| 855 |
begin |
| 856 |
A := FNode.FdEmissiveColor.Items; |
| 857 |
if A.Count = 0 then |
| 858 |
Result := TPhongMaterialInfo.DefaultEmissiveColor |
| 859 |
else |
| 860 |
Result := A.L[Min(FIndex, A.Count - 1)]; |
| 861 |
end; |
| 862 |
|
| 863 |
procedure TMaterialNode_1.TMaterialInfo_1.SetEmissiveColor(const Value: TVector3); |
| 864 |
begin |
| 865 |
FNode.FdEmissiveColor.Send([Value]); |
| 866 |
end; |
| 867 |
|
| 868 |
function TMaterialNode_1.TMaterialInfo_1.Shininess: Single; |
| 869 |
var |
| 870 |
A: TSingleList; |
| 871 |
begin |
| 872 |
A := FNode.FdShininess.Items; |
| 873 |
if A.Count = 0 then |
| 874 |
Result := TPhongMaterialInfo.DefaultShininess |
| 875 |
else |
| 876 |
Result := A.L[Min(FIndex, A.Count - 1)]; |
| 877 |
end; |
| 878 |
|
| 879 |
function TMaterialNode_1.TMaterialInfo_1.ReflectionColor: TVector3; |
| 880 |
var |
| 881 |
A: TSingleList; |
| 882 |
M: Single; |
| 883 |
begin |
| 884 |
A := FNode.FdMirror.Items; |
| 885 |
if A.Count = 0 then |
| 886 |
M := 0.0 // TMaterialInfo.DefaultReflectionColor[0, 1 or 2] |
| 887 |
else |
| 888 |
M := A.L[Min(FIndex, A.Count - 1)]; |
| 889 |
|
| 890 |
Result := Vector3(M, M, M); |
| 891 |
end; |
| 892 |
|
| 893 |
function TMaterialNode_1.TMaterialInfo_1.Transparency: Single; |
| 894 |
var |
| 895 |
A: TSingleList; |
| 896 |
begin |
| 897 |
A := FNode.FdTransparency.Items; |
| 898 |
if A.Count = 0 then |
| 899 |
Result := TMaterialInfo.DefaultTransparency |
| 900 |
else |
| 901 |
Result := A.L[Min(FIndex, A.Count - 1)]; |
| 902 |
end; |
| 903 |
|
| 904 |
function TMaterialNode_1.TMaterialInfo_1.ReflSpecular: TVector3; |
| 905 |
var |
| 906 |
A: TVector3List; |
| 907 |
begin |
| 908 |
A := FNode.FdReflSpecular.Items; |
| 909 |
if A.Count = 0 then |
| 910 |
Result := inherited |
| 911 |
else |
| 912 |
Result := A.L[Min(FIndex, A.Count - 1)]; |
| 913 |
end; |
| 914 |
|
| 915 |
function TMaterialNode_1.TMaterialInfo_1.ReflDiffuse: TVector3; |
| 916 |
var |
| 917 |
A: TVector3List; |
| 918 |
begin |
| 919 |
A := FNode.FdReflDiffuse.Items; |
| 920 |
if A.Count = 0 then |
| 921 |
Result := inherited |
| 922 |
else |
| 923 |
Result := A.L[Min(FIndex, A.Count - 1)]; |
| 924 |
end; |
| 925 |
|
| 926 |
function TMaterialNode_1.TMaterialInfo_1.TransSpecular: TVector3; |
| 927 |
var |
| 928 |
A: TVector3List; |
| 929 |
begin |
| 930 |
A := FNode.FdTransSpecular.Items; |
| 931 |
if A.Count = 0 then |
| 932 |
Result := inherited |
| 933 |
else |
| 934 |
Result := A.L[Min(FIndex, A.Count - 1)]; |
| 935 |
end; |
| 936 |
|
| 937 |
function TMaterialNode_1.TMaterialInfo_1.TransDiffuse: TVector3; |
| 938 |
var |
| 939 |
A: TVector3List; |
| 940 |
begin |
| 941 |
A := FNode.FdTransDiffuse.Items; |
| 942 |
if A.Count = 0 then |
| 943 |
Result := inherited |
| 944 |
else |
| 945 |
Result := A.L[Min(FIndex, A.Count - 1)]; |
| 946 |
end; |
| 947 |
|
| 948 |
function TMaterialNode_1.TMaterialInfo_1.ReflSpecularExp: Single; |
| 949 |
var |
| 950 |
A: TSingleList; |
| 951 |
begin |
| 952 |
A := FNode.FdReflSpecularExp.Items; |
| 953 |
if A.Count = 0 then |
| 954 |
Result := inherited |
| 955 |
else |
| 956 |
Result := A.L[Min(FIndex, A.Count - 1)]; |
| 957 |
end; |
| 958 |
|
| 959 |
function TMaterialNode_1.TMaterialInfo_1.TransSpecularExp: Single; |
| 960 |
var |
| 961 |
A: TSingleList; |
| 962 |
begin |
| 963 |
A := FNode.FdTransSpecularExp.Items; |
| 964 |
if A.Count = 0 then |
| 965 |
Result := inherited |
| 966 |
else |
| 967 |
Result := A.L[Min(FIndex, A.Count - 1)]; |
| 968 |
end; |
| 969 |
|
| 970 |
{ TTexture2Node_1 ------------------------------------------------------------ } |
| 971 |
|
| 972 |
const |
| 973 |
{ Constants for @link(TTexture2Node_1.FdWrapS).Value and @link(TTexture2Node_1.FdWrapT).Value. } |
| 974 |
TEXWRAP_REPEAT = 0; |
| 975 |
TEXWRAP_CLAMP = 1; |
| 976 |
|
| 977 |
procedure TTexture2Node_1.ParseAfter(Reader: TX3DReaderNames); |
| 978 |
begin |
| 979 |
inherited; |
| 980 |
|
| 981 |
{ Implementation of VRML 1 node TTexture2Node_1 |
| 982 |
just copies the FdWrapS/T values to X3D fields RepeatS/T at parsing. |
| 983 |
|
| 984 |
This makes code easier (the rest of code can just use |
| 985 |
TAbstractTexture2DNode.RepeatS/T). |
| 986 |
It also makes small unexpected issue -- if you would construct |
| 987 |
VRML 1 node TTexture2Node_1 by code, |
| 988 |
you actually should set RepeatS/T and not WrapS/T. |
| 989 |
But, as VRML 1.0 is deprecated and ancient format now, this is acceptable. |
| 990 |
} |
| 991 |
|
| 992 |
RepeatS := FdWrapS.Value = TEXWRAP_REPEAT; |
| 993 |
RepeatT := FdWrapT.Value = TEXWRAP_REPEAT; |
| 994 |
end; |
| 995 |
|
| 996 |
procedure TTexture2Node_1.LoadTextureData(out CacheUsed: boolean); |
| 997 |
var |
| 998 |
FullUrl: String; |
| 999 |
begin |
| 1000 |
CacheUsed := false; |
| 1001 |
FTextureUsedFullUrl := ''; |
| 1002 |
|
| 1003 |
{ load from FdFilename } |
| 1004 |
if FdFilename.Value <> '' then |
| 1005 |
try |
| 1006 |
FullUrl := PathFromBaseUrl(FdFilename.Value); |
| 1007 |
FTextureImage := X3DCache.TextureImage_IncReference( |
| 1008 |
FullUrl, FTextureComposite, FAlphaChannelData); |
| 1009 |
FTextureUsedFullUrl := FullUrl; |
| 1010 |
CacheUsed := true; |
| 1011 |
Exit; |
| 1012 |
except |
| 1013 |
on E: Exception do |
| 1014 |
{ Remember that WritelnWarning *may* raise an exception. } |
| 1015 |
WritelnWarning('Texture', Format(SLoadError, |
| 1016 |
[E.ClassName, 'texture', UriDisplay(FullUrl), E.Message])); |
| 1017 |
end; |
| 1018 |
|
| 1019 |
{ Still not loaded (maybe FdFilename.Value is '' |
| 1020 |
or loading image raised exception)? So try to use inlined texture. } |
| 1021 |
if not FdImage.Value.IsEmpty then |
| 1022 |
FTextureImage := FdImage.Value.MakeCopy; |
| 1023 |
end; |
| 1024 |
|
| 1025 |
function TTexture2Node_1.TextureDescription: string; |
| 1026 |
|
| 1027 |
function InlinedDescr: string; |
| 1028 |
begin |
| 1029 |
Result := Format('inlined (width = %d; height = %d; with alpha = %s)', |
| 1030 |
[ FdImage.Value.Width, |
| 1031 |
FdImage.Value.Height, |
| 1032 |
BoolToStr(FdImage.Value.HasAlpha, true) ]); |
| 1033 |
end; |
| 1034 |
|
| 1035 |
begin |
| 1036 |
if FdFilename.Value <> '' then |
| 1037 |
begin |
| 1038 |
Result := 'file "' +PathFromBaseUrl(FdFilename.Value) +'"'; |
| 1039 |
if not FdImage.Value.IsEmpty then |
| 1040 |
Result := Result + (' (and '+InlinedDescr+')'); |
| 1041 |
end else |
| 1042 |
if not FdImage.Value.IsEmpty then |
| 1043 |
Result := InlinedDescr else |
| 1044 |
Result := 'none'; |
| 1045 |
end; |
| 1046 |
|
| 1047 |
function TTexture2TransformNode_1.TextureMatrixTransformation: TMatrix4; |
| 1048 |
begin |
| 1049 |
Result := |
| 1050 |
TranslationMatrix(Vector3(FdTranslation.Value + FdCenter.Value, 0)) * |
| 1051 |
RotationMatrixRad(FdRotation.Value, Vector3(0, 0, 1)) * |
| 1052 |
ScalingMatrix(Vector3(FdScaleFactor.Value[0], FdScaleFactor.Value[1], 1)) * |
| 1053 |
TranslationMatrix(Vector3(-FdCenter.Value[0], -FdCenter.Value[1], 0)); |
| 1054 |
end; |
| 1055 |
|
| 1056 |
procedure TTexture2TransformNode_1.MiddleTraverse(StateStack: TX3DGraphTraverseStateStack); |
| 1057 |
begin |
| 1058 |
inherited; |
| 1059 |
StateStack.Top.TextureTransform := StateStack.Top.TextureTransform * |
| 1060 |
TextureMatrixTransformation; |
| 1061 |
end; |
| 1062 |
|
| 1063 |
function TShapeHintsNode_1.ParseNodeBodyElement(Lexer: TX3DLexer; Reader: TX3DReaderNames; |
| 1064 |
const APositionInParent: Integer): boolean; |
| 1065 |
var |
| 1066 |
Hints: TSFBitMask; |
| 1067 |
begin |
| 1068 |
Result := inherited; |
| 1069 |
|
| 1070 |
if not Result then |
| 1071 |
begin |
| 1072 |
Result := (Lexer.Version.Major = 0) and |
| 1073 |
(Lexer.Token = vtName) and |
| 1074 |
(Lexer.TokenName = 'hints'); |
| 1075 |
if Result then |
| 1076 |
begin |
| 1077 |
Hints := TSFBitMask.Create(Self, true, 'hints', |
| 1078 |
['SOLID', 'ORDERED', 'CONVEX'], 'NONE', '', |
| 1079 |
[ false, true, true]); |
| 1080 |
try |
| 1081 |
Lexer.NextToken; |
| 1082 |
Hints.Parse(Lexer, Reader, false); |
| 1083 |
{$warnings off} // using deprecated to keep supporting VRML 1 |
| 1084 |
if Hints.Flags[0] then |
| 1085 |
FdShapeType.Value := SHTYPE_SOLID else |
| 1086 |
FdShapeType.Value := SHTYPE_UNKNOWN; |
| 1087 |
if Hints.Flags[1] then |
| 1088 |
FdVertexOrdering.Value := VERTORDER_COUNTERCLOCKWISE else |
| 1089 |
FdVertexOrdering.Value := VERTORDER_UNKNOWN; |
| 1090 |
if Hints.Flags[2] then |
| 1091 |
FdFaceType.Value := FACETYPE_CONVEX else |
| 1092 |
FdFaceType.Value := FACETYPE_UNKNOWN; |
| 1093 |
{$warnings on} |
| 1094 |
finally Hints.Free end; |
| 1095 |
end; |
| 1096 |
end; |
| 1097 |
end; |
| 1098 |
|
| 1099 |
procedure TMatrixTransformNode_1.MiddleTraverse(StateStack: TX3DGraphTraverseStateStack); |
| 1100 |
begin |
| 1101 |
inherited; |
| 1102 |
StateStack.Top.Transformation.MultiplyMatrix(FdMatrix.Value); |
| 1103 |
end; |
| 1104 |
|
| 1105 |
procedure TRotationNode_1.MiddleTraverse(StateStack: TX3DGraphTraverseStateStack); |
| 1106 |
begin |
| 1107 |
inherited; |
| 1108 |
StateStack.Top.Transformation.Multiply(FdRotation.Value, Vector3(1, 1, 1), TVector3.Zero); |
| 1109 |
end; |
| 1110 |
|
| 1111 |
procedure TScaleNode_1.MiddleTraverse(StateStack: TX3DGraphTraverseStateStack); |
| 1112 |
begin |
| 1113 |
inherited; |
| 1114 |
StateStack.Top.Transformation.Multiply(TVector4.Zero, FdScaleFactor.Value, TVector3.Zero); |
| 1115 |
end; |
| 1116 |
|
| 1117 |
procedure TTransformNode_1.MiddleTraverse(StateStack: TX3DGraphTraverseStateStack); |
| 1118 |
begin |
| 1119 |
inherited; |
| 1120 |
StateStack.Top.Transformation.Multiply( |
| 1121 |
FdCenter.Value, |
| 1122 |
FdRotation.Value, |
| 1123 |
FdScaleFactor.Value, |
| 1124 |
FdScaleOrientation.Value, |
| 1125 |
FdTranslation.Value); |
| 1126 |
end; |
| 1127 |
|
| 1128 |
procedure TTranslationNode_1.MiddleTraverse(StateStack: TX3DGraphTraverseStateStack); |
| 1129 |
begin |
| 1130 |
inherited; |
| 1131 |
StateStack.Top.Transformation.Multiply(TVector4.Zero, Vector3(1, 1, 1), FdTranslation.Value); |
| 1132 |
end; |
| 1133 |
|
| 1134 |
function TAbstractCameraNode_1.PositionField: TSFVec3f; |
| 1135 |
begin |
| 1136 |
Result := FdPosition; |
| 1137 |
end; |
| 1138 |
|
| 1139 |
class function TOrthographicCameraNode_1.ProjectionType: TProjectionType; |
| 1140 |
begin |
| 1141 |
Result := ptOrthographic; |
| 1142 |
end; |
| 1143 |
|
| 1144 |
class function TPerspectiveCameraNode_1.ProjectionType: TProjectionType; |
| 1145 |
begin |
| 1146 |
Result := ptPerspective; |
| 1147 |
end; |
| 1148 |
|
| 1149 |
function TDirectionalLightNode_1.Scope: TLightScope; |
| 1150 |
begin |
| 1151 |
if FdGlobal.Value then |
| 1152 |
Result := lsGlobal else |
| 1153 |
Result := lsLocalVRML1; |
| 1154 |
end; |
| 1155 |
|
| 1156 |
constructor TPointLightNode_1.Create(const AX3DName: string = ''; const ABaseUrl: String = ''); |
| 1157 |
begin |
| 1158 |
inherited; |
| 1159 |
{ Default location value for VRML 1.0, was changed in VRML >= 2.0 } |
| 1160 |
FdLocation.Value := Vector3(0, 0, 1); |
| 1161 |
FdLocation.DefaultValue := Vector3(0, 0, 1); |
| 1162 |
end; |
| 1163 |
|
| 1164 |
function TPointLightNode_1.HasRadius: boolean; |
| 1165 |
begin |
| 1166 |
Result := false; |
| 1167 |
end; |
| 1168 |
|
| 1169 |
function TPointLightNode_1.Scope: TLightScope; |
| 1170 |
begin |
| 1171 |
if FdGlobal.Value then |
| 1172 |
Result := lsGlobal else |
| 1173 |
Result := lsLocalVRML1; |
| 1174 |
end; |
| 1175 |
|
| 1176 |
constructor TSpotLightNode_1.Create(const AX3DName: string = ''; const ABaseUrl: String = ''); |
| 1177 |
begin |
| 1178 |
inherited; |
| 1179 |
{ Default location value for VRML 1.0, was changed in VRML >= 2.0 } |
| 1180 |
FdLocation.Value := Vector3(0, 0, 1); |
| 1181 |
FdLocation.DefaultValue := Vector3(0, 0, 1); |
| 1182 |
end; |
| 1183 |
|
| 1184 |
function TSpotLightNode_1.SpotExponent: Single; |
| 1185 |
begin |
| 1186 |
Result := Clamped(FdDropOffRate.Value * 128.0, 0.0, 128.0); |
| 1187 |
end; |
| 1188 |
|
| 1189 |
function TSpotLightNode_1.SpotCutoffDeg: Single; |
| 1190 |
begin |
| 1191 |
Result := Min(90, RadToDeg(FdCutOffAngle.Value)); |
| 1192 |
end; |
| 1193 |
|
| 1194 |
function TSpotLightNode_1.SpotCosCutoff: Single; |
| 1195 |
begin |
| 1196 |
Result := Cos(FdCutOffAngle.Value); |
| 1197 |
end; |
| 1198 |
|
| 1199 |
procedure TSpotLightNode_1.UpdateLightInstance(var LightInstance: TLightInstance); |
| 1200 |
begin |
| 1201 |
inherited; |
| 1202 |
LightInstance.Direction := |
| 1203 |
LightInstance.Transform.MultDirection(FdDirection.Value).Normalize; |
| 1204 |
end; |
| 1205 |
|
| 1206 |
function TSpotLightNode_1.ProjectionMatrix: TMatrix4; |
| 1207 |
var |
| 1208 |
Angle, N, F: Single; |
| 1209 |
begin |
| 1210 |
{ If author didn't provide and CastleInternalShadowMaps unit didn't calculate |
| 1211 |
values for some fields, then use FallbackProjection* defaults here. } |
| 1212 |
|
| 1213 |
{ Implementation just like for TSpotLightNode, |
| 1214 |
except I was too lazy to add here projectionAngle. } |
| 1215 |
Angle := 2 * FdCutOffAngle.Value; |
| 1216 |
|
| 1217 |
N := FdProjectionNear.Value; |
| 1218 |
if N = 0 then N := FallbackProjectionNear; |
| 1219 |
|
| 1220 |
F := FdProjectionFar.Value; |
| 1221 |
if F = 0 then F := FallbackProjectionFar; |
| 1222 |
|
| 1223 |
Result := PerspectiveProjectionMatrixRad(Angle, 1, N, F); |
| 1224 |
end; |
| 1225 |
|
| 1226 |
function TSpotLightNode_1.ModelviewMatrix: TMatrix4; |
| 1227 |
var |
| 1228 |
Pos, Dir, Side, AUp: TVector3; |
| 1229 |
begin |
| 1230 |
GetView(Pos, Dir, Side, AUp); |
| 1231 |
Result := LookDirMatrix(Pos, Dir, Side, AUp); |
| 1232 |
end; |
| 1233 |
|
| 1234 |
function TSpotLightNode_1.ModelviewRotationMatrix: TMatrix4; |
| 1235 |
var |
| 1236 |
Pos, Dir, Side, AUp: TVector3; |
| 1237 |
begin |
| 1238 |
GetView(Pos, Dir, Side, AUp); |
| 1239 |
Result := FastLookDirMatrix(Dir, AUp); |
| 1240 |
end; |
| 1241 |
|
| 1242 |
function TSpotLightNode_1.GetProjectionLocationLocal: TVector3; |
| 1243 |
begin |
| 1244 |
Result := FdLocation.Value; |
| 1245 |
end; |
| 1246 |
|
| 1247 |
procedure TSpotLightNode_1.SetProjectionLocationLocal(const Value: TVector3); |
| 1248 |
begin |
| 1249 |
FdLocation.Send(Value); |
| 1250 |
end; |
| 1251 |
|
| 1252 |
function TSpotLightNode_1.GetProjectionDirectionLocal: TVector3; |
| 1253 |
begin |
| 1254 |
Result := FdDirection.Value; |
| 1255 |
end; |
| 1256 |
|
| 1257 |
procedure TSpotLightNode_1.SetProjectionDirectionLocal(const Value: TVector3); |
| 1258 |
begin |
| 1259 |
FdDirection.Send(Value); |
| 1260 |
end; |
| 1261 |
|
| 1262 |
function TSpotLightNode_1.HasRadius: boolean; |
| 1263 |
begin |
| 1264 |
Result := false; |
| 1265 |
end; |
| 1266 |
|
| 1267 |
procedure TSpotLightNode_1.Box3DDistances(const Box: TBox3D; |
| 1268 |
out MinDistance, MaxDistance: Single); |
| 1269 |
begin |
| 1270 |
{ TODO: MaxDistance should be a little larger, as spot light rays |
| 1271 |
are not parallel. } |
| 1272 |
Box.DirectionDistances(ProjectionWorldLocation, ProjectionWorldDirection, MinDistance, MaxDistance); |
| 1273 |
end; |
| 1274 |
|
| 1275 |
function TSpotLightNode_1.Scope: TLightScope; |
| 1276 |
begin |
| 1277 |
if FdGlobal.Value then |
| 1278 |
Result := lsGlobal else |
| 1279 |
Result := lsLocalVRML1; |
| 1280 |
end; |
| 1281 |
|
| 1282 |
constructor TGroupNode_1.Create(const AX3DName: string = ''; const ABaseUrl: String = ''); |
| 1283 |
begin |
| 1284 |
inherited; |
| 1285 |
VRML1ChildrenAllowed := true; |
| 1286 |
VRML1ChildrenParsingAllowed := true; |
| 1287 |
end; |
| 1288 |
|
| 1289 |
constructor TAbstractSeparatorNode_1.Create(const AX3DName: string = ''; const ABaseUrl: String = ''); |
| 1290 |
begin |
| 1291 |
inherited; |
| 1292 |
VRML1ChildrenAllowed := true; |
| 1293 |
VRML1ChildrenParsingAllowed := true; |
| 1294 |
end; |
| 1295 |
|
| 1296 |
type |
| 1297 |
TVRML1SeparatorEnumerator = class |
| 1298 |
State: TX3DGraphTraverseState; |
| 1299 |
function Enumerate(Node, Child: TX3DNode): Pointer; |
| 1300 |
end; |
| 1301 |
|
| 1302 |
function TVRML1SeparatorEnumerator.Enumerate(Node, Child: TX3DNode): Pointer; |
| 1303 |
begin |
| 1304 |
Result := nil; |
| 1305 |
if Child is TLocalFogNode then |
| 1306 |
State.LocalFog := TLocalFogNode(Child); |
| 1307 |
end; |
| 1308 |
|
| 1309 |
procedure TAbstractSeparatorNode_1.BeforeTraverse(StateStack: TX3DGraphTraverseStateStack); |
| 1310 |
var |
| 1311 |
Enumerator: TVRML1SeparatorEnumerator; |
| 1312 |
begin |
| 1313 |
inherited; |
| 1314 |
StateStack.Push; |
| 1315 |
|
| 1316 |
{ Use TVRML1SeparatorEnumerator, to propagate LocalFog into children, |
| 1317 |
just like VRML >= 2 grouping nodes. Otherwise LocalFog would |
| 1318 |
never work in VRML 1.0. } |
| 1319 |
Enumerator := TVRML1SeparatorEnumerator.Create; |
| 1320 |
try |
| 1321 |
Enumerator.State := StateStack.Top; |
| 1322 |
DirectEnumerateActive({$ifdef FPC}@{$endif} Enumerator.Enumerate); |
| 1323 |
finally FreeAndNil(Enumerator) end; |
| 1324 |
end; |
| 1325 |
|
| 1326 |
procedure TAbstractSeparatorNode_1.AfterTraverse(StateStack: TX3DGraphTraverseStateStack); |
| 1327 |
begin |
| 1328 |
StateStack.Pop; |
| 1329 |
inherited; |
| 1330 |
end; |
| 1331 |
|
| 1332 |
constructor TSwitchNode_1.Create(const AX3DName: string = ''; const ABaseUrl: String = ''); |
| 1333 |
begin |
| 1334 |
inherited; |
| 1335 |
VRML1ChildrenAllowed := true; |
| 1336 |
VRML1ChildrenParsingAllowed := true; |
| 1337 |
end; |
| 1338 |
|
| 1339 |
function TSwitchNode_1.DirectEnumerateActive(Func: TEnumerateChildrenFunction): Pointer; |
| 1340 |
begin |
| 1341 |
Result := nil; |
| 1342 |
|
| 1343 |
if FdWhichChild.Value = -3 then |
| 1344 |
begin |
| 1345 |
{ Enumerate all. |
| 1346 |
Note : value -3 is already deprecated in VRML 1.0; |
| 1347 |
but I support it, at least for now. } |
| 1348 |
Result := inherited; |
| 1349 |
if Result <> nil then Exit; |
| 1350 |
end else |
| 1351 |
begin |
| 1352 |
{ Jezeli whichChild jest nieprawidlowe to w rezultacie nie wejdziemy w |
| 1353 |
zadne Child. Wpp. wejdziemy w jedno wyznaczone child. I o to chodzi. |
| 1354 |
(note : value -1 is no special value; any value that doesn't specify |
| 1355 |
valid child number and is not -3 instructs Switch to not enter |
| 1356 |
into any child. This is conforming with the VRML 97 specification) } |
| 1357 |
if Between(FdWhichChild.Value, 0, VRML1ChildrenCount - 1) then |
| 1358 |
begin |
| 1359 |
Result := Func(Self, VRML1Children[FdWhichChild.Value]); |
| 1360 |
if Result <> nil then Exit; |
| 1361 |
end; |
| 1362 |
end; |
| 1363 |
end; |
| 1364 |
|
| 1365 |
constructor TTransformSeparatorNode_1.Create(const AX3DName: string = ''; const ABaseUrl: String = ''); |
| 1366 |
begin |
| 1367 |
inherited; |
| 1368 |
VRML1ChildrenAllowed := true; |
| 1369 |
VRML1ChildrenParsingAllowed := true; |
| 1370 |
end; |
| 1371 |
|
| 1372 |
procedure TTransformSeparatorNode_1.BeforeTraverse(StateStack: TX3DGraphTraverseStateStack); |
| 1373 |
begin |
| 1374 |
inherited; |
| 1375 |
|
| 1376 |
{ We don't copy whole State.Top here, as changes to other properties of |
| 1377 |
state should "leak out" from TransformSeparator node. } |
| 1378 |
|
| 1379 |
OriginalTransformation := StateStack.Top.Transformation; |
| 1380 |
end; |
| 1381 |
|
| 1382 |
procedure TTransformSeparatorNode_1.AfterTraverse(StateStack: TX3DGraphTraverseStateStack); |
| 1383 |
begin |
| 1384 |
StateStack.Top.Transformation := OriginalTransformation; |
| 1385 |
inherited; |
| 1386 |
end; |
| 1387 |
|
| 1388 |
constructor TWWWInlineNode_1.Create(const AX3DName: string = ''; const ABaseUrl: String = ''); |
| 1389 |
begin |
| 1390 |
inherited; |
| 1391 |
|
| 1392 |
{ change "url" field to "name", with default value being an empty string } |
| 1393 |
FdUrl.AddAlternativeName('name', 1); |
| 1394 |
FdUrl.Items.Add(''); |
| 1395 |
FdUrl.AssignDefaultValueFromValue; |
| 1396 |
|
| 1397 |
{ bboxSize is (0, 0, 0) in VRML 1.0 (in VRML 2.0/X3D it's (-1, -1, -1)) } |
| 1398 |
FdBboxSize.Value := Vector3(0, 0, 0); |
| 1399 |
FdBboxSize.AssignDefaultValueFromValue; |
| 1400 |
end; |
| 1401 |
|
| 1402 |
function TWWWInlineNode_1.SeparateGroup: boolean; |
| 1403 |
begin |
| 1404 |
Result := FdSeparate.Value; |
| 1405 |
end; |
| 1406 |
|
| 1407 |
procedure RegisterVRML1Nodes; |
| 1408 |
begin |
| 1409 |
NodesManager.RegisterNodeClasses([ |
| 1410 |
TAsciiTextNode_1, TConeNode_1, TCubeNode_1, TCylinderNode_1, |
| 1411 |
TIndexedFaceSetNode_1, TIndexedLineSetNode_1, |
| 1412 |
TPointSetNode_1, TSphereNode_1, |
| 1413 |
TCoordinate3Node_1, TFontStyleNode_1, TInfoNode_1, TLODNode_1, TMaterialNode_1, |
| 1414 |
TMaterialBindingNode_1, TNormalBindingNode_1, TTexture2Node_1, |
| 1415 |
TTexture2TransformNode_1, |
| 1416 |
TTextureCoordinate2Node_1, TShapeHintsNode_1, |
| 1417 |
TMatrixTransformNode_1, TRotationNode_1, |
| 1418 |
TScaleNode_1, TTransformNode_1, |
| 1419 |
TTranslationNode_1, |
| 1420 |
TOrthographicCameraNode_1, TPerspectiveCameraNode_1, |
| 1421 |
TDirectionalLightNode_1, TPointLightNode_1, TSpotLightNode_1, |
| 1422 |
TGroupNode_1, TSeparatorNode_1, TSwitchNode_1, TTransformSeparatorNode_1, |
| 1423 |
TWWWAnchorNode_1, |
| 1424 |
TWWWInlineNode_1 |
| 1425 |
]); |
| 1426 |
end; |
| 1427 |
|
| 1428 |
{$endif read_implementation} |