Unit Triangulator

DescriptionusesClasses, Interfaces, Objects and RecordsFunctions and ProceduresTypesConstantsVariables

Description

Triangulating, i.e. decomposing polygons into triangles.

uses

Overview

Functions and Procedures

procedure TriangulateFace(FaceIndices: PArray_Longint; FaceIndicesCount: integer; Vertices: PArray_Vector3Single; TriangulatorProc: TTriangulatorProc; TriangulatorProcData: Pointer; AddToIndices: Longint);
procedure TriangulateConvexFace(FaceIndicesCount: integer; TriangulatorProc: TTriangulatorProc; TriangulatorProcData: Pointer; AddToIndices: Longint);
procedure TriangulateTriangleStrip(IndicesCount: integer; TriangulatorProc: TTriangulatorProc; TriangulatorProcData: Pointer; AddToIndices: Longint);

Types

TTriangulatorProc = procedure(const Tri:TVector3Longint; Data:Pointer);

Description

Functions and Procedures

procedure TriangulateFace(FaceIndices: PArray_Longint; FaceIndicesCount: integer; Vertices: PArray_Vector3Single; TriangulatorProc: TTriangulatorProc; TriangulatorProcData: Pointer; AddToIndices: Longint);

FaceIndices[0]..FaceIndices[FaceIndicesCount-1] zawieraja indeksy do tablicy Vertices. Te indeksy okreslaja kolejne wierzcholki sciany, niekoniecznie convex.

TriangulateFace rozbija face na trojkaty, dla kazdego trojkata wywolujac TriangulatorProc z drugim parametrem = TriangulatorProcData a pierwszym parametrem ustawionym na indeksy do tablicy FaceIndices[] ktore utworza dany trojkat (zwracamy indeksy a nie gotowe wektory z tablicy Vertices (ani nawet indkesy do Vertices[]) zeby program mogl nie tylko wyciagnac sobie z tablic Vertices[FaceIndices[]] wektory ale takze byc moze z innych tablic wyciagnac informacje towarzyszace dla wierzcholka, a do tego moze byc potrzebny nie tylko indeks do Vertices ale wrecz indeks do FaceIndices - patrz np. w rendererze dla IndexedFaceSet.) Indeksy te sa zwiekszone o AddToIndices (moze byc ujemne) (to jest wygodne gdy FaceIndices to wskaznik do srodka jakiejs tablicy).

Generowane trojkaty maja taka sama orientacje (normal z CCW) jak oryginalny polygon - tzn. normale wyliczone np. IndexedPolygonNormal na non-convex face beda dobre dla trojkatow po triangulacji tej face przez TriangulateFace.

Nie powinienes uzywac tej procedury gdy WIESZ ze face jest convex - wtedy mozna przeciez rozbic face na trojkaty bardzo latwo. Uzywaj tej proc gdy rzeczywiscie face moze byc non-convex - jesli wiesz ze jest convex to uzyj TriangulateConvexFace.

procedure TriangulateConvexFace(FaceIndicesCount: integer; TriangulatorProc: TTriangulatorProc; TriangulatorProcData: Pointer; AddToIndices: Longint);

proste procedury TriangulateConvexFace i TriangulateTriangleStrip nie potrzebuja FaceIndices ani Vertices. Wystarczy im FaceIndicesCount. One tez zapewniaja konsekwentna orientacje trojkatow (w przypadku TriangleStrip liczy sie orientacja pierwszych trzech wierzcholkow, tzn. kolejno dostajemy v0-v1-v2, v2-v1-v3, v2-v3-v4, v4-v3-v5 itd., podobnie jak w OpenGLu). Zwracam uwage ze TriangleStrip ma po prostu jednoznacznie wyznaczona triangulacje i nie ma w jego przypadku sensu rozwazanie czy jest convex czy non-convex.

procedure TriangulateTriangleStrip(IndicesCount: integer; TriangulatorProc: TTriangulatorProc; TriangulatorProcData: Pointer; AddToIndices: Longint);
 

Types

TTriangulatorProc = procedure(const Tri:TVector3Longint; Data:Pointer);
 

Generated by PasDoc 0.10.0 on 2008-02-25 00:00:38