Class TGeometryArrays

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TGeometryArrays = class(TObject)

Description

Geometry represented as arrays of indexes, vertex positions, texture coordinates and such. Many (eventually, all) geometry nodes (TVRMLGeometryNode) can be processed into an instance of this class.

This can be used to render, as arrays here map very naturally to an efficient OpenGL vertex arrays and VBOs. We use interleaving, storing everything in two arrays: 1st one for positions and normals (stuff that changes during coordinate morphing, most common dynamic shapes, so we specifically think about optimizing it). 2nd one for everything else (colors, tex coords, also GLSL attributes). This should allow for the most efficient usage, making use of interleaving and still allowing fast dynamic updates in common cases.

Hierarchy

  • TObject
  • TGeometryArrays

Overview

Methods

Public constructor Create;
Public destructor Destroy; override;
Public function IndexesPtr(const Index: Cardinal): PLongInt;
Public function Position: PVector3Single;
Public function Position(const Index: Cardinal): PVector3Single;
Public procedure IncPosition(var P: PVector3Single);
Public function Normal: PVector3Single;
Public function Normal(const Index: Cardinal): PVector3Single;
Public procedure IncNormal(var P: PVector3Single);
Public procedure AddColor;
Public function Color(const Index: Cardinal = 0): PVector4Single;
Public procedure IncColor(var P: PVector4Single);
Public procedure AddFogCoord;
Public function FogCoord(const Index: Cardinal = 0): PSingle;
Public procedure AddTexCoord2D(const TextureUnit: Cardinal);
Public procedure AddTexCoord3D(const TextureUnit: Cardinal);
Public procedure AddTexCoord4D(const TextureUnit: Cardinal);
Public procedure AddTexCoordGenerated(const Generation: TTextureCoordinateGeneration; const TextureUnit: Cardinal);
Public procedure AddTexCoordCopy(const NewTextureUnit, ExistingTextureUnit: Cardinal);
Public function TexCoord(const TextureUnit, Index: Cardinal): Pointer;
Public function TexCoord2D(const TextureUnit, Index: Cardinal): PVector2Single;
Public function TexCoord3D(const TextureUnit, Index: Cardinal): PVector3Single;
Public function TexCoord4D(const TextureUnit, Index: Cardinal): PVector4Single;
Public procedure AddGLSLAttributeFloat(const Name: string; const Internal: boolean);
Public procedure AddGLSLAttributeVector2(const Name: string; const Internal: boolean);
Public procedure AddGLSLAttributeVector3(const Name: string; const Internal: boolean);
Public procedure AddGLSLAttributeVector4(const Name: string; const Internal: boolean);
Public procedure AddGLSLAttributeMatrix3(const Name: string; const Internal: boolean);
Public procedure AddGLSLAttributeMatrix4(const Name: string; const Internal: boolean);
Public function GLSLAttribute(A: TGeometryAttrib; const Offset: PtrUInt = 0): Pointer;
Public function GLSLAttributeFloat(const Name: string; const Index: Cardinal = 0): PSingle;
Public function GLSLAttributeVector2(const Name: string; const Index: Cardinal = 0): PVector2Single;
Public function GLSLAttributeVector3(const Name: string; const Index: Cardinal = 0): PVector3Single;
Public function GLSLAttributeVector4(const Name: string; const Index: Cardinal = 0): PVector4Single;
Public function GLSLAttributeMatrix3(const Name: string; const Index: Cardinal = 0): PMatrix3Single;
Public function GLSLAttributeMatrix4(const Name: string; const Index: Cardinal = 0): PMatrix4Single;
Public procedure FreeData;

Properties

Public property Indexes: TLongIntList read FIndexes write FIndexes;
Public property IndexesCount: Cardinal read FIndexesCount;
Public property HasIndexes: boolean read FHasIndexes;
Public property Primitive: TGeometryPrimitive read FPrimitive write FPrimitive;
Public property Counts: TCardinalList read FCounts write FCounts;
Public property CoordinateArray: Pointer read FCoordinateArray;
Public property CoordinateSize: Cardinal read FCoordinateSize;
Public property AttributeArray: Pointer read FAttributeArray;
Public property AttributeSize: Cardinal read FAttributeSize;
Public property Count: Integer read FCount write SetCount;
Public property HasColor: boolean read FHasColor;
Public property HasDefaultColor: boolean read FHasDefaultColor write FHasDefaultColor default false;
Public property DefaultColor: TVector4Single read FDefaultColor write FDefaultColor;
Public property HasFogCoord: boolean read FHasFogCoord;
Public property FogDirectValues: boolean read FFogDirectValues write FFogDirectValues default false;
Public property TexCoords: TGeometryTexCoordList read FTexCoords;
Public property Attribs: TGeometryAttribList read FAttribs;
Public property CullBackFaces: boolean read FCullBackFaces write FCullBackFaces default false;
Public property FrontFaceCcw: boolean read FFrontFaceCcw write FFrontFaceCcw default false;
Public property ForceFlatShading: boolean read FForceFlatShading write FForceFlatShading default false;
Public property DataFreed: boolean read FDataFreed;
Public property Faces: TFaceIndexesList read FFaces write FFaces;

Description

Methods

Public constructor Create;
 
Public destructor Destroy; override;
 
Public function IndexesPtr(const Index: Cardinal): PLongInt;

Information about Indexes.

You coulc as well use the Indexes property to get the same information. You can use Indexes[Index], Indexes <> nil, Indexes.Count and such. However, FreeData call (that you may use to conserve memory usage after loading arrays to VBO) releases Indexes property, while these properties stay the same.

Public function Position: PVector3Single;
 
Public function Position(const Index: Cardinal): PVector3Single;
 
Public procedure IncPosition(var P: PVector3Single);
 
Public function Normal: PVector3Single;
 
Public function Normal(const Index: Cardinal): PVector3Single;
 
Public procedure IncNormal(var P: PVector3Single);
 
Public procedure AddColor;
 
Public function Color(const Index: Cardinal = 0): PVector4Single;
 
Public procedure IncColor(var P: PVector4Single);
 
Public procedure AddFogCoord;
 
Public function FogCoord(const Index: Cardinal = 0): PSingle;
 
Public procedure AddTexCoord2D(const TextureUnit: Cardinal);
 
Public procedure AddTexCoord3D(const TextureUnit: Cardinal);
 
Public procedure AddTexCoord4D(const TextureUnit: Cardinal);
 
Public procedure AddTexCoordGenerated(const Generation: TTextureCoordinateGeneration; const TextureUnit: Cardinal);

Add generated texture coord. Such texture coord will not have actual data allocated in the array (you're expected to instead setup and enable glTexGen when rendering). Generation passed here must not be tgExplicit.

Public procedure AddTexCoordCopy(const NewTextureUnit, ExistingTextureUnit: Cardinal);

Add texture coord, with configuration copied from existing texture coord.

Public function TexCoord(const TextureUnit, Index: Cardinal): Pointer;
 
Public function TexCoord2D(const TextureUnit, Index: Cardinal): PVector2Single;
 
Public function TexCoord3D(const TextureUnit, Index: Cardinal): PVector3Single;
 
Public function TexCoord4D(const TextureUnit, Index: Cardinal): PVector4Single;
 
Public procedure AddGLSLAttributeFloat(const Name: string; const Internal: boolean);
 
Public procedure AddGLSLAttributeVector2(const Name: string; const Internal: boolean);
 
Public procedure AddGLSLAttributeVector3(const Name: string; const Internal: boolean);
 
Public procedure AddGLSLAttributeVector4(const Name: string; const Internal: boolean);
 
Public procedure AddGLSLAttributeMatrix3(const Name: string; const Internal: boolean);
 
Public procedure AddGLSLAttributeMatrix4(const Name: string; const Internal: boolean);
 
Public function GLSLAttribute(A: TGeometryAttrib; const Offset: PtrUInt = 0): Pointer;
 
Public function GLSLAttributeFloat(const Name: string; const Index: Cardinal = 0): PSingle;
 
Public function GLSLAttributeVector2(const Name: string; const Index: Cardinal = 0): PVector2Single;
 
Public function GLSLAttributeVector3(const Name: string; const Index: Cardinal = 0): PVector3Single;
 
Public function GLSLAttributeVector4(const Name: string; const Index: Cardinal = 0): PVector4Single;
 
Public function GLSLAttributeMatrix3(const Name: string; const Index: Cardinal = 0): PMatrix3Single;
 
Public function GLSLAttributeMatrix4(const Name: string; const Index: Cardinal = 0): PMatrix4Single;
 
Public procedure FreeData;

Release the allocated memory for arrays (CoordinateArray, AttributeArray, Indexes). Further calls to IndexesPtr, Normal, Color and such will return only an offset relative to the original arrays pointer. This is very useful if you loaded arrays data into GPU memory (like Vertex Buffer Object of OpenGL), and you will not need the data anymore.

Properties

Public property Indexes: TLongIntList read FIndexes write FIndexes;

Indexes to remaining arrays.

If non-nil, we will render using these indexes, which means that items on the remaining lists (vertex positions, tex coords etc.) may be used multiple times. This is good (the lists may be possibly shorter, and GPU will be able to reuse more calculation results), but it's also limited: a vertex must always have the same properties in this case (e.g. the same normal vector, so shape must be completely smooth).

When this is nil, we will simply use all the vertexes in order. So every item of the remaining lists will be processed exactly once, in the given order. This seems dumb, but actually we're often forced to use this: when you use flat (per-face) normals or colors, then the same vertex position must be used many times with different normal/color. If you want to use OpenGL vertex arrays for whole rendering, this vertex position will just have to be duplicated (which is OK, as the calculation results couldn't be shared anyway, since normal/color are different).

Public property IndexesCount: Cardinal read FIndexesCount;
 
Public property HasIndexes: boolean read FHasIndexes;
 
Public property Primitive: TGeometryPrimitive read FPrimitive write FPrimitive;
 
Public property Counts: TCardinalList read FCounts write FCounts;

If this is assigned, then the vertexes are divided into groups. This is the only way to put many triangle strips, triangle fans and such into one TGeometryArrays instance. For normal sets of triangles and quads this has no use, as there's never a need to divide them for rendering.

Each value of this list specifies to take consecutive number of vertexes for next primitive. If Indexes are assigned, then they are divided into groups. Otherwise, the other arrays (positions, normals etc.) are divided into groups.

The sum of values must be equal to the Indexes.Count (if Indexes assigned) or arrays Count (if Indexes not assigned).

Public property CoordinateArray: Pointer read FCoordinateArray;

Memory containing vertex positions and normals, that is everything that changes during Coordinate.coord animation. CoordinateSize is size, in bytes, of one item of this array (currently just constant, 2 * TVector3Single).

Public property CoordinateSize: Cardinal read FCoordinateSize;
 
Public property AttributeArray: Pointer read FAttributeArray;

Memory containing everything other vertex attribute, like color, texture coordinates and GLSL attributes. AttributeSize is size, in bytes, of one item of this array.

Public property AttributeSize: Cardinal read FAttributeSize;
 
Public property Count: Integer read FCount write SetCount;

Allocated number of items in vertex positions, normals, colors and such arrays.

You can only set this once. You must do all necessary AddColor / AddAttribute calls before setting this.

You can access all Position / Normal etc. pointers only after setting this. Also, IndexesCount and HasIndexes is stored at this point.

Public property HasColor: boolean read FHasColor;
 
Public property HasDefaultColor: boolean read FHasDefaultColor write FHasDefaultColor default false;

When Color array is not initialized and HasDefaultColor, then the default color will be set to DefaultColor.

Public property DefaultColor: TVector4Single read FDefaultColor write FDefaultColor;
 
Public property HasFogCoord: boolean read FHasFogCoord;
 
Public property FogDirectValues: boolean read FFogDirectValues write FFogDirectValues default false;

If FogCoord present, does it specify direct fog intensities, that should be used to change pixel colors without any further processing. When this is False, then fog coordinates are understood as distance from the eye, and they are processed by linear/exp equations before being used to blend pixel colors.

Public property TexCoords: TGeometryTexCoordList read FTexCoords;

Allocated in AttributeArray texture coords. Index is texture unit (counted from renderer first available texture unit). If given item is Nil on this list, then this texture unit is not allocated (just like it would be outside of TexCoords.Count).

Public property Attribs: TGeometryAttribList read FAttribs;
 
Public property CullBackFaces: boolean read FCullBackFaces write FCullBackFaces default false;

CullBackFaces says if we should enable back-face culling. If True, then we should glEnable(GL_CULL_FACE), and set glCullFace such that front face will be visible. FrontFaceCcw says what is "front face".

FrontFaceCcw is ignored by renderer if CullBackFaces = False.

Note that we *do not* implement FrontFaceCcw by glFrontFace, we do a little more complicated trick, see comments at the beginning of CastleRenderer for explanation (hint: plane mirrors).

Public property FrontFaceCcw: boolean read FFrontFaceCcw write FFrontFaceCcw default false;
 
Public property ForceFlatShading: boolean read FForceFlatShading write FForceFlatShading default false;

Make the whole rendering with flat shading.

Public property DataFreed: boolean read FDataFreed;

Was FreeData called.

Public property Faces: TFaceIndexesList read FFaces write FFaces;

Information about faces. Generated for some geometry types. Generated only when TArraysGenerator.FacesNeeded is True. Generated only for indexed shapes. When Indexes <> nil, these have the same count as Indexes.Count. Otherwise these have the same count as our Count.


Generated by PasDoc 0.13.0 on 2014-10-26 05:15:12