Castle Game Engine: CastleGeometryArrays: Class TGeometryArrays

# Class TGeometryArrays
Description | Hierarchy | Fields | Methods | Properties
## Unit CastleGeometryArrays ## 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
| `constructor Create;`
| `destructor Destroy; override;`
| `function IndexesPtr(const Index: Cardinal): PLongInt;`
| `function Position: PVector3Single;`
| `function Position(const Index: Cardinal): PVector3Single;`
| `procedure IncPosition(var P: PVector3Single);`
| `function Normal: PVector3Single;`
| `function Normal(const Index: Cardinal): PVector3Single;`
| `procedure IncNormal(var P: PVector3Single);`
| `procedure AddColor;`
| `function Color(const Index: Cardinal = 0): PVector4Single;`
| `procedure IncColor(var P: PVector4Single);`
| `procedure AddFogCoord;`
| `function FogCoord(const Index: Cardinal = 0): PSingle;`
| `procedure AddTexCoord2D(const TextureUnit: Cardinal);`
| `procedure AddTexCoord3D(const TextureUnit: Cardinal);`
| `procedure AddTexCoord4D(const TextureUnit: Cardinal);`
| `procedure AddTexCoordGenerated(const Generation: TTextureCoordinateGeneration; const TextureUnit: Cardinal);`
| `procedure AddTexCoordCopy(const NewTextureUnit, ExistingTextureUnit: Cardinal);`
| `function TexCoord(const Dimensions: TTexCoordDimensions; const TextureUnit, Index: Cardinal): Pointer;`
| `function TexCoord2D(const TextureUnit, Index: Cardinal): PVector2Single;`
| `function TexCoord3D(const TextureUnit, Index: Cardinal): PVector3Single;`
| `function TexCoord4D(const TextureUnit, Index: Cardinal): PVector4Single;`
| `procedure AddGLSLAttributeFloat(const Name: string; const Internal: boolean);`
| `procedure AddGLSLAttributeVector2(const Name: string; const Internal: boolean);`
| `procedure AddGLSLAttributeVector3(const Name: string; const Internal: boolean);`
| `procedure AddGLSLAttributeVector4(const Name: string; const Internal: boolean);`
| `procedure AddGLSLAttributeMatrix3(const Name: string; const Internal: boolean);`
| `procedure AddGLSLAttributeMatrix4(const Name: string; const Internal: boolean);`
| `function GLSLAttribute(A: TGeometryAttrib; const Offset: PtrUInt = 0): Pointer;`
| `function GLSLAttributeFloat(const Name: string; const Index: Cardinal = 0): PSingle;`
| `function GLSLAttributeVector2(const Name: string; const Index: Cardinal = 0): PVector2Single;`
| `function GLSLAttributeVector3(const Name: string; const Index: Cardinal = 0): PVector3Single;`
| `function GLSLAttributeVector4(const Name: string; const Index: Cardinal = 0): PVector4Single;`
| `function GLSLAttributeMatrix3(const Name: string; const Index: Cardinal = 0): PMatrix3Single;`
| `function GLSLAttributeMatrix4(const Name: string; const Index: Cardinal = 0): PMatrix4Single;`
| `procedure FreeData;`
### Properties
| `property Indexes: TLongIntList read FIndexes write FIndexes;`
| `property IndexesCount: Cardinal read FIndexesCount;`
| `property HasIndexes: boolean read FHasIndexes;`
| `property Primitive: TGeometryPrimitive read FPrimitive write FPrimitive;`
| `property Counts: TCardinalList read FCounts write FCounts;`
| `property CoordinateArray: Pointer read FCoordinateArray;`
| `property CoordinateSize: Cardinal read FCoordinateSize;`
| `property AttributeArray: Pointer read FAttributeArray;`
| `property AttributeSize: Cardinal read FAttributeSize;`
| `property Count: Integer read FCount write SetCount;`
| `property HasColor: boolean read FHasColor;`
| `property HasDefaultColor: boolean read FHasDefaultColor write FHasDefaultColor default false;`
| `property DefaultColor: TVector4Single read FDefaultColor write FDefaultColor;`
| `property HasFogCoord: boolean read FHasFogCoord;`
| `property FogDirectValues: boolean read FFogDirectValues write FFogDirectValues default false;`
| `property TexCoords: TGeometryTexCoordList read FTexCoords;`
| `property Attribs: TGeometryAttribList read FAttribs;`
| `property CullBackFaces: boolean read FCullBackFaces write FCullBackFaces default false;`
| `property FrontFaceCcw: boolean read FFrontFaceCcw write FFrontFaceCcw default false;`
| `property ForceFlatShading: boolean read FForceFlatShading write FForceFlatShading default false;`
| `property DataFreed: boolean read FDataFreed;`
| `property Faces: TFaceIndexesList read FFaces write FFaces;`
## Description ### Methods
| `constructor Create;`
| `destructor Destroy; override;`
| `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.
| `function Position: PVector3Single;`
| `function Position(const Index: Cardinal): PVector3Single;`
| `procedure IncPosition(var P: PVector3Single);`
| `function Normal: PVector3Single;`
| `function Normal(const Index: Cardinal): PVector3Single;`
| `procedure IncNormal(var P: PVector3Single);`
| `procedure AddColor;`
| `function Color(const Index: Cardinal = 0): PVector4Single;`
| `procedure IncColor(var P: PVector4Single);`
| `procedure AddFogCoord;`
| `function FogCoord(const Index: Cardinal = 0): PSingle;`
| `procedure AddTexCoord2D(const TextureUnit: Cardinal);`
| `procedure AddTexCoord3D(const TextureUnit: Cardinal);`
| `procedure AddTexCoord4D(const TextureUnit: Cardinal);`
| `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.
| `procedure AddTexCoordCopy(const NewTextureUnit, ExistingTextureUnit: Cardinal);`
Add texture coord, with configuration copied from existing texture coord.
| `function TexCoord(const Dimensions: TTexCoordDimensions; const TextureUnit, Index: Cardinal): Pointer;`
| `function TexCoord2D(const TextureUnit, Index: Cardinal): PVector2Single;`
| `function TexCoord3D(const TextureUnit, Index: Cardinal): PVector3Single;`
| `function TexCoord4D(const TextureUnit, Index: Cardinal): PVector4Single;`
| `procedure AddGLSLAttributeFloat(const Name: string; const Internal: boolean);`
| `procedure AddGLSLAttributeVector2(const Name: string; const Internal: boolean);`
| `procedure AddGLSLAttributeVector3(const Name: string; const Internal: boolean);`
| `procedure AddGLSLAttributeVector4(const Name: string; const Internal: boolean);`
| `procedure AddGLSLAttributeMatrix3(const Name: string; const Internal: boolean);`
| `procedure AddGLSLAttributeMatrix4(const Name: string; const Internal: boolean);`
| `function GLSLAttribute(A: TGeometryAttrib; const Offset: PtrUInt = 0): Pointer;`
| `function GLSLAttributeFloat(const Name: string; const Index: Cardinal = 0): PSingle;`
| `function GLSLAttributeVector2(const Name: string; const Index: Cardinal = 0): PVector2Single;`
| `function GLSLAttributeVector3(const Name: string; const Index: Cardinal = 0): PVector3Single;`
| `function GLSLAttributeVector4(const Name: string; const Index: Cardinal = 0): PVector4Single;`
| `function GLSLAttributeMatrix3(const Name: string; const Index: Cardinal = 0): PMatrix3Single;`
| `function GLSLAttributeMatrix4(const Name: string; const Index: Cardinal = 0): PMatrix4Single;`
| `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
| `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).
| `property IndexesCount: Cardinal read FIndexesCount;`
| `property HasIndexes: boolean read FHasIndexes;`
| `property Primitive: TGeometryPrimitive read FPrimitive write FPrimitive;`
| `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).
| `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).
| `property CoordinateSize: Cardinal read FCoordinateSize;`
| `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.
| `property AttributeSize: Cardinal read FAttributeSize;`
| `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.
| `property HasColor: boolean read FHasColor;`
| `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.
| `property DefaultColor: TVector4Single read FDefaultColor write FDefaultColor;`
| `property HasFogCoord: boolean read FHasFogCoord;`
| `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.
| `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).
| `property Attribs: TGeometryAttribList read FAttribs;`
| `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 GLRenderer for explanation (hint: plane mirrors).
| `property FrontFaceCcw: boolean read FFrontFaceCcw write FFrontFaceCcw default false;`
| `property ForceFlatShading: boolean read FForceFlatShading write FForceFlatShading default false;`
Make the whole rendering with flat shading.
| `property DataFreed: boolean read FDataFreed;`
Was FreeData called.
| `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 2013-08-17 21:27:12