forked from gbegreg/GBE3D
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGBEConeExtend.pas
95 lines (78 loc) · 2.23 KB
/
GBEConeExtend.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
unit GBEConeExtend;
interface
uses
System.SysUtils, System.Classes, FMX.Types, FMX.Controls3D, FMX.Objects3D, FMX.Types3D, System.Math.Vectors,
FMX.MaterialSources;
type
TCustomMeshHelper = class(TCustomMesh);
TConeForme = (pyramidTriangle, pyramidSquare, tipi, cone);
TGBEConeExtend = class(TCone)
private
{ Déclarations privées }
fForme : TConeForme;
fShowlines: boolean;
fMaterialLignes: TColorMaterialSource;
procedure setForme(const Value: TConeForme);
procedure CreateGBECone(const aData: TMeshData; const aForme: TConeForme = TConeForme.cone);
protected
{ Déclarations protégées }
public
{ Déclarations publiques }
constructor Create(AOwner: TComponent); override;
procedure Render; override;
published
{ Déclarations publiées }
property Forme : TConeForme read fForme write setForme;
property ShowLines: boolean read fShowlines write fShowLines;
property MaterialLines : TColorMaterialSource read fMaterialLignes write fMaterialLignes;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('GBE3D', [TGBEConeExtend]);
end;
{ TGBEConeExtend }
constructor TGBEConeExtend.Create(AOwner: TComponent);
begin
inherited;
fForme := TConeForme.cone;
end;
procedure TGBEConeExtend.setForme(const Value: TConeForme);
begin
if value <> fForme then
begin
fForme := Value;
CreateGBECone(self.Data,fForme);
end;
end;
procedure TGBEConeExtend.CreateGBECone(Const aData:TMeshData; Const aForme: TConeForme = TConeForme.cone);
var
D:TMeshData;
Co:TCone;
begin
D:=TMeshData.Create;
Co:=TCone.Create(nil);
case fForme of
pyramidTriangle: Co.SubdivisionsAxes:=3;
pyramidSquare: Co.SubdivisionsAxes:=4;
tipi : Co.SubdivisionsAxes:=6;
cone : Co.SubdivisionsAxes:=12;
end;
Co.SubdivisionsHeight:=self.SubdivisionsHeight;
Co.SubdivisionsCap :=self.SubdivisionsCap;
D.Assign(TCustomMeshHelper(Co).Data);
TCustomMeshHelper(Co).data.Clear;
Co.Free;
D.CalcTangentBinormals;
aData.Clear;
aData.Assign(D);
D.Free;
end;
procedure TGBEConeExtend.Render;
begin
inherited;
if ShowLines then
Context.DrawLines(self.Data.VertexBuffer, self.Data.IndexBuffer, TMaterialSource.ValidMaterial(fMaterialLignes),1);
end;
end.