Class TMFLong

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TMFLong = class(TX3DSimpleMultField)

Description

no description available, TX3DSimpleMultField description follows

Field holding multiple values. Remember that such field may always have any number of items, including zero.

Note that we keep MF fields contents in TFPSList or TCastleStringList instances (RawItems in this class, also accessible as Items (with more concrete class) in descendants). This means that they are in compact form, easy for reading, or even for feeding the list into OpenGL. That's the main reason why I did not simply implement TX3DSimpleMultField as a descendant of TX3DSingleFieldsList: A long list of vertexes, MFVec3f, would be kept as a list of pointers to a lot of TSFVec3f instances. This would be quite memory-consuming, and very uncomfortable for access. On the contrary, current implementation keeps all these vertexes inside one TVector3SingleList instance, that internally keeps all items in one continuos piece of memory.

Descendants implementors notes: to make new descendant:

  • In CreateUndefined you have to initialize FItemClass and create RawItems. In destructor of this class, RawItems are freed, so don't worry about this.

  • Override RawItemsAdd.

  • If your ItemClass doesn't work 100% correctly when it's initialized by CreateUndefined, you may have to override CreateItemBeforeParse. Fortunately, VRML specification was careful to choose as multi-valued field types' only fields that can behave nicely when initialized by CreateUndefined (and in fact VRML 2.0 removed the "bad fields" entirely).

  • Not strictly required, but usually it's comfortable to have a constructor that allows you to init default field value from some "array of TXxx".

Hierarchy

Overview

Methods

Protected function RawItemToString(ItemNum: integer; const Encoding: TX3DEncoding): string; override;
Protected function SaveToStreamDoNewLineAfterRawItem(ItemNum: integer): boolean; override;
Public procedure RawItemsAdd(Item: TX3DSingleField); override;
Public constructor Create(AParentNode: TX3DFileItem; const AName: string; const InitialContent: array of Longint);
Public constructor CreateUndefined(AParentNode: TX3DFileItem; const AName: string; const AExposed: boolean); override;
Public function EqualsDefaultValue: boolean; override;
Public function Equals(SecondValue: TX3DField; const EqualityEpsilon: Double): boolean; override;
Public procedure Assign(Source: TPersistent); override;
Public procedure AssignValue(Source: TX3DField); override;
Public procedure AssignDefaultValueFromValue; override;
Public class function TypeName: string; override;
Public class function CreateEvent(const AParentNode: TX3DFileItem; const AName: string; const AInEvent: boolean): TX3DEvent; override;
Public procedure OnWarning_WrongVertexIndex( const GeometryNodeTypeName: string; const VertexNum: Integer; const CoordCount: Integer);
Public procedure Send(const AValue: array of LongInt); virtual; overload;

Properties

Public property SaveToStreamLineUptoNegative: boolean read FSaveToStreamLineUptoNegative write FSaveToStreamLineUptoNegative default false;
Public property Items: TLongintList read GetItems write SetItems;
Public property ItemsSafe[Index:Integer]: LongInt read GetItemsSafe write SetItemsSafe;

Description

Methods

Protected function RawItemToString(ItemNum: integer; const Encoding: TX3DEncoding): string; override;
 
Protected function SaveToStreamDoNewLineAfterRawItem(ItemNum: integer): boolean; override;
 
Public procedure RawItemsAdd(Item: TX3DSingleField); override;
 
Public constructor Create(AParentNode: TX3DFileItem; const AName: string; const InitialContent: array of Longint);
 
Public constructor CreateUndefined(AParentNode: TX3DFileItem; const AName: string; const AExposed: boolean); override;
 
Public function EqualsDefaultValue: boolean; override;
 
Public function Equals(SecondValue: TX3DField; const EqualityEpsilon: Double): boolean; override;
 
Public procedure Assign(Source: TPersistent); override;
 
Public procedure AssignValue(Source: TX3DField); override;
 
Public procedure AssignDefaultValueFromValue; override;
 
Public class function TypeName: string; override;
 
Public class function CreateEvent(const AParentNode: TX3DFileItem; const AName: string; const AInEvent: boolean): TX3DEvent; override;
 
Public procedure OnWarning_WrongVertexIndex( const GeometryNodeTypeName: string; const VertexNum: Integer; const CoordCount: Integer);

Call OnWarning reporting that an invalid vertex index is caused from this field. This simply calls OnWarning formatting appropriate message.

Additionally this guards us against producing too many warnings from the same field. When a given threshold will be reached, further OnWarning_WrongVertexIndex calls for this field instance will be simply ignored. This is a good thing, as some invalid models have really an incredible amount of invalid indexes, and the very amount of lines printed on console makes viewing these invalid files (at least, the valid parts of them) impossible.

Example test cases: content/examples/Basic/HumanoidAnimation/AllenStandShootRifleM24.x3d and content/examples/Basic/HumanoidAnimation/NancyDiving.x3dv from http://www.web3d.org/ example models.

Public procedure Send(const AValue: array of LongInt); virtual; overload;
 

Properties

Public property SaveToStreamLineUptoNegative: boolean read FSaveToStreamLineUptoNegative write FSaveToStreamLineUptoNegative default false;

When saving to VRML/X3D classic encoding, make newline after each negative value on the list. This makes a nice output for fields like IndexedFaceSet.coordIndex.

Public property Items: TLongintList read GetItems write SetItems;
 
Public property ItemsSafe[Index:Integer]: LongInt read GetItemsSafe write SetItemsSafe;

Access Items[] checking for range errors. In case of errors, Get will return zero, Set will do nothing, and both will produce clear OnWarning.