CAST II Game Engine

   DESCRIPTION       FEATURES       SCREENSHOTS       FORUMS       DOCUMENTATION       DOWNLOADS       CONTACTS   
Units
Class Hierarchy
Classes, Interfaces and Objects
Types
Enumerations
Variables
Constants
Functions and Procedures
Identifiers

Class TTesselator

Unit

C2Visual

Declaration

type TTesselator = class(TReferencedItem)

Description

Performs triangulation of visible items

Visible items are different - GUI elements, 3D meshes, procedural models, etc. [b]TTesselator[/b] contains methods to convert an item to its triangulated representation.

Hierarchy

TReferencedItem

Fields

 NameDescription
PublicCommandBlockCommand block ID For render speedup. E.g. OpenGL display list ID.
PublicCommandBlockValidDetermines if command block is a currently valid ID
PublicCompositeMember 
PublicCompositeOffset 
ProtectedElementOffs 
ProtectedFVertexFormat 
ProtectedFVertexSize 
PublicIndexingVerticesNumber of vertices referenced by indices
PublicIndicesRes 
PublicLastTotalIndicesIndex: Integer;
PublicLastTotalVerticesIndex: Integer;
PublicManualRender 
PublicPrimitiveTypePrimitive type
PublicStripOffsetOffset in vertex buffer for each strip
PublicTesselationStatusCurrent tesselation status
PublicTotalIndicesTotal indices in all strips
PublicTotalPrimitivesTotal primitives in each strip
PublicTotalStripsTotal strips
PublicTotalVerticesTotal vetices in all strips
PublicVerticesRes 

Methods

Overview

Publicconstructor Create; virtual;
Publicprocedure AddProperties(const Result: Props.TProperties); virtual;
Publicprocedure BeginLighting; virtual; abstract;
Publicfunction CalculateLighting(const ALight: TLight; const ALightToItem: TMatrix4s): Boolean; virtual; abstract;
Publicprocedure DoManualRender(Item: TItem); virtual; abstract;
Publicfunction GetBoundingBox: TBoundingBox; virtual;
Publicfunction GetIndex(AOffset: Integer; AIBuf: Pointer): Integer;
Publicfunction GetMaxAmount(Buffer: TTesselationBuffer): Integer;
Protectedfunction GetMaxIndices: Integer; virtual;
Protectedfunction GetMaxVertices: Integer; virtual;
Publicfunction GetUpdatedElements(Buffer: TTesselationBuffer; const Params: TTesselationParameters): Integer; virtual;
Publicfunction GetVertexDataC(AIndex: Integer; AVBuf: Pointer): TVector3s;
Publicprocedure Init; virtual;
Protectedprocedure InitVertexFormat(Format: Integer); virtual;
Publicprocedure Invalidate(ABuffer: TTesselationBufferSet; EntireBuffer: Boolean);
Protectedprocedure InvalidateBoundingBox;
Protectedprocedure SetIndex(AValue, AOffset: Integer; AIBuf: Pointer);
Publicfunction SetIndices(IBPTR: Pointer): Integer; virtual;
Publicprocedure SetProperties(Properties: Props.TProperties); virtual;
Protectedprocedure SetVertexData2UV(u, v: Single; Index: Integer; VBuf: Pointer);
Protectedprocedure SetVertexDataC(x, y, z: Single; Index: Integer; VBuf: Pointer); overload;
Protectedprocedure SetVertexDataC(const Vec: TVector3s; Index: Integer; VBuf: Pointer); overload;
Protectedprocedure SetVertexDataCRHW(x, y, z, RHW: Single; Index: Integer; VBuf: Pointer);
Protectedprocedure SetVertexDataD(Color: TColor; Index: Integer; VBuf: Pointer);
Protectedprocedure SetVertexDataN(nx, ny, nz: Single; Index: Integer; VBuf: Pointer); overload;
Protectedprocedure SetVertexDataN(const Vec: TVector3s; Index: Integer; VBuf: Pointer); overload;
Protectedprocedure SetVertexDataS(Color: TColor; Index: Integer; VBuf: Pointer);
Protectedprocedure SetVertexDataUV(u, v: Single; Index: Integer; VBuf: Pointer);
Protectedprocedure SetVertexDataUV3(u, v, w: Single; Index: Integer; VBuf: Pointer);
Protectedprocedure SetVertexDataW(w: Single; Index: Integer; VBuf: Pointer);
Publicfunction Tesselate(const Params: TTesselationParameters; VBPTR: Pointer): Integer; virtual;
Publicfunction Validate: Boolean; virtual;

Description

Publicconstructor Create; virtual;

{$IFDEF DEBUGMODE} LastMaxVertices: Integer; {$ENDIF} // Used only for debugging

Publicprocedure AddProperties(const Result: Props.TProperties); virtual;

Can be overridden to add some properties in addition to ones of a visible item which uses the tesselator. Called from AddProperties of TVisible. Object links can not be used or resolved here.

Publicprocedure BeginLighting; virtual; abstract;

Manual lighting begin

Publicfunction CalculateLighting(const ALight: TLight; const ALightToItem: TMatrix4s): Boolean; virtual; abstract;

Perform manual lighting

Publicprocedure DoManualRender(Item: TItem); virtual; abstract;

 

Publicfunction GetBoundingBox: TBoundingBox; virtual;

 

Publicfunction GetIndex(AOffset: Integer; AIBuf: Pointer): Integer;

Returns an index from index buffer

Publicfunction GetMaxAmount(Buffer: TTesselationBuffer): Integer;

Returns maximum amount of elements in the specified buffer type

Protectedfunction GetMaxIndices: Integer; virtual;

Should return a maximum possible amount of indices for the tesselator object to reserve place in buffers.
For rarely updated tesselators which still can have a variable number of indices it's reasonable to use a static tesselator with GetMaxVertices the maximum amount of indices. The return value of this function can vary but its change should be indicated with the tsMaxSizeChanged teselation status and will cause discarding of a buffer which may cause performance penalty at lest for static buffers.

Protectedfunction GetMaxVertices: Integer; virtual;

Should return a maximum possible amount of vertices for the tesselator object to reserve place in buffers.
For rarely updated tesselators which still can have a variable number of vertices it's reasonable to use a static tesselator with GetMaxVertices the maximum amount of vertices. The return value of this function can vary but its change should be indicated with the tsMaxSizeChanged teselation status and will cause discarding of a buffer which may cause performance penalty at lest for static buffers.

Publicfunction GetUpdatedElements(Buffer: TTesselationBuffer; const Params: TTesselationParameters): Integer; virtual;

Returns number of elements in the specified buffer type which needs to be updated in an API buffers. This function called by engine static buffers management routine to determine if lock/fill/unlock procedure needed for each tesselator. If the function returns 0 no update needed.

Publicfunction GetVertexDataC(AIndex: Integer; AVBuf: Pointer): TVector3s;

Get a coordinate set from vertex buffer. [b]AIndex[/b] - element index, [b]AVBuf[/b] - pointer to vertex buffer.

Publicprocedure Init; virtual;

 

Protectedprocedure InitVertexFormat(Format: Integer); virtual;

Init internal variables for the specified vertex format

Publicprocedure Invalidate(ABuffer: TTesselationBufferSet; EntireBuffer: Boolean);

Invalidates contents of buffers used by the tesselator at the API side. If EntireBuffer is True entire API buffer will become invalid so use only if necessary.

Protectedprocedure InvalidateBoundingBox;

Informs engine core about bounding box change

Protectedprocedure SetIndex(AValue, AOffset: Integer; AIBuf: Pointer);

Sets an index in index buffer

Publicfunction SetIndices(IBPTR: Pointer): Integer; virtual;

 

Publicprocedure SetProperties(Properties: Props.TProperties); virtual;

Can be overridden to set some properties in addition to ones of a visible item which uses the tesselator. Called from SetProperties of TVisible. Object links can not be used or resolved here.

Protectedprocedure SetVertexData2UV(u, v: Single; Index: Integer; VBuf: Pointer);

Set second 2D-texture coordinates set in vertex buffer. [b]Index[/b] - element index, [b]VBuf[/b] - pointer to vertex buffer. Should be called from Tesselate only

Protectedprocedure SetVertexDataC(x, y, z: Single; Index: Integer; VBuf: Pointer); overload;

Set a coordinate set in vertex buffer. [b]Index[/b] - element index, [b]VBuf[/b] - pointer to vertex buffer. Should be called from Tesselate only

Protectedprocedure SetVertexDataC(const Vec: TVector3s; Index: Integer; VBuf: Pointer); overload;

Set a coordinate set in vertex buffer. [b]Index[/b] - element index, [b]VBuf[/b] - pointer to vertex buffer. Should be called from Tesselate only

Protectedprocedure SetVertexDataCRHW(x, y, z, RHW: Single; Index: Integer; VBuf: Pointer);

Set a transformed coordinate set in vertex buffer. [b]Index[/b] - element index, [b]VBuf[/b] - pointer to vertex buffer. Should be called from Tesselate only

Protectedprocedure SetVertexDataD(Color: TColor; Index: Integer; VBuf: Pointer);

Set a diffuse color (color 1) in vertex buffer. [b]Index[/b] - element index, [b]VBuf[/b] - pointer to vertex buffer. Should be called from Tesselate only

Protectedprocedure SetVertexDataN(nx, ny, nz: Single; Index: Integer; VBuf: Pointer); overload;

Set a normal in vertex buffer. [b]Index[/b] - element index, [b]VBuf[/b] - pointer to vertex buffer. Should be called from Tesselate only

Protectedprocedure SetVertexDataN(const Vec: TVector3s; Index: Integer; VBuf: Pointer); overload;

Set a normal in vertex buffer. [b]Index[/b] - element index, [b]VBuf[/b] - pointer to vertex buffer. Should be called from Tesselate only

Protectedprocedure SetVertexDataS(Color: TColor; Index: Integer; VBuf: Pointer);

Set a specular color (color 2) in vertex buffer. [b]Index[/b] - element index, [b]VBuf[/b] - pointer to vertex buffer. Should be called from Tesselate only

Protectedprocedure SetVertexDataUV(u, v: Single; Index: Integer; VBuf: Pointer);

Set first 2D-texture coordinates set in vertex buffer. [b]Index[/b] - element index, [b]VBuf[/b] - pointer to vertex buffer. Should be called from Tesselate only

Protectedprocedure SetVertexDataUV3(u, v, w: Single; Index: Integer; VBuf: Pointer);

Set first 3D-texture coordinates set in vertex buffer. [b]Index[/b] - element index, [b]VBuf[/b] - pointer to vertex buffer. Should be called from Tesselate only

Protectedprocedure SetVertexDataW(w: Single; Index: Integer; VBuf: Pointer);

Set a weight in vertex buffer. [b]Index[/b] - element index, [b]VBuf[/b] - pointer to vertex buffer. Should be called from Tesselate only

Publicfunction Tesselate(const Params: TTesselationParameters; VBPTR: Pointer): Integer; virtual;

 

Publicfunction Validate: Boolean; virtual;

Returns True if mesh is valid. The basic implemetation simply tests all indices to point within correct vertices range.

Properties

Overview

Publicproperty VertexFormat: Integer;
Publicproperty VertexSize: Integer;

Description

Publicproperty VertexFormat: Integer;

Output format of vertices

Publicproperty VertexSize: Integer;

Size of each vertex

Last modified: 4 Jul, 2008
Copyright (C) 2006-2008, casteng.com