Class TX3DPrototypeNode

Unit

Declaration

type TX3DPrototypeNode = class(TX3DNode)

Description

Node with information about X3D prototype.

This node will have fields initialized according to associated Prototype.InterfaceDeclarations. This way you can simply parse this node (just like any other node) to parse prototype instance.

The prototype may be instantiated. After parsing you can do it by Instantiate method. In case of non-external prototype, this should always be possible (for a valid X3D files, that is), in case of external prototype this may requite loading the external prototype file.

This node cannot be created by standard Create method, always use CreatePrototypeNode.

Hierarchy

Overview

Methods

Protected function DeepCopyCreate(CopyState: TX3DNodeDeepCopyState): TX3DNode; override;
Public constructor Create(const AName, ABaseUrl: string); override;
Public constructor CreatePrototypeNode(const AName, ABaseUrl: string; APrototype: TX3DPrototypeBase);
Public function X3DType: string; override;
Public function Instantiate: TX3DNode;

Properties

Public property Prototype: TX3DPrototypeBase read FPrototype;

Description

Methods

Protected function DeepCopyCreate(CopyState: TX3DNodeDeepCopyState): TX3DNode; override;

This item has no description. Showing description inherited from TX3DNode.DeepCopyCreate.

This should be a mere call to constructor of your own class.

In TX3DNode, this simply calls default virtual constructor, which is Ok for all normal nodes. But we have some special nodes, like TX3DPrototypeNode or TX3DUnknownNode, that simply cannot be created by default constructor. They need to override this.

Public constructor Create(const AName, ABaseUrl: string); override;

This constructor will raise exception for TX3DPrototypeNode. Always use CreatePrototypeNode for this node class.

Public constructor CreatePrototypeNode(const AName, ABaseUrl: string; APrototype: TX3DPrototypeBase);

This item has no description.

Public function X3DType: string; override;

This item has no description. Showing description inherited from TX3DNode.X3DType.

Type of the node in X3D, like 'Group' or 'Shape'. Never empty. Constant for the class lifetime (even for special TX3DUnknownNode and TX3DPrototypeNode, where this is calculated at runtime).

Note that VRML/X3D is generally case-sensitive, so this property is too.

In TX3DNode, this returns ClassX3DType, which is suitable for most nodes. See ClassX3DType.

Public function Instantiate: TX3DNode;

Instantiate the prototype, that is create new X3D node (of "normal" classs, not TX3DPrototypeNode) using prototype description.

For non-external prototype, in essense it just takes Prototype.Node and returns it's copy. For external prototype it first loads external file, and then uses non-external prototype there. Eventually, for external prototype we may also use build-in node (if URN will indicate so).

Actually, the process is a little more involved (see below for details), but the idea is that returned node can be simply inserted into VRML hierarchy and works just like a normal node. The important feature is that returned instance class is the same that was specified as a first prototype node. For example, if the prototype should expand to Material node, then this returns TMaterialNode. Just like Material node would be normally specified, not created by some prototype.

Note that this TX3DPrototypeNode becomes "owned" by returned node instance, in PrototypeInstanceSourceNode. (that's needed for returned node's SaveToStream to work correctly).

Details:

Exceptions raised
EX3DPrototypeInstantiateError
If for some reason the prototype cannot be instantiated. Outside code should catch this and replace with ApplicationProperties.OnWarning, if possible.

Properties

Public property Prototype: TX3DPrototypeBase read FPrototype;

This item has no description.


Generated by PasDoc 0.16.0.