Class TX3DGraphTraverseState

Unit

Declaration

type TX3DGraphTraverseState = class(TObject)

Description

Current state (transformation and such) when traversing VRML/X3D graph.

For VRML/X3D >= 2.0 this could be simpler, as VRML/X3D >= 2.0 doesn't need to keep track for example of the VRML1State. But we want to still handle VRML 1.0, 100% correctly, so here we are: this class contains whole state needed for any VRML/X3D version.

Hierarchy

  • TObject
  • TX3DGraphTraverseState

Overview

Fields

Public Lights: TLightInstancesList;
Public Transformation: TTransformation;
Public TextureTransform: TMatrix4;
Public ShapeNode: TAbstractShapeNode;
Public InsideInline: Cardinal;
Public InsidePrototype: Cardinal;
Public InsideIgnoreCollision: Cardinal;
Public InsideInvisible: Cardinal;
Public PointingDeviceSensors: TPointingDeviceSensorList;
Public HumanoidTransformation: TTransformation;
Public Humanoid: THAnimHumanoidNode;
Public ClipPlanes: TClipPlaneList;
Public LocalFog: TLocalFogNode;
Public Effects: TX3DNodeList;

Methods

Public procedure AddLight(const Light: TLightInstance);
Public procedure AssignTransform(Source: TX3DGraphTraverseState);
Public function Transform: TMatrix4; deprecated 'use Transformation.Transform';
Public function InvertedTransform: TMatrix4; deprecated 'use Transformation.InverseTransform';
Public constructor CreateCopy(Source: TX3DGraphTraverseState);
Public constructor Create;
Public destructor Destroy; override;
Public procedure Assign(Source: TX3DGraphTraverseState);
Public procedure Clear;
Public function Equals(SecondValue: TX3DGraphTraverseState; const IgnoreTransform: boolean): boolean; reintroduce;
Public function MainTexture: TAbstractTextureNode;
Public function MainTexture(const GeometryForTexCoord: TAbstractGeometryNode; out TexCoordIndex: Integer): TAbstractTextureNode;
Public function BlendMode: TBlendModeNode;
Public function AddClipPlane: PClipPlane;
Public function MaterialInfo: TMaterialInfo;

Properties

Public property VRML1State: TVRML1State read FVRML1State;
Public property LastNodes: TVRML1State read FVRML1State; deprecated 'use VRML1State';

Description

Fields

Public Lights: TLightInstancesList;

Lights active in this state.

May be Nil if empty. This way we optimize creation / assignment time, which happen very often with TX3DGraphTraverseState during VRML/X3D traversing.

Note that VRML >= 2.0 "global" lights are added from TCastleSceneCore, not during the traverse pass.

Public Transformation: TTransformation;

Transformation of this state. Calculated efficiently while traversing the X3D graph.

Public TextureTransform: TMatrix4;

Current texture transformation. Usable only for VRML 1.0, in VRML 2.0 texture transformations don't accumulate like modelview transformations.

Public ShapeNode: TAbstractShapeNode;
 
Public InsideInline: Cardinal;

Information if you're within any inline node or expanded prototype. InsideInline = 0 means you're not inside any inline node, 1 means you're inside one inline, 2 means you're within content inlined from yet another inline node, and so on. Analogous for InsidePrototype.

These are measured from the node where you started TX3DNode.Traverse call, that is they assume that the initial node from where you're traversing is at level 0 (not inside inline or expanded prototype).

These are useful to establish "run-time name scope" of X3D, see X3D spec 4.4.7 (needed e.g. when handling Anchor node with "#Viewpoint" URL). Interpreting this for our implementation, specification says that if you traverse from node X, then all traversed nodes with InsideInline = InsidePrototype = 0 are within the same name scope.

Also this is useful for searching for the first bindable node after loading the file. Specification says to ignore inline content in this case (although prototype content is Ok in this case).

When scriping will be implemented, probably analogous InsideScriptCreatedNode will also be needed, as the spec says that bindable nodes should not be searched within things like "Browser.createX3DFromString()".

Public InsidePrototype: Cardinal;
 
Public InsideIgnoreCollision: Cardinal;

This is > 0 when traversing nodes that do not participate in collision detection.

This counts how many times are we inside Collision node that prevents us from colliding. More precise, this is increased when we traverse inside Collision.children with Collision.enabled = FALSE or Collision.proxy <> NULL (since then Collision.children are not collidable).

Public InsideInvisible: Cardinal;

This is > 0 when traversing nodes that are not visible.

This counts how many times are we inside Collision.proxy (with Collision.enabled = TRUE). Collision.proxy is never visible.

Public PointingDeviceSensors: TPointingDeviceSensorList;

Active pointing device sensors in this state. This can contain only nodes descending from X3DPointingDeviceSensorNode, and additionally an Anchor node.

This list automatically honours VRML / X3D rules for what pointing device sensor is active: pointing device within some group node affects all children in this group node. (And when multiple pointing device sensors are within the same grouping node, they all work.)

Public HumanoidTransformation: TTransformation;

For Humanoid skeleton, these contain cummulated joint transformation.

Public Humanoid: THAnimHumanoidNode;

Humanoid node containing us, or Nil if none.

Public ClipPlanes: TClipPlaneList;

ClipPlanes affecting nodes within this state.

They are collected here regardless of whether they are enabled or not. This allows efficient implementation of ClipPlane.enabled dynamic changes.

Ordered from the most global to most local ones. So, following the X3D specification, we should consider the first clip planes on this list more important.

Always Nil if empty. This allows us to optimize TX3DGraphTraverseState processing.

Public LocalFog: TLocalFogNode;

Local fog settings. When Nil, it means use global fog (or no fog, if no global fog defined in file).

Public Effects: TX3DNodeList;

Effects (TEffectNode) affecting this state.

Methods

Public procedure AddLight(const Light: TLightInstance);
 
Public procedure AssignTransform(Source: TX3DGraphTraverseState);

Copy transformation-related fields from Source. Copies Transformation. Copies also the ClipPlanes list, as it contains the transformation information.

Public function Transform: TMatrix4; deprecated 'use Transformation.Transform';

Warning: this symbol is deprecated: use Transformation.Transform

 
Public function InvertedTransform: TMatrix4; deprecated 'use Transformation.InverseTransform';

Warning: this symbol is deprecated: use Transformation.InverseTransform

 
Public constructor CreateCopy(Source: TX3DGraphTraverseState);
 
Public constructor Create;

Standard constructor. Uses global VRML1DefaultState as default nodes for VRML1State. This makes it fast, and improves cache (more nodes have equal reference).

Public destructor Destroy; override;
 
Public procedure Assign(Source: TX3DGraphTraverseState);
 
Public procedure Clear;

Clear the whole state, just like this TX3DGraphTraverseState instance would be just constructed.

Public function Equals(SecondValue: TX3DGraphTraverseState; const IgnoreTransform: boolean): boolean; reintroduce;

Compare with other TX3DGraphTraverseState instance. True if these two states, when applied to the same geometry, result in the same TGeometryArrays output. If IgnoreTransform then we should ignore transformation during comparison (it means that renderer is absolutely sure that different transformation of geometry doesn't affect the generated arrays).

Public function MainTexture: TAbstractTextureNode;

Primary texture that determines RGB color and opacity. See TAppearanceNode.MainTexture for definition.

Public function MainTexture(const GeometryForTexCoord: TAbstractGeometryNode; out TexCoordIndex: Integer): TAbstractTextureNode;
 
Public function BlendMode: TBlendModeNode;

Returns BlendMode for this state, or Nil if not present.

Public function AddClipPlane: PClipPlane;
 
Public function MaterialInfo: TMaterialInfo;

Material information at this state. See TMaterialInfo for usage description. Returns Nil when no node determines material properties (which indicates white unlit look).

Returned TMaterialInfo is valid only as long as the underlying Material or CommonSurfaceShader node exists. Do not free it yourself, it will be automatically freed.

Properties

Public property VRML1State: TVRML1State read FVRML1State;

Nodes that affect how following nodes are rendered, mostly for VRML 1.0 state.

Public property LastNodes: TVRML1State read FVRML1State; deprecated 'use VRML1State';

Warning: this symbol is deprecated: use VRML1State

 

Generated by PasDoc 0.15.0.