Castle Game Engine: CastleArraysGenerator: Class TArraysGenerator

# Class TArraysGenerator
Description | Hierarchy | Fields | Methods | Properties
## Unit CastleArraysGenerator ## Declaration `type TArraysGenerator = class(TObject)` ## Description Generate TGeometryArrays for a VRML/X3D shape. This is the basis of our renderer: generate a TGeometryArrays for a shape, then TGLRenderer will pass TGeometryArrays to OpenGL. Geometry must be based on coordinates when using this, that is TAbstractGeometryNode.Coord must return `True`. ## Hierarchy TObject TArraysGenerator ## Overview ### Fields
| `IndexesFromCoordIndex: TLongIntList;`
| `ArrayIndexNum: Integer;`
| `Arrays: TGeometryArrays;`
| `TexCoordsNeeded: Cardinal;`
| `MaterialOpacity: Single;`
| `FogVolumetric: boolean;`
| `FogVolumetricDirection: TVector3Single;`
| `FogVolumetricVisibilityStart: Single;`
| `ShapeBumpMappingUsed: boolean;`
| `OnRadianceTransfer: TRadianceTransferFunction;`
| `OnVertexColor: TVertexColorFunction;`
| `FacesNeeded: boolean;`
### Methods
| `procedure WarningShadingProblems( const ColorPerVertex, NormalPerVertex: boolean);`
| `procedure GenerateVertex(IndexNum: Integer); virtual;`
| `function GetVertex(IndexNum: integer): TVector3Single;`
| `function CoordCount: Integer;`
| `procedure GenerateCoordinate; virtual; abstract;`
| `procedure GenerateCoordinateBegin; virtual;`
| `procedure GenerateCoordinateEnd; virtual;`
| `procedure GenerateCoordsRange( const RangeNumber: Cardinal; BeginIndex, EndIndex: Integer); virtual;`
| `procedure PrepareIndexesPrimitives; virtual; abstract;`
| `procedure PrepareAttributes(var AllowIndexed: boolean); virtual;`
| `constructor Create(AShape: TShape; AOverTriangulate: boolean); virtual;`
| `function GenerateArrays: TGeometryArrays;`
| `class function BumpMappingAllowed: boolean; virtual;`
### Properties
| `property Shape: TShape read FShape;`
| `property State: TX3DGraphTraverseState read FState;`
| `property Geometry: TAbstractGeometryNode read FGeometry;`
| `property Coord: TMFVec3f read FCoord;`
| `property CoordIndex: TMFLong read FCoordIndex;`
| `property CurrentRangeNumber: Cardinal read FCurrentRangeNumber;`
## Description ### Fields
| `IndexesFromCoordIndex: TLongIntList;`
Indexes, only when Arrays.Indexes = nil but original node was indexed.
| `ArrayIndexNum: Integer;`
Index to Arrays. Suitable always to index Arrays.Position / Color / Normal and other Arrays attribute arrays. Calculated in each TAbstractCoordinateGenerator.GenerateVertex, always call "inherited" first fro GenerateVertex overrides. There are three cases: 1. When CoordIndex <> nil (so we have indexed node) and Arrays.Indexes <> nil (so we can render it by indexes, because AllowIndexed = true) then it's an index to node coordinates. It's equivalent to CoordIndex[IndexNum], and it can be used to index node's Coord as well as Arrays.Position (since they are ordered the same in this case). 2. When CoordIndex <> nil (so we have indexed node) and Arrays.Indexes = nil (so we cannot render it by indexes, because AllowIndexed = false) then it's a number of vertex, that is it's incremented in each TAbstractCoordinateGenerator.GenerateVertex call. In this case IndexesFromCoordIndex <> nil, and Arrays attributes have the same count as IndexesFromCoordIndex.Count. GenerateVertex must be called in exactly the same order as IndexesFromCoordIndex were generated for this. 3. When CoordIndex = nil (so we don't have an indexed node, also Arrays.Indexes = IndexesFromCoordIndex = nil always in this case) then it's an index to attributes. This is the trivial case, as Arrays attributes are then ordered just like node's Coord. It's equal to IndexNum then.
| `Arrays: TGeometryArrays;`
Generated TGeometryArrays instance, available inside GenerateCoordinate*.
| `TexCoordsNeeded: Cardinal;`
Assign these before calling GenerateArrays.
| `MaterialOpacity: Single;`
| `FogVolumetric: boolean;`
| `FogVolumetricDirection: TVector3Single;`
| `FogVolumetricVisibilityStart: Single;`
| `ShapeBumpMappingUsed: boolean;`
| `OnRadianceTransfer: TRadianceTransferFunction;`
| `OnVertexColor: TVertexColorFunction;`
| `FacesNeeded: boolean;`
Do we need TGeometryArrays.Faces
### Methods
| `procedure WarningShadingProblems( const ColorPerVertex, NormalPerVertex: boolean);`
| `procedure GenerateVertex(IndexNum: Integer); virtual;`
Generate arrays content for given vertex. Given IndexNum indexes Coord, or (if CoordIndex is assigned) indexes CoordIndex (and CoordIndex then indexes actual Coord).
| `function GetVertex(IndexNum: integer): TVector3Single;`
Get vertex coordinate. Returned vertex is in local coordinate space (use State.Transform if you want to get global coordinates).
| `function CoordCount: Integer;`
Count of indexes. You can pass index between 0 and `CoordCount` - 1 to various methods taking an index, like GenerateVertex.
| `procedure GenerateCoordinate; virtual; abstract;`
Generate contents of Arrays. These are all called only when Coord is assigned. `GenerateCoordinate` can be overridden only by the class that actually knows how to deconstruct (triangulate etc.) this node. It must call GenerateVertex (or call GenerateCoordsRange, that has to be then overridden to call GenerateVertex after inherited). GenerateCoordinateBegin, GenerateCoordinateEnd will be called before / after `GenerateCoordinate`. It's useful to override them for intermediate classes in this file, that cannot triangulate, but still want to add something before / after `GenerateCoordinate`. When overriding GenerateCoordinateBegin, always call inherited at the begin. When overriding GenerateCoordinateEnd, always call inherited at the end.
| `procedure GenerateCoordinateBegin; virtual;`
| `procedure GenerateCoordinateEnd; virtual;`
| `procedure GenerateCoordsRange( const RangeNumber: Cardinal; BeginIndex, EndIndex: Integer); virtual;`
Generate arrays content for one coordinate range (like a face). This is not called, not used, anywhere in this base TAbstractCoordinateGenerator class. In descendants, it may be useful to use this, like Geometry.MakeCoordRanges(State, @`GenerateCoordsRange`). `GenerateCoordsRange` is supposed to generate the parts of the mesh between BeginIndex and EndIndex - 1 vertices. BeginIndex and EndIndex are indexes to CoordIndex array, if CoordIndex is assigned, or just indexes to Coord.
| `procedure PrepareIndexesPrimitives; virtual; abstract;`
If CoordIndex assigned (this VRML/X3D node is IndexedXxx) then calculate and set IndexesFromCoordIndex here. This is also the place to set Arrays.Primitive and Arrays.Counts.
| `procedure PrepareAttributes(var AllowIndexed: boolean); virtual;`
Called when constructing Arrays, before the Arrays.Count is set. Descendants can override this to do stuff like Arrays.AddColor or Arrays.AddAttribute('foo'). Descendants can also set AllowIndexed to `False`, if we can't use indexed rendering (because e.g. we have colors per-face, which means that the same vertex position may have different colors, which means it has to be duplicated in arrays anyway, so there's no point in indexing).
| `constructor Create(AShape: TShape; AOverTriangulate: boolean); virtual;`
| `function GenerateArrays: TGeometryArrays;`
Create and generate Arrays contents.
| `class function BumpMappingAllowed: boolean; virtual;`
### Properties
| `property Shape: TShape read FShape;`
Current shape properties, constant for the whole lifetime of the generator, set in constructor.
| `property State: TX3DGraphTraverseState read FState;`
| `property Geometry: TAbstractGeometryNode read FGeometry;`
| `property Coord: TMFVec3f read FCoord;`
Coordinates, taken from Geometry.Coord. Usually coming from (`coord` as Coordinate).points field. If `Nil` then nothing will be rendered. In our constructor we initialize `Coord` and CoordIndex from Geometry, using TAbstractGeometryNode.Coord and TAbstractGeometryNode.CoordIndex values.
| `property CoordIndex: TMFLong read FCoordIndex;`
Coordinate index, taken from Geometry.CoordIndex. If `Nil`, then GenerateVertex (and all other routines taking some index) will just directly index Coord (this is useful for non-indexed geometry, like TriangleSet instead of IndexedTriangleSet).
| `property CurrentRangeNumber: Cardinal read FCurrentRangeNumber;`
The number of current range (like a face), equal to RangeNumber passed to GenerateCoordsRange. Read this only while in GenerateCoordsRange. In fact, this is just set by GenerateCoordsRange in this class (so call `inherited` first when overriding it). It's comfortable e.g. when you need RangeNumber inside GenerateVertex, and you know that GenerateVertex will be called only from GenerateCoordsRange.
Generated by PasDoc 0.13.0 on 2015-06-15 04:43:08