Class TSFFloat

Unit

Declaration

type TSFFloat = class(TX3DSingleField)

Description

X3D field containing a floating-point value with Single precision.

Source: scene/x3d/castlefields_x3dsinglefield_descendants.inc (line 167).

Hierarchy

Show Additional Members:

Overview

Fields

Public OnInputIgnore: TInputIgnoreEvent;
Public DefaultValue: Single;
Public DefaultValueExists: boolean;

Methods

Public constructor Create;
Public procedure SaveToStream(Writer: TX3DWriter); virtual; abstract;
Public function SaveToXml: TSaveToXmlMethod; virtual;
Public constructor Create(const AParentNode: TX3DFileItem; const AX3DName: string);
Public destructor Destroy; override;
Public function IsClauseNamesCount: Integer;
Public procedure IsClauseNamesAssign(const SourceIsClauseNames: TCastleStringList);
Public procedure IsClauseNamesAdd(const S: string);
Public procedure ParseIsClause(Lexer: TX3DLexer);
Public procedure AddAlternativeName(const AlternativeName: string; const X3DMajorVersion: Integer); virtual;
Public procedure RemoveAlternativeName(const X3DMajorVersion: Integer);
Public function IsName(const S: string): boolean;
Public function NameForVersion(Version: TX3DVersion): string; overload;
Public function NameForVersion(Writer: TX3DWriter): string; overload;
Public function NiceName: string;
Public procedure SaveToStreamClassicIsClauses(Writer: TX3DWriter);
Public constructor CreateUndefined(const AParentNode: TX3DFileItem; const AExposed: boolean; const AName: String); virtual;
Public destructor Destroy; override;
Public procedure Parse(Lexer: TX3DLexer; Reader: TX3DReader; IsClauseAllowed: boolean);
Public procedure ParseValue(Lexer: TX3DLexer; Reader: TX3DReader); virtual; abstract;
Public procedure ParseXMLAttributeLexer(Lexer: TX3DLexer; Reader: TX3DReader); virtual;
Public procedure ParseXMLAttribute(const AttributeValue: String; Reader: TX3DReader); virtual;
Public procedure ParseXMLElement(Element: TDOMElement; Reader: TX3DReader); virtual;
Public procedure FieldSaveToStream(Writer: TX3DWriter; FieldSaveWhenDefault: boolean = false; XmlAvoidSavingNameBeforeValue: boolean = false);
Public procedure SaveToStream(Writer: TX3DWriter); override;
Public function SaveToXml: TSaveToXmlMethod; override;
Public function EqualsDefaultValue: boolean; virtual;
Public function Equals(SecondValue: TX3DField): boolean; reintroduce; virtual;
Public function FastEqualsValue(SecondValue: TX3DField): boolean; virtual;
Public function EventIn: TX3DEvent;
Public function EventOut: TX3DEvent;
Public class function X3DType: String; virtual;
Public class function TypeName: String; deprecated 'use X3DType';
Public class function CreateEvent(const AParentNode: TX3DFileItem; const AName: String; const AInEvent: boolean): TX3DEvent; virtual;
Public procedure AssignValue(Source: TX3DField); virtual;
Public procedure AssignDefaultValueFromValue; virtual;
Public procedure UnassignDefaultValue; virtual;
Public procedure AssignLerp(const A: Double; Value1, Value2: TX3DField); virtual;
Public function CanAssignLerp: boolean; virtual;
Public procedure AddAlternativeName(const AlternativeName: String; const X3DMajorVersion: Integer); override;
Public procedure Changed;
Public function ExecuteChange: TX3DChange; virtual;
Public procedure Send(Value: TX3DField); overload;
Public procedure AddNotification(const Notification: TX3DEventReceive);
Public procedure RemoveNotification(const Notification: TX3DEventReceive);
Public constructor Create(const AParentNode: TX3DFileItem; const AExposed: boolean; const AName: String; const AValue: Single);
Public procedure ParseValue(Lexer: TX3DLexer; Reader: TX3DReader); override;
Public function EqualsDefaultValue: boolean; override;
Public function Equals(SecondValue: TX3DField): boolean; override;
Public function FastEqualsValue(SecondValue: TX3DField): boolean; override;
Public procedure AssignLerp(const A: Double; Value1, Value2: TX3DField); override;
Public function CanAssignLerp: boolean; override;
Public procedure Assign(Source: TPersistent); override;
Public procedure AssignValue(Source: TX3DField); override;
Public procedure AssignDefaultValueFromValue; override;
Public procedure UnassignDefaultValue; override;
Public class function X3DType: String; override;
Public class function CreateEvent(const AParentNode: TX3DFileItem; const AName: String; const AInEvent: boolean): TX3DEvent; override;
Public procedure Send(const AValue: Single); overload;

Properties

Public property PositionInParent: Integer read FPositionInParent write FPositionInParent default -1;
Public property X3DName: string read FX3DName;
Public property Name: string read FX3DName; deprecated 'use X3DName';
Public property ParentNode: TX3DFileItem read FParentNode write FParentNode;
Public property IsClauseNames[const Index: Integer]: string read GetIsClauseNames;
Public property ParentInterfaceDeclaration: TX3DFileItem read FParentInterfaceDeclaration write FParentInterfaceDeclaration;
Public property ValueFromIsClause: boolean read FValueFromIsClause write FValueFromIsClause;
Public property Exposed: boolean read FExposed write SetExposed default false;
Public property ExposedEvents [InEvent: boolean]: TX3DEvent read GetExposedEvents;
Public property ExposedEventsLinked: boolean read FExposedEventsLinked write SetExposedEventsLinked default true;
Public property ChangeAlways: TX3DChange read FChangeAlways write FChangeAlways default chNone;
Public property Value: Single read FValue write SetValue;
Public property MustBeNonnegative: Boolean read FMustBeNonnegative write SetMustBeNonnegative default false;
Public property Angle: boolean read FAngle write FAngle default false;

Description

Fields

Public OnInputIgnore: TInputIgnoreEvent;

This item has no description.

Source: scene/x3d/castlefields_x3dfield.inc (line 226).

Public DefaultValue: Single;

This item has no description.

Source: scene/x3d/castlefields_x3dsinglefield_descendants.inc (line 177).

Public DefaultValueExists: boolean;

This item has no description.

Source: scene/x3d/castlefields_x3dsinglefield_descendants.inc (line 178).

Methods

Public constructor Create;

This item has no description.

Source: scene/x3d/castlefields_x3dfileitem.inc (line 42).

Public procedure SaveToStream(Writer: TX3DWriter); virtual; abstract;

Save to stream.

Source: scene/x3d/castlefields_x3dfileitem.inc (line 75).

Public function SaveToXml: TSaveToXmlMethod; virtual;

How is this saved to X3D XML encoding. This determines when SaveToStream is called. It also cooperates with some SaveToStream implementations, guiding how the item is actually saved. By default it is sxChildElement.

Source: scene/x3d/castlefields_x3dfileitem.inc (line 81).

Public constructor Create(const AParentNode: TX3DFileItem; const AX3DName: string);

This item has no description.

Source: scene/x3d/castlefields_x3dfieldorevent.inc (line 47).

Public destructor Destroy; override;

This item has no description.

Source: scene/x3d/castlefields_x3dfieldorevent.inc (line 48).

Public function IsClauseNamesCount: Integer;

This item has no description.

Source: scene/x3d/castlefields_x3dfieldorevent.inc (line 102).

Public procedure IsClauseNamesAssign(const SourceIsClauseNames: TCastleStringList);

This item has no description.

Source: scene/x3d/castlefields_x3dfieldorevent.inc (line 103).

Public procedure IsClauseNamesAdd(const S: string);

This item has no description.

Source: scene/x3d/castlefields_x3dfieldorevent.inc (line 104).

Public procedure ParseIsClause(Lexer: TX3DLexer);

Parse only "IS" clause, if it's not present — don't do nothing. For example, for the TX3DField descendant, this does not try to parse field value.

Source: scene/x3d/castlefields_x3dfieldorevent.inc (line 110).

Public procedure AddAlternativeName(const AlternativeName: string; const X3DMajorVersion: Integer); virtual;

Add alternative name for the same field/event, to be used in different VRML version.

When VRML major version is exactly equal X3DMajorVersion, the AlternativeName should be used — for both reading and writing of this field/event. In some cases, when reading, we may also allow all versions (both original and alternative), but this is mostly for implementation simplicity — don't count on it.

A special value 0 for X3DMajorVersion means that this is just an alternative name, that should be allowed when reading (as alternative to normal Name), and never used when writing.

Alternative names is a very handy mechanism for cases when the only thing that changed between VRML versions is the field name. Example: Switch node's children/choice, LOD node's children/level, Polyline2D lineSegments/point.

Note that this also works for ExposedEvents with exposed TX3DField: if a field has alternative names, then it's exposed events always also have appropriate alternative names.

Source: scene/x3d/castlefields_x3dfieldorevent.inc (line 133).

Public procedure RemoveAlternativeName(const X3DMajorVersion: Integer);

This item has no description.

Source: scene/x3d/castlefields_x3dfieldorevent.inc (line 135).

Public function IsName(const S: string): boolean;

Returns if S matches current Name or one of the alternative names. Think about it like simple test "Name = S", but actually this checks also names added by AddAlternativeName method.

Source: scene/x3d/castlefields_x3dfieldorevent.inc (line 140).

Public function NameForVersion(Version: TX3DVersion): string; overload;

Return how this field should be named for given VRML version. In almost all cases, this simply returns current Name. But it can also return a name added by AddAlternativeName method.

Source: scene/x3d/castlefields_x3dfieldorevent.inc (line 145).

Public function NameForVersion(Writer: TX3DWriter): string; overload;

This item has no description.

Source: scene/x3d/castlefields_x3dfieldorevent.inc (line 146).

Public function NiceName: string;

Nice and concise field description for user. Describes parent node type, name and field/event's name.

Source: scene/x3d/castlefields_x3dfieldorevent.inc (line 159).

Public procedure SaveToStreamClassicIsClauses(Writer: TX3DWriter);

Save IS clauses to stream, only for classic encoding. For each IS clause, writeln field/event name followed by "IS" clause.

Source: scene/x3d/castlefields_x3dfieldorevent.inc (line 163).

Public constructor CreateUndefined(const AParentNode: TX3DFileItem; const AExposed: boolean; const AName: String); virtual;

Main constructor that initializes field when default value is not known.

It is virtual, so you can use it to construct field instance when field class is known only at runtime. For example you can have variable like "FieldClass: TX3DFieldClass" and use it to construct the field instance. Such field can be later initialized e.g. using Parse.

Note: Two exceptional VRML 1.0 fields simply cannot work when initialized by this constructor: TSFEnum and TSFBitMask . They simply need to know their TSFEnum.EnumNames, or TSFBitMask.FlagNames + TSFBitMask.NoneString + TSFBitMask.AllString before they can be parsed. Luckily these fields have been removed in VRML 2.0 and X3D so we don't need to support them e.g. in VRML 2.0 and X3D prototypes.

Descendants implementors:

1. Descendants should override this virtual constructor, CreateUndefined, to do all obligatory initialization work (e.g. create some internal TStringList).

Call "inherited" at the beginning of the implementation of this overridden "CreateUndefined".

2. Can Create also a convenience non-virtual constructor Create, that takes as parameter initial value (with type specific to given field, e.g. Integer for TSFInt32).

This convenience constructor should call "CreateUndefined" (not "inherited Create" or "inherited CreateUndefined"!) at the beginning.

TODO: Rename this to just Create, to obscure parent Create. After everything migrated to calling CreateUndefined.

Source: scene/x3d/castlefields_x3dfield.inc (line 264).

Public destructor Destroy; override;

This item has no description.

Source: scene/x3d/castlefields_x3dfield.inc (line 267).

Public procedure Parse(Lexer: TX3DLexer; Reader: TX3DReader; IsClauseAllowed: boolean);

Parse inits properties from Lexer.

In this class, Parse only appends to IsClauseNames: if we stand on "IS" clause (see VRML 2.0 spec about "IS" clause) and IsClauseAllowed then we append specified identifier to IsClauseNames.

If "IS" clause not found, we call ParseValue which should actually parse field's value. Descendants should override ParseValue.

Source: scene/x3d/castlefields_x3dfield.inc (line 279).

Public procedure ParseValue(Lexer: TX3DLexer; Reader: TX3DReader); virtual; abstract;

This item has no description.

Source: scene/x3d/castlefields_x3dfield.inc (line 281).

Public procedure ParseXMLAttributeLexer(Lexer: TX3DLexer; Reader: TX3DReader); virtual;

Parse field value from X3D XML encoded attribute using a Lexer. Attributes in X3D are generally encoded such that normal ParseValue(Lexer, nil) call is appropriate, so this is done in this class.

Source: scene/x3d/castlefields_x3dfield.inc (line 287).

Public procedure ParseXMLAttribute(const AttributeValue: String; Reader: TX3DReader); virtual;

Parse field value from X3D XML encoded attribute.

Implementation in this class creates a Lexer to parse the string, and calls ParseXMLAttributeLexer.

Source: scene/x3d/castlefields_x3dfield.inc (line 293).

Public procedure ParseXMLElement(Element: TDOMElement; Reader: TX3DReader); virtual;

Parse field's value from XML Element children. This is used to read SFNode / MFNode field value inside <field> (for interface declaration default field value) and <fieldValue> inside <ProtoInstance>.

Source: scene/x3d/castlefields_x3dfield.inc (line 299).

Public procedure FieldSaveToStream(Writer: TX3DWriter; FieldSaveWhenDefault: boolean = false; XmlAvoidSavingNameBeforeValue: boolean = false);

Save the field to the stream. Field name (if set, omitted if empty) and value are saved. Unless the current field value equals default value and FieldSaveWhenDefault is False (default), then nothing is saved.

IS clauses are not saved here (because they often have to be treated specially anyway, for XML encoding, for prototype declarations etc.).

Source: scene/x3d/castlefields_x3dfield.inc (line 308).

Public procedure SaveToStream(Writer: TX3DWriter); override;

Save the field to the stream.

This simply calls FieldSaveToStream(Writer). See FieldSaveToStream for more comments and when you need control over FieldSaveWhenDefault behavior.

It doesn't actually save anything if field value is defined and equals default value.

Source: scene/x3d/castlefields_x3dfield.inc (line 320).

Public function SaveToXml: TSaveToXmlMethod; override;

This item has no description. Showing description inherited from TX3DFileItem.SaveToXml.

How is this saved to X3D XML encoding. This determines when SaveToStream is called. It also cooperates with some SaveToStream implementations, guiding how the item is actually saved. By default it is sxChildElement.

Source: scene/x3d/castlefields_x3dfield.inc (line 321).

Public function EqualsDefaultValue: boolean; virtual;

Whether the value is equal to default. Returns always False in TX3DField, descendants should override it. It is used when writing the field value to X3D file (values that are default do not have to be written, ever).

Source: scene/x3d/castlefields_x3dfield.inc (line 333).

Public function Equals(SecondValue: TX3DField): boolean; reintroduce; virtual;

True if the SecondValue object has exactly the same type and properties. For this class, this returns just (SecondValue.Name = Name).

All descendants (that add some property that should be compared) should override this like

Result := (inherited Equals(SecondValue)) and
  (SecondValue is TMyType) and
  (TMyType(SecondValue).MyProperty = MyProperty);

The floating-point fields may be compared with a small epsilon tolerance by this method.

Note that this *doesn't* compare the default values of two fields instances. This compares only the current values of two fields instances, and eventually some other properties that affect parsing (like names for TSFEnum and TSFBitMask) or allowed future values (like TSFFloat.MustBeNonnegative).

Source: scene/x3d/castlefields_x3dfield.inc (line 356).

Public function FastEqualsValue(SecondValue: TX3DField): boolean; virtual;

Compare value of this field, with other field, fast.

This compares only the values of the fields, not other properties (it doesn't care about names of the fields or such, or default values; only current values). In other words, it compares only the things copied by AssignValue.

This tries to compare very fast, which means that for large (multi-valued) fields it may give up and answer False even when they are in fact equal. So this is usable only for optimization purposes: when it answers True, it is True. When it answers False, it actually doesn't know.

Default implementation in this class (TX3DField) just returns False.

Source: scene/x3d/castlefields_x3dfield.inc (line 372).

Public function EventIn: TX3DEvent;

Exposed events of this field. Nil if this field is not exposed. EventIn is always equivalent to ExposedEvents[true], EventOut is always equivalent to ExposedEvents[false].

Source: scene/x3d/castlefields_x3dfield.inc (line 387).

Public function EventOut: TX3DEvent;

This item has no description.

Source: scene/x3d/castlefields_x3dfield.inc (line 388).

Public class function X3DType: String; virtual;

Field type in X3D, like 'SFString' or 'MFInt32'. As for VRML/X3D interface declaration statements. In base TX3DField class, this returns XFAny (name indicating any type, used by instantreality and us).

Source: scene/x3d/castlefields_x3dfield.inc (line 409).

Public class function TypeName: String; deprecated 'use X3DType';

Warning: this symbol is deprecated: use X3DType

This item has no description.

Source: scene/x3d/castlefields_x3dfield.inc (line 410).

Public class function CreateEvent(const AParentNode: TX3DFileItem; const AName: String; const AInEvent: boolean): TX3DEvent; virtual;

Create TX3DEvent descendant suitable as exposed event for this field.

Source: scene/x3d/castlefields_x3dfield.inc (line 413).

Public procedure AssignValue(Source: TX3DField); virtual;

Copies the current field value. Contrary to TPersistent.Assign, this doesn't copy the rest of properties.

After setting, our ValueFromIsClause is always changed to False. You can manually change it to True, if this copy indeed was done following "IS" clause.

Descendants implementors notes:

In this class, implementation takes care of setting our ValueFromIsClause to False. In descendants, you should do like

if Source is <appropriate class> then
begin
  inherited;
  Value := Source.value;
end else
  AssignValueRaiseInvalidClass(Source);

Exceptions raised
EX3DFieldAssignInvalidClass
Usually it's required the Source class to be equal to our class, if Source classes cannot be assigned we raise EX3DFieldCannotAssignClass.
EX3DFieldAssign
Raised in case of any field assignment problem. It's guaranteed that in case of such problem, our value will not be modified before raising the exception.

EX3DFieldAssignInvalidClass inherits from EX3DFieldAssign, so actually EX3DFieldAssignInvalidClass is just a special case of this exceptiion.

Source: scene/x3d/castlefields_x3dfield.inc (line 450).

Public procedure AssignDefaultValueFromValue; virtual;

Set field's default value from the current value.

Note that for now this doesn't guarantee that every possible field's value can be stored as default value. In case of trouble, it will silently record "no default is known" information, so e.g. EqualsDefaultValue will always return False. Our default value mechanisms are sometimes limited, not every value can be a default value. For example, for multiple-valued nodes, we usually cannot save arrays longer than one as default value. This is not a problem, since X3D specification doesn't specify too long default values. But it may be a problem for prototypes, since then user can assign any value as default value. May be corrected in the future.

Source: scene/x3d/castlefields_x3dfield.inc (line 465).

Public procedure UnassignDefaultValue; virtual;

Remove default value, recording that "no default is known". In effect EqualsDefaultValue will always return False.

Source: scene/x3d/castlefields_x3dfield.inc (line 469).

Public procedure AssignLerp(const A: Double; Value1, Value2: TX3DField); virtual;

Assigns value to this node calculated from linear interpolation between two given nodes Value1, Value2. Just like other lerp functions in our units (like CastleVectors.Lerp).

Like AssignValue, this copies only the current value. All other properties (like Name, IsClauseNames, ValueFromIsClause, default value) are untouched.

There are some special precautions for this:

  • First of all, AssignLerp is defined only for fields where CanAssignLerp returns True, so always check CanAssignLerp first. All float-based fields should have this implemented.

  • Use this only if Value1 and Value2 are equal or descendant of target (Self) class.

  • For multiple-value fields, counts of Value1 and Value2 must be equal, or EListsDifferentCount will be raised.

Exceptions raised
EListsDifferentCount
When field is multiple-value field and Value1.Count <> Value2.Count.

Source: scene/x3d/castlefields_x3dfield.inc (line 496).

Public function CanAssignLerp: boolean; virtual;

Is AssignLerp usable on this field type?

Descendants implementors notes: In this class, this always returns False.

Source: scene/x3d/castlefields_x3dfield.inc (line 502).

Public procedure AddAlternativeName(const AlternativeName: String; const X3DMajorVersion: Integer); override;

This item has no description. Showing description inherited from TX3DFieldOrEvent.AddAlternativeName.

Add alternative name for the same field/event, to be used in different VRML version.

When VRML major version is exactly equal X3DMajorVersion, the AlternativeName should be used — for both reading and writing of this field/event. In some cases, when reading, we may also allow all versions (both original and alternative), but this is mostly for implementation simplicity — don't count on it.

A special value 0 for X3DMajorVersion means that this is just an alternative name, that should be allowed when reading (as alternative to normal Name), and never used when writing.

Alternative names is a very handy mechanism for cases when the only thing that changed between VRML versions is the field name. Example: Switch node's children/choice, LOD node's children/level, Polyline2D lineSegments/point.

Note that this also works for ExposedEvents with exposed TX3DField: if a field has alternative names, then it's exposed events always also have appropriate alternative names.

Source: scene/x3d/castlefields_x3dfield.inc (line 504).

Public procedure Changed;

Notify ParentNode.Scene that the value of this field changed.

Source: scene/x3d/castlefields_x3dfield.inc (line 508).

Public function ExecuteChange: TX3DChange; virtual;

What happens when the value of this field changes. This is called, exactly once, by TCastleSceneCore.InternalChangedField to determine what must be done when we know that value of this field changed.

In overridden descendants, this can also do something immediately. Overriding this is similar to registering your callback by EventOut.AddNotification, with two additional benefits:

  1. This method may be not called (although no guarantees) when the actual field value did not change. In contrast, the event notification is always fired, even when you send the same value to an exposed field, because VRML/X3D events and routes must be fired anyway.

  2. This is useful also for fields that are not exposed, and can be changed only by ObjectPascal code.

So overridding this is closer to "do something when field value changes" than registering notification by EventOut.AddNotification.

Source: scene/x3d/castlefields_x3dfield.inc (line 541).

Public procedure Send(Value: TX3DField); overload;

Set the value of the field, notifying the scenes and events engine. This sets the value of this field in the nicest possible way for any possible TCastleSceneCore (with events on or off) containing the node with this field.

Precise specification:

  • If this is an exposed field and we have events engine working:

    We will send this value through it's input event. In this case, this is equivalent to doing EventIn.Send(Value, Scene.Time). The scenes (including events engine) will be notified correctly by exposed events handler already.

  • Otherwise, we will just set the fields value. And then notify the scenes (including events engine).

Source: scene/x3d/castlefields_x3dfield.inc (line 562).

Public procedure AddNotification(const Notification: TX3DEventReceive);

Notifications when exposed field received new value through VRML/X3D event. Use only for exposed fields. This is simply a shortcut for EventOut.AddNotification, EventOut.RemoveNotification, see TX3DEvent.AddNotification for details how does this work.

Note that this observes the "out" event (not the "in" event). This way you know inside the handler that the field value is already changed as appropriate. Inside "in" event handlers, you would not know this (it would depend on the order in which handlers are run, one "in" handler sets the field value).

Note that "out" event handlers are executed before Scene is notified about the field value change (before TCastleSceneCore.InternalChangedField is called). This is also usually exactly what you want — you can change the scene graph inside the event handler (for example, load something on Inline.load or Inline.url changes), and let the TX3DField.ChangeAlways cause appropriate action on this change.

Source: scene/x3d/castlefields_x3dfield.inc (line 582).

Public procedure RemoveNotification(const Notification: TX3DEventReceive);

This item has no description.

Source: scene/x3d/castlefields_x3dfield.inc (line 583).

Public constructor Create(const AParentNode: TX3DFileItem; const AExposed: boolean; const AName: String; const AValue: Single);

This item has no description.

Source: scene/x3d/castlefields_x3dsinglefield_descendants.inc (line 180).

Public procedure ParseValue(Lexer: TX3DLexer; Reader: TX3DReader); override;

This item has no description.

Source: scene/x3d/castlefields_x3dsinglefield_descendants.inc (line 199).

Public function EqualsDefaultValue: boolean; override;

This item has no description. Showing description inherited from TX3DField.EqualsDefaultValue.

Whether the value is equal to default. Returns always False in TX3DField, descendants should override it. It is used when writing the field value to X3D file (values that are default do not have to be written, ever).

Source: scene/x3d/castlefields_x3dsinglefield_descendants.inc (line 201).

Public function Equals(SecondValue: TX3DField): boolean; override;

This item has no description. Showing description inherited from TX3DField.Equals.

True if the SecondValue object has exactly the same type and properties. For this class, this returns just (SecondValue.Name = Name).

All descendants (that add some property that should be compared) should override this like

Result := (inherited Equals(SecondValue)) and
  (SecondValue is TMyType) and
  (TMyType(SecondValue).MyProperty = MyProperty);

The floating-point fields may be compared with a small epsilon tolerance by this method.

Note that this *doesn't* compare the default values of two fields instances. This compares only the current values of two fields instances, and eventually some other properties that affect parsing (like names for TSFEnum and TSFBitMask) or allowed future values (like TSFFloat.MustBeNonnegative).

Source: scene/x3d/castlefields_x3dsinglefield_descendants.inc (line 202).

Public function FastEqualsValue(SecondValue: TX3DField): boolean; override;

This item has no description. Showing description inherited from TX3DField.FastEqualsValue.

Compare value of this field, with other field, fast.

This compares only the values of the fields, not other properties (it doesn't care about names of the fields or such, or default values; only current values). In other words, it compares only the things copied by AssignValue.

This tries to compare very fast, which means that for large (multi-valued) fields it may give up and answer False even when they are in fact equal. So this is usable only for optimization purposes: when it answers True, it is True. When it answers False, it actually doesn't know.

Default implementation in this class (TX3DField) just returns False.

Source: scene/x3d/castlefields_x3dsinglefield_descendants.inc (line 203).

Public procedure AssignLerp(const A: Double; Value1, Value2: TX3DField); override;

This item has no description. Showing description inherited from TX3DField.AssignLerp.

Assigns value to this node calculated from linear interpolation between two given nodes Value1, Value2. Just like other lerp functions in our units (like CastleVectors.Lerp).

Like AssignValue, this copies only the current value. All other properties (like Name, IsClauseNames, ValueFromIsClause, default value) are untouched.

There are some special precautions for this:

  • First of all, AssignLerp is defined only for fields where CanAssignLerp returns True, so always check CanAssignLerp first. All float-based fields should have this implemented.

  • Use this only if Value1 and Value2 are equal or descendant of target (Self) class.

  • For multiple-value fields, counts of Value1 and Value2 must be equal, or EListsDifferentCount will be raised.

Source: scene/x3d/castlefields_x3dsinglefield_descendants.inc (line 205).

Public function CanAssignLerp: boolean; override;

This item has no description. Showing description inherited from TX3DField.CanAssignLerp.

Is AssignLerp usable on this field type?

Descendants implementors notes: In this class, this always returns False.

Source: scene/x3d/castlefields_x3dsinglefield_descendants.inc (line 206).

Public procedure Assign(Source: TPersistent); override;

This item has no description.

Source: scene/x3d/castlefields_x3dsinglefield_descendants.inc (line 207).

Public procedure AssignValue(Source: TX3DField); override;

This item has no description. Showing description inherited from TX3DField.AssignValue.

Copies the current field value. Contrary to TPersistent.Assign, this doesn't copy the rest of properties.

After setting, our ValueFromIsClause is always changed to False. You can manually change it to True, if this copy indeed was done following "IS" clause.

Descendants implementors notes:

In this class, implementation takes care of setting our ValueFromIsClause to False. In descendants, you should do like

if Source is <appropriate class> then
begin
  inherited;
  Value := Source.value;
end else
  AssignValueRaiseInvalidClass(Source);

Source: scene/x3d/castlefields_x3dsinglefield_descendants.inc (line 208).

Public procedure AssignDefaultValueFromValue; override;

This item has no description. Showing description inherited from TX3DField.AssignDefaultValueFromValue.

Set field's default value from the current value.

Note that for now this doesn't guarantee that every possible field's value can be stored as default value. In case of trouble, it will silently record "no default is known" information, so e.g. EqualsDefaultValue will always return False. Our default value mechanisms are sometimes limited, not every value can be a default value. For example, for multiple-valued nodes, we usually cannot save arrays longer than one as default value. This is not a problem, since X3D specification doesn't specify too long default values. But it may be a problem for prototypes, since then user can assign any value as default value. May be corrected in the future.

Source: scene/x3d/castlefields_x3dsinglefield_descendants.inc (line 209).

Public procedure UnassignDefaultValue; override;

This item has no description. Showing description inherited from TX3DField.UnassignDefaultValue.

Remove default value, recording that "no default is known". In effect EqualsDefaultValue will always return False.

Source: scene/x3d/castlefields_x3dsinglefield_descendants.inc (line 210).

Public class function X3DType: String; override;

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

Field type in X3D, like 'SFString' or 'MFInt32'. As for VRML/X3D interface declaration statements. In base TX3DField class, this returns XFAny (name indicating any type, used by instantreality and us).

Source: scene/x3d/castlefields_x3dsinglefield_descendants.inc (line 212).

Public class function CreateEvent(const AParentNode: TX3DFileItem; const AName: String; const AInEvent: boolean): TX3DEvent; override;

This item has no description. Showing description inherited from TX3DField.CreateEvent.

Create TX3DEvent descendant suitable as exposed event for this field.

Source: scene/x3d/castlefields_x3dsinglefield_descendants.inc (line 213).

Public procedure Send(const AValue: Single); overload;

This item has no description.

Source: scene/x3d/castlefields_x3dsinglefield_descendants.inc (line 215).

Properties

Public property PositionInParent: Integer read FPositionInParent write FPositionInParent default -1;

Position of this item within parent VRML/X3D node, used for saving the VRML/X3D graph to file. Default value -1 means "undefined".

For normal usage and processing of VRML graph, this is totally not needed. This position doesn't dictate actual meaning of VRML graph. If you're looking to change order of nodes, you probably want to rather look at something like ReplaceItems within TMFNode or such.

This field is purely a hint when encoding VRML file how to order VRML items (nodes, fields, routes, protos) within parent node or the VRML file. Reason: VRML allows non-unique node names. Each DEF XXX overrides all previous ("previous" in lexical sense, i.e. normal order of tokens in the file) DEF XXX with the same XXX, thus hiding previous node name "XXX". This means that when saving VRML file we have to be very careful about the order of items, such that e.g. all routes are specified when appropriate node names are bound.

This is a relative position, relative to other PositionInParent value of other TX3DFileItem items. So it's not necessary to keep all PositionInParent different or successive within some parent. When saving, we will sort everything according to PositionInParent.

See e.g. ../../../demo_models/x3d/tricky_def_use.x3dv for tests of some tricky layout. When reading such file we have to record PositionInParent to be able to save such file correctly.

Source: scene/x3d/castlefields_x3dfileitem.inc (line 71).

Public property X3DName: string read FX3DName;

Name of the field or event.

Most fields/events are inside some X3D node, and then they have a non-empty name. But in some special cases we also use temporary fields with an empty name.

Note that you cannot change this after object creation, since Name is used for various purposes (like to generate names for TX3DField.ExposedEvents).

Note that this property is deliberately not called Name. In the future, this class may descend from the standard TComponent class, that defines a Name field with a special restrictions (it must be a valid Pascal identifier), which cannot apply to X3D node names (that can have quite free names, see http://www.web3d.org/documents/specifications/19776-2/V3.3/Part02/grammar.html ). We don't want to confuse these two properties.

Source: scene/x3d/castlefields_x3dfieldorevent.inc (line 67).

Public property Name: string read FX3DName; deprecated 'use X3DName';

Warning: this symbol is deprecated: use X3DName

This item has no description.

Source: scene/x3d/castlefields_x3dfieldorevent.inc (line 68).

Public property ParentNode: TX3DFileItem read FParentNode write FParentNode;

X3D node containing this field/event. This must always contain an instance of TX3DNode class (although it cannot be declared such, since X3DFields unit cannot depend on X3DNodes interface).

It may be Nil for special fields/events when parent node is unknown.

Source: scene/x3d/castlefields_x3dfieldorevent.inc (line 76).

Public property IsClauseNames[const Index: Integer]: string read GetIsClauseNames;

"IS" clauses of this field/event, used when this field/event is inside prototype definition.

This is an array, as one item may have many "IS" clauses (for a field, only one "IS" clause should refer to another field; but you can have many "IS" clauses connecting events, also exposedField may have "IS" clause that should be interpreted actually as links to it's exposed events). See e.g. demo_models/x3d/proto_events_test_3.x3dv.

Note that having "IS" clauses doesn't mean that the field should be considered "without any value". This is not a good way of thinking, as an exposed field may have an "IS" clause, but linking it to an event, and thus such field has it's value (default value, if not specified in the file), event though it also has an "IS" clause. Although there is TX3DField.ValueFromIsClause, which indicates whether current value was obtained from "IS" clause.

To be able to significantly optimize memory, we do not expose IsClauseNames as TCastleStringList. Instead operate on them only using below functions. Note that IsClauseNamesAssign can also accept Nil as parameter.

Source: scene/x3d/castlefields_x3dfieldorevent.inc (line 101).

Public property ParentInterfaceDeclaration: TX3DFileItem read FParentInterfaceDeclaration write FParentInterfaceDeclaration;

For fields contained in TX3DInterfaceDeclaration.

This should always be Nil (if the field is normal, standard field, not coming from interface declaration in X3D file) or an instance of TX3DInterfaceDeclaration. (But it cannot be declared such, since TX3DInterfaceDeclaration is not known in this unit).

Source: scene/x3d/castlefields_x3dfieldorevent.inc (line 154).

Public property ValueFromIsClause: boolean read FValueFromIsClause write FValueFromIsClause;

Does current field value came from expanding "IS" clause. If yes, then saving this field to stream will only save it's "IS" clauses, never saving actual value.

Source: scene/x3d/castlefields_x3dfield.inc (line 326).

Public property Exposed: boolean read FExposed write SetExposed default false;

Does this field generate/accept events, that is an "exposedField" (in VRML 2.0) or "inputOutput" (in X3D).

Source: scene/x3d/castlefields_x3dfield.inc (line 376).

Public property ExposedEvents [InEvent: boolean]: TX3DEvent read GetExposedEvents;

These are the set_xxx and xxx_changed events exposed by this field. Nil if Exposed is False.

Source: scene/x3d/castlefields_x3dfield.inc (line 380).

Public property ExposedEventsLinked: boolean read FExposedEventsLinked write SetExposedEventsLinked default true;

When True (default) we will automatically handle exposed events behavior. This means that we will listen on EventIn, and when something will be received we will set current field's value and produce appropriate EventOut.

You almost certainly want to leave this as True in all typical situations, as it takes care of implementing required exposed events behavior.

That said, in special cases you may decide to break this.

Source: scene/x3d/castlefields_x3dfield.inc (line 401).

Public property ChangeAlways: TX3DChange read FChangeAlways write FChangeAlways default chNone;

What always happens when the value of this field changes.

This is included in the ExecuteChange method result. So instead of using this property, you could always override ExecuteChange method. But often it's easier to use the property.

By default this is chNone. See TX3DChange for possible values.

Source: scene/x3d/castlefields_x3dfield.inc (line 518).

Public property Value: Single read FValue write SetValue;

Current field value.

Source: scene/x3d/castlefields_x3dsinglefield_descendants.inc (line 184).

Public property MustBeNonnegative: Boolean read FMustBeNonnegative write SetMustBeNonnegative default false;

Set this to True to request that only values >= 0 are valid. Trying to set Value to something < 0 will make a warning and fix it (for now – by negating it, but don't depend on this "fix" algorithm). Also when changing this to True while current Value is invalid, it will also be fixed and make a warning.

Source: scene/x3d/castlefields_x3dsinglefield_descendants.inc (line 191).

Public property Angle: boolean read FAngle write FAngle default false;

Value represents an angle. When reading from X3D 3.3 file, we will make sure it's expressed in radians, honoring optional "UNIT angle ..." declaration in X3D file.

Source: scene/x3d/castlefields_x3dsinglefield_descendants.inc (line 197).


Generated by PasDoc 0.17.0.snapshot.