Castle Game EngineIntroduction Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers
|
Class TArraysGenerator
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
Overview
Fields
Methods
Properties
Description
Fields
 |
IndexesFromCoordIndex: TGeometryIndexList; |
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.
|
 |
TexCoordsNeeded: Cardinal; |
Assign these before calling GenerateArrays.
|
 |
MaterialOpacity: Single; |
|
 |
FogVolumetric: boolean; |
|
 |
FogVolumetricVisibilityStart: Single; |
|
 |
ShapeBumpMappingUsed: boolean; |
|
 |
ShapeBumpMappingTextureCoordinatesId: Cardinal; |
|
Methods
 |
procedure WarningShadingProblems( const ColorPerVertex, NormalPerVertex: boolean); |
|
 |
function GetVertex(IndexNum: integer): TVector3; |
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.InternalMakeCoordRanges(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; |
|
 |
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 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).
|
Generated by PasDoc 0.15.0.
|