/usr/src/castle-game-engine-4.1.1/x3d/x3d_networking.inc is in castle-game-engine-src 4.1.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 | {
Copyright 2002-2013 Michalis Kamburelis.
This file is part of "Castle Game Engine".
"Castle Game Engine" is free software; see the file COPYING.txt,
included in this distribution, for details about the copyright.
"Castle Game Engine" is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
----------------------------------------------------------------------------
}
{$ifdef read_interface}
{ }
TAbstractNetworkSensorNode = class(TAbstractSensorNode)
public
procedure CreateNode; override;
end;
IAbstractUrlObject = interface(IX3DNode)
['{668420DB-20F7-4A5E-BB89-52F29CA39057}']
property FdUrl: TMFString { read GetFdurl }; { }
end;
TAbstractViewpointNode = class;
TAnchorNode = class(TAbstractX3DGroupingNode)
protected
procedure DirectEnumerateActive(
Func: TEnumerateChildrenFunction); override;
public
procedure CreateNode; override;
class function ClassNodeTypeName: string; override;
class function URNMatching(const URN: string): boolean; override;
private FFdDescription: TSFString;
public property FdDescription: TSFString read FFdDescription;
private FFdParameter: TMFString;
public property FdParameter: TMFString read FFdParameter;
private FFdUrl: TMFString;
public property FdUrl: TMFString read FFdUrl;
{ Load the document, world and/or viewpoint referenced by this Anchor node.
This iterates over url field, for each URL trying to load
referenced file. If URL specifies viewpoint name within 3D file (or current
3D world), we also search for viewpoint.
If it will succeed for some URL, returns @true,
setting output parameters. Returns @false if no loadable URL is found.
Output NewRootNode is the loaded world,
or @nil if actually we should stay within the same world.
@nil happens for URLs like @code(#ViewpointName),
or when URL refers to some non-3D document (that is opened with appropriate
application on user system).
NewViewpoint is the new viewpoint that should be bound,
or @nil if URL doesn't specify viewpoint name within 3D file.
This viewpoint is part of NewRootNode graph, if NewRootNode <> @nil,
or is part of CurrentRootNode if we should stay within
current world (NewRootNode = @nil).
Note that this means that NewRootNode = nil and
NewViewpoint = nil are valid output from this method,
and indicate that nothing should be done.
CurrentRootNode is required to detect invalid viewpoint names
within current file. An explanation why this is needed follows:
Invalid viewpoint names within newly loaded
files are harmless, that is newly loaded file is accepted anyway
and invalid viewpoint name is ignored. X3D spec says this explicitly.
But what should happen for invalid viewpoint names within current file?
X3D spec doesn't say anything clear here (the part before "#" is
valid in this case, since it just indicates current file, so someone
could argue that URL is valid, only viewpoint name is wrong and
so it should be ignored...). Consider url field like
@preformatted(
[ "#NotExistingViewpoint", "#ExistingViewpoint" ]
)
It seems sensible that we detect "#NotExistingViewpoint" as invalid,
and move on to the next URL (which may be local or not).
That's why we need CurrentRootNode instance.
When CurrentRootNode = nil, we understand that no file is currently
loaded (at least, you don't have it's X3D graph). It means that
any "#Viewpoint" within current model is considered invalid. }
function LoadAnchor(
out NewRootNode: TX3DRootNode;
out NewViewpoint: TAbstractViewpointNode;
CurrentRootNode: TX3DRootNode): boolean;
end;
{ Inline node.
The loaded inline contents are accessible in the @link(Inlined) object.
Currently this is also kept in the Children list
of this node. Originally, Children list is for VRML 1.0 children,
but for inline node this is just used for inlined content (regardless
of VRML/X3D version).
This means that most methods, like TX3DNode.EnumerateNodes,
descend into inlined content normally. }
TInlineNode = class(TAbstractGroupingNode, IAbstractBoundedObject, IAbstractUrlObject)
private
procedure EventLoadReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
procedure EventUrlReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
private
{ Is the inline currently loaded. This means "loaded",
not "successfully loaded": when Loaded := true,
we condider "url" field as handled, and loaded *if possible*.
If "url" didn't contain anything useful, Loaded is still set to @true,
to avoid constantly trying to reload. }
Loaded: boolean;
FInlined: TX3DRootNode;
protected
procedure BeforeTraverse(StateStack: TX3DGraphTraverseStateStack); override;
procedure AfterTraverse(StateStack: TX3DGraphTraverseStateStack); override;
{ You can override this to do anything after the Inline children were
loaded. It's called only after actual loading occurred, e.g. it's not
called when LoadInlined was called on the already-loaded node with
CanReload = @false. }
procedure AfterLoadInlined; virtual;
function DeepCopyCore(CopyState: TX3DNodeDeepCopyState): TX3DNode; override;
procedure ParseAfter(Reader: TX3DReaderNames); override;
public
procedure CreateNode; override;
class function ClassNodeTypeName: string; override;
class function URNMatching(const URN: string): boolean; override;
private FFdLoad: TSFBool;
public property FdLoad: TSFBool read FFdLoad;
private FFdUrl: TMFString;
public property FdUrl: TMFString read FFdUrl;
private FFdBboxCenter: TSFVec3f;
public property FdBboxCenter: TSFVec3f read FFdBboxCenter;
private FFdBboxSize: TSFVec3f;
public property FdBboxSize: TSFVec3f read FFdBboxSize;
class function VRML1ChildrenSaveToStream: boolean; override;
{ Load inlined content @bold(now).
If @link(Inlined) is already loaded:
if CanReload = @true then it will be freed and loaded again,
else (if CanReload = @false) nothing will happen.
Note that this has a really simple support for "load" field
(this concerns VRML 97 amendment 1 "InlineLoadControl.load" and
X3D (actually used also in VRML 97 handling) "Inline.load" fields).
It simply doesn't do any loading when "load" = @false.
Note that this doesn't perform setting the "load" field,
or sending any notifications to Scene
about "load" field. It's the caller's job to keep loaded state
synchronized with "load" field value.
LoadInlined(false) will be called automatically, to ensure the inlined
contents are always loaded. It will be called at the end of Parse
(this is needed to handle VRML/X3D IMPORT/EXPORT mechanism),
it will also be called in BeforeTraverse (in case you constructed node
by code, not by parsing; this also happens when node was made by expanding
a PROTO).
@param(Exported If non-nil, we will assign here node names
exported from the file. Used to handle IMPORT/EXPORT X3D mechanism.) }
procedure LoadInlined(CanReload: boolean;
const CurrentLengthConversionFactor: Float = 1.0;
Exported: TX3DNodeNames = nil);
procedure UnLoadInlined;
{ Call this to indicate that you loaded the inline contents directly,
by using AddChild yourself. }
procedure LoadedInlineDirectly;
{ The inlined content (loaded from inlined url).
@nil if not yet loaded, or no loading was successful.
This is also kept in VRML 1.0 children as Children[0],
but for future it's better to not depend on that. }
property Inlined: TX3DRootNode read FInlined;
end;
{ InlineLoadControl (VRML 97 node).
Note that our Inline node conforms to X3D, and so our Inline already
has a "load" field. So InlineLoadControl doesn't really have much use...
InlineLoadControl is implemented mostly for compatibility with VRML 97.
It has additional "children" output field. }
TInlineLoadControlNode = class(TInlineNode)
protected
procedure AfterLoadInlined; override;
public
procedure CreateNode; override;
class function ClassNodeTypeName: string; override;
class function URNMatching(const URN: string): boolean; override;
{ Event: MFNode, out } { }
private FEventChildren: TX3DEvent;
public property EventChildren: TX3DEvent read FEventChildren;
end;
TLoadSensorNode = class(TAbstractNetworkSensorNode)
public
procedure CreateNode; override;
class function ClassNodeTypeName: string; override;
class function URNMatching(const URN: string): boolean; override;
private FFdTimeOut: TSFTime;
public property FdTimeOut: TSFTime read FFdTimeOut;
private FFdWatchList: TMFNode;
public property FdWatchList: TMFNode read FFdWatchList;
{ Event: SFBool, out } { }
private FEventIsLoaded: TX3DEvent;
public property EventIsLoaded: TX3DEvent read FEventIsLoaded;
{ Event: SFTime, out } { }
private FEventLoadTime: TX3DEvent;
public property EventLoadTime: TX3DEvent read FEventLoadTime;
{ Event: SFFloat, out } { }
private FEventProgress: TX3DEvent;
public property EventProgress: TX3DEvent read FEventProgress;
end;
{$endif read_interface}
{$ifdef read_implementation}
procedure TAbstractNetworkSensorNode.CreateNode;
begin
inherited;
DefaultContainerField := 'children';
end;
procedure TAnchorNode.CreateNode;
begin
inherited;
FFdDescription := TSFString.Create(Self, 'description', '');
Fields.Add(FFdDescription);
FFdParameter := TMFString.Create(Self, 'parameter', []);
Fields.Add(FFdParameter);
FFdUrl := TMFString.Create(Self, 'url', []);
Fields.Add(FFdUrl);
{ X3D specification comment: [url or urn] }
DefaultContainerField := 'children';
end;
class function TAnchorNode.ClassNodeTypeName: string;
begin
Result := 'Anchor';
end;
class function TAnchorNode.URNMatching(const URN: string): boolean;
begin
Result := (inherited URNMatching(URN)) or
(URN = URNVRML97Nodes + ClassNodeTypeName) or
(URN = URNX3DNodes + ClassNodeTypeName);
end;
procedure TAnchorNode.DirectEnumerateActive(Func: TEnumerateChildrenFunction);
var
I: Integer;
begin
for I := 0 to FdChildren.Count - 1 do
Func(Self, FdChildren[I]);
end;
function TAnchorNode.LoadAnchor(
out NewRootNode: TX3DRootNode;
out NewViewpoint: TAbstractViewpointNode;
CurrentRootNode: TX3DRootNode): boolean;
procedure ViewpointNameInvalid(const NewViewpointName: string);
begin
OnWarning(wtMajor, 'VRML/X3D', Format('Viewpoint "%s" specified by Anchor not found',
[NewViewpointName]));
end;
var
I: Integer;
Url, UrlWithoutViewpoint, NewViewpointName: string;
begin
for I := 0 to FdUrl.Count - 1 do
begin
Url := FdUrl.Items[I];
{ We have to call URIExtractAnchor before PathFromBaseUrl.
Otherwise, in case of Urls like '' or '#viewpoint_in_this_world'
PathFromBaseUrl would prefix it with our path,
making it invalid. }
UrlWithoutViewpoint := Url;
URIExtractAnchor(UrlWithoutViewpoint, NewViewpointName);
if UrlWithoutViewpoint = '' then
begin
{ in this case, we have either a viewpoint in current 3D world, or nothing }
NewRootNode := nil;
if NewViewpointName = '' then
begin
NewViewpoint := nil;
Exit(true);
end else
begin
if CurrentRootNode <> nil then
begin
NewViewpoint := CurrentRootNode.TryFindNodeByName(TAbstractViewpointNode,
NewViewpointName, true) as TAbstractViewpointNode;
if NewViewpoint <> nil then
Exit(true) else
ViewpointNameInvalid(NewViewpointName);
end else
ViewpointNameInvalid(NewViewpointName);
{ In this case invalid viewpoint name is treated as a failure,
that is we try to find next URL.
This happens when CurrentRootNode = nil or when
CurrentRootNode doesn't contain NewViewpointName. }
end;
end else
begin
{ in this case, we have either a new 3D world, or a document }
UrlWithoutViewpoint := PathFromBaseUrl(UrlWithoutViewpoint);
try
NewRootNode := Load3D(UrlWithoutViewpoint, false, true);
if NewRootNode = nil then
begin
{ we have a document URL }
if OpenURL(PathFromBaseUrl(Url)) then
begin
NewViewpoint := nil;
Exit(true);
end else
begin
OnWarning(wtMinor, 'VRML/X3D', Format('Cannot open browser to handle document on this URL: %s',
[PathFromBaseUrl(Url)]));
Continue;
end;
end;
except
on E: Exception do
begin
{ Catch exception and produce OnWarning, go to next URL }
OnWarning(wtMajor, 'VRML/X3D', Format('Loading world from Anchor URL "%s" failed: %s',
[UrlWithoutViewpoint, E.Message]));
Continue;
end;
end;
if NewViewpointName = '' then
begin
NewViewpoint := nil;
end else
begin
NewViewpoint := NewRootNode.TryFindNodeByName(TAbstractViewpointNode,
NewViewpointName, true) as TAbstractViewpointNode;
if NewViewpoint = nil then
ViewpointNameInvalid(NewViewpointName);
{ In this case invalid viewpoint name is ignored,
that is we still accept this URL. This follows X3D spec
(also, this is sensible, otherwise we would have to free
loaded model just because viewpoint is invalid). }
end;
Exit(true);
end;
end;
Result := false;
end;
procedure TInlineNode.CreateNode;
begin
inherited;
FFdLoad := TSFBool.Create(Self, 'load', true);
FdLoad.OnReceive.Add(@EventLoadReceive);
Fields.Add(FFdLoad);
FFdUrl := TMFString.Create(Self, 'url', []);
FdUrl.OnReceive.Add(@EventUrlReceive);
Fields.Add(FFdUrl);
{ X3D specification comment: [url or urn] }
FFdBboxCenter := TSFVec3f.Create(Self, 'bboxCenter', Vector3Single(0, 0, 0));
FdBboxCenter.Exposed := false;
Fields.Add(FFdBboxCenter);
{ X3D specification comment: (-Inf,Inf) }
FFdBboxSize := TSFVec3f.Create(Self, 'bboxSize', Vector3Single(-1, -1, -1));
FdBboxSize.Exposed := false;
Fields.Add(FFdBboxSize);
{ X3D specification comment: [0,Inf) or -1 -1 -1 }
DefaultContainerField := 'children';
{ To allow inlined children (they are loaded as VRML 1.0 style children) }
VRML1ChildrenAllowed := true;
VRML1ChildrenParsingAllowed := false;
FInlined := nil;
end;
class function TInlineNode.ClassNodeTypeName: string;
begin
Result := 'Inline';
end;
class function TInlineNode.URNMatching(const URN: string): boolean;
begin
Result := (inherited URNMatching(URN)) or
(URN = URNVRML97Nodes + ClassNodeTypeName) or
(URN = URNX3DNodes + ClassNodeTypeName);
end;
procedure TInlineNode.ParseAfter(Reader: TX3DReaderNames);
var
Exported: TX3DNodeNames;
begin
inherited;
if NodeName <> '' then
Exported := TX3DNodeNames.Create(false) else
Exported := nil;
LoadInlined(false, Reader.LengthConversionFactor, Exported);
{ do not add Exported to Importable list, if nothing was exported.
This just saves the size of the Importable list. }
if (Exported <> nil) and (Exported.Count = 0) then
FreeAndNil(Exported);
if Exported <> nil then
begin
{ connect Exported nodes with our inline NodeName }
Assert(NodeName <> '');
Reader.Importable.Bind(NodeName, Exported);
end;
end;
procedure TInlineNode.UnLoadInlined;
begin
VRML1ChildrenClear;
FInlined := nil;
Loaded := false;
end;
procedure TInlineNode.LoadInlined(CanReload: boolean;
const CurrentLengthConversionFactor: Float;
Exported: TX3DNodeNames);
var
I: Integer;
FullUrl: string;
begin
if Exported <> nil then Exported.Clear;
if Loaded then
begin
if CanReload then UnLoadInlined else Exit;
end;
Assert(not Loaded);
Assert(FInlined = nil);
Assert(VRML1ChildrenCount = 0);
if (not FdLoad.Value) or
{ Do not do anything, in particular do not set Loaded:=true,
when url field is empty. This is important in case "url" field value
has an IS clause, and it will be really known only after expanding
the PROTO, see demo_models/prototypes/proto_inline.x3dv testcase. }
(FdUrl.Items.Count = 0) then
Exit;
for I := 0 to FdUrl.Items.Count - 1 do
{ For VRML 1.0 WWWInline, an item on "url" (alias "name") field
may be empty, and should be nicely ignored then.
For VRML >= 2.0 we also can ignore it (otherwise confusing warning
about unrecognized 3D model file extension for dir name is done). }
if FdUrl.Items[I] <> '' then
begin
FullUrl := PathFromBaseUrl(FdUrl.Items[I]);
try
FInlined := Load3D(FullUrl, false);
if (Exported <> nil) and
(TX3DRootNode(FInlined).ExportedNames <> nil) then
Exported.Assign(TX3DRootNode(FInlined).ExportedNames);
Break;
except
on E: Exception do
{ Careful here, as OnWarning may also raise exception. }
OnWarning(wtMinor, 'VRML/X3D', Format(SLoadError,
[E.ClassName, 'inline file', URIDisplay(FullUrl), E.Message]));
end;
end;
if FInlined <> nil then
begin
{ The Inlined contents are usually TX3DRootNode,
but they should not be saved as such. Although usually this doesn't
get saved (since we do not save inline contents), but it may happen
if you copy nodes around, e.g. "expanding" inlines (see view3dscene
planned feature, in view3dscene/TODO-expand-inlines.txt).
TODO: Such expanding must inherently break mismatching UNIT clauses
for LengthConversionFactor. To overcome this, our TX3DRootNode
should descend from TTransformNode and have it's scale actually saved. }
FInlined.SaveAsRootNode := false;
{ FInlined.Scale is adjusted now to make 1 unit = 1 meter inside.
However, we are already scaled by CurrentLengthConversionFactor.
(The check for CurrentLengthConversionFactor <> 1 is only to make sure
we keep Scale equal precisely 1.0 (no fp errors) when nothing uses
UNIT length.) }
if CurrentLengthConversionFactor <> 1 then
FInlined.Scale := FInlined.Scale / CurrentLengthConversionFactor;
VRML1ChildAdd(FInlined);
AfterLoadInlined;
end;
{ Whether or not we successfully got FInlined <> nil, we always set
Loaded to true here. This way we will not try to reload this inline
at next LoadInlined(false) (this would be bad, as we already did
OnWarning in case loading failed and such). }
Loaded := true;
end;
procedure TInlineNode.LoadedInlineDirectly;
begin
Loaded := true;
if VRML1ChildrenCount <> 0 then
FInlined := VRML1Children[0] as TX3DRootNode else
FInlined := nil;
end;
function TInlineNode.DeepCopyCore(CopyState: TX3DNodeDeepCopyState): TX3DNode;
var
ResultI: TInlineNode;
begin
Result := inherited DeepCopyCore(CopyState);
ResultI := Result as TInlineNode;
{ Since inherited copied our Children, we should also set "Loaded"
and "Inlined" field to the same value. }
ResultI.Loaded := Loaded;
if ResultI.VRML1ChildrenCount <> 0 then
ResultI.FInlined := ResultI.VRML1Children[0] as TX3DRootNode else
ResultI.FInlined := nil;
end;
procedure TInlineNode.AfterLoadInlined;
begin
{ Nothing to do in this class. }
end;
procedure TInlineNode.BeforeTraverse(StateStack: TX3DGraphTraverseStateStack);
begin
inherited;
try
LoadInlined(false);
except
{ LoadInlined may easily fail with exception, it's imprtant in such case
to still do AfterTraverse, to make "inherited AfterTraverse",
to finalize what "inherited BeginTraverse" did: usually StateStack.Pop. }
inherited AfterTraverse(StateStack);
raise;
end;
Inc(StateStack.Top.InsideInline);
end;
procedure TInlineNode.AfterTraverse(StateStack: TX3DGraphTraverseStateStack);
begin
Dec(StateStack.Top.InsideInline);
inherited;
end;
class function TInlineNode.VRML1ChildrenSaveToStream: boolean;
begin
Result := false;
end;
procedure TInlineNode.EventLoadReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
begin
{ Changing the "load" and "url" fields causes LoadInlined or UnLoadInlined,
so the VRML graph changes, so they deserve ChangedAll.
Note that, in theory, actually LoadInlined and UnLoadInlined
should already call Scene.ChangedAll already.
But this opens a can of worms, because our BeforeTraverse also
calls LoadInlined. And you can't really reliably call ChangedAll
in the middle of traversing (since this means you may call ChangedAll
in the middle of ChangedAll, for which we're not ready).
Moreover, we need to use BeforeNodesFree. Otherwise our UnLoadInlined
will free items to which existing TCastleSceneCore / TShape may keep
references. Testcase: inline_load_control_test_1.x3dv,
with --debug-log-vrml-changes,
press ctrl then shift, without BeforeNodesFree will fail ->
because OriginalGeometry.ClassName is no longer available. }
if Scene <> nil then Scene.BeforeNodesFree;
if FdLoad.Value then
LoadInlined(false) else
UnLoadInlined;
if Scene <> nil then Scene.ChangedAll;
end;
procedure TInlineNode.EventUrlReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
begin
if FdLoad.Value then
begin
if Scene <> nil then Scene.BeforeNodesFree;
UnLoadInlined;
LoadInlined(false);
if Scene <> nil then Scene.ChangedAll;
end;
end;
procedure TInlineLoadControlNode.CreateNode;
begin
inherited;
FEventChildren := TX3DEvent.Create(Self, 'children', TMFNode, false);
Events.Add(FEventChildren);
FInlined := nil;
end;
class function TInlineLoadControlNode.ClassNodeTypeName: string;
begin
Result := 'InlineLoadControl';
end;
class function TInlineLoadControlNode.URNMatching(const URN: string): boolean;
begin
Result := (inherited URNMatching(URN)) or
(URN = URNVRML97Nodes + ClassNodeTypeName);
end;
procedure TInlineLoadControlNode.AfterLoadInlined;
var
ChildrenToSend: TMFNode;
begin
{ TODO: InlineLoadControl should load it's contents to
children MFNode, and we should make a way (analogous
to TInlineLoadControlNode.VRML1ChildrenSaveToStream)
to say that "we don't want to save to stream "children" field".
For now it's not really important (user doesn't see
where it's loaded), but it will be later for scripts. }
if EventChildren.SendNeeded and (Scene <> nil) then
begin
ChildrenToSend := TMFNode.CreateUndefined(Self, EventChildren.Name, false);
try
ChildrenToSend.Add(FInlined);
EventChildren.Send(ChildrenToSend, Scene.GetTime);
finally FreeAndNil(ChildrenToSend) end;
end;
end;
procedure TLoadSensorNode.CreateNode;
begin
inherited;
FFdTimeOut := TSFTime.Create(Self, 'timeOut', 0);
Fields.Add(FFdTimeOut);
FFdWatchList := TMFNode.Create(Self, 'watchList', IAbstractUrlObject);
Fields.Add(FFdWatchList);
FEventIsLoaded := TX3DEvent.Create(Self, 'isLoaded', TSFBool, false);
Events.Add(FEventIsLoaded);
FEventLoadTime := TX3DEvent.Create(Self, 'loadTime', TSFTime, false);
Events.Add(FEventLoadTime);
FEventProgress := TX3DEvent.Create(Self, 'progress', TSFFloat, false);
Events.Add(FEventProgress);
DefaultContainerField := 'children';
end;
class function TLoadSensorNode.ClassNodeTypeName: string;
begin
Result := 'LoadSensor';
end;
class function TLoadSensorNode.URNMatching(const URN: string): boolean;
begin
Result := (inherited URNMatching(URN)) or
(URN = URNX3DNodes + ClassNodeTypeName);
end;
procedure RegisterNetworkingNodes;
begin
NodesManager.RegisterNodeClasses([
TAnchorNode,
TInlineNode,
TInlineLoadControlNode,
TLoadSensorNode
]);
end;
{$endif read_implementation}
|