-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMain.pas
118 lines (93 loc) · 3.48 KB
/
Main.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
unit Main;
interface //#################################################################### ■
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
System.Math.Vectors,
FMX.Types3D, FMX.Viewport3D, FMX.Controls3D, FMX.Objects3D, FMX.MaterialSources,
LIB.Model.Poin, LIB.Model.Wire, LIB.Model.Face;
type
TForm1 = class(TForm)
Viewport3D1: TViewport3D;
Dummy1: TDummy;
Dummy2: TDummy;
Camera1: TCamera;
Light1: TLight;
ColorMaterialSource1: TColorMaterialSource;
TextureMaterialSource1: TTextureMaterialSource;
LightMaterialSource1: TLightMaterialSource;
Grid3D1: TGrid3D;
procedure FormCreate(Sender: TObject);
procedure Viewport3D1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single);
procedure Viewport3D1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single);
procedure Viewport3D1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single);
private
{ private 宣言 }
_MouseS :TShiftState;
_MouseP :TPointF;
public
{ public 宣言 }
_PoinModel :TMyPoinModel;
_WireModel :TMyWireModel;
_FaceModel :TMyFaceModel;
end;
var
Form1: TForm1;
implementation //############################################################### ■
{$R *.fmx}
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
procedure TForm1.FormCreate(Sender: TObject);
begin
_MouseS := [];
_PoinModel := TMyPoinModel.Create( Self );
_WireModel := TMyWireModel.Create( Self );
_FaceModel := TMyFaceModel.Create( Self );
with _PoinModel do
begin
Parent := Viewport3D1;
Material := ColorMaterialSource1;
HitTest := False;
end;
with _WireModel do
begin
Parent := Viewport3D1;
Material := TextureMaterialSource1;
HitTest := False;
end;
with _FaceModel do
begin
Parent := Viewport3D1;
Material := LightMaterialSource1;
HitTest := False;
end;
TextureMaterialSource1.Texture.LoadFromFile( '../../_DATA/Rainbow_512.png' );
LightMaterialSource1 .Texture.LoadFromFile( '../../_DATA/Lena_512.png' );
end;
////////////////////////////////////////////////////////////////////////////////
procedure TForm1.Viewport3D1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single);
begin
_MouseS := Shift;
_MouseP := TPointF.Create( X, Y );
end;
procedure TForm1.Viewport3D1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single);
var
P :TPointF;
begin
if ssLeft in _MouseS then
begin
P := TPointF.Create( X, Y );
with Dummy1.RotationAngle do Y := Y + ( P.X - _MouseP.X ) / 2;
with Dummy2.RotationAngle do X := X - ( P.Y - _MouseP.Y ) / 2;
_MouseP := P;
end;
end;
procedure TForm1.Viewport3D1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single);
begin
Viewport3D1MouseMove( Sender, Shift, X, Y );
_MouseS := [];
end;
initialization /////////////////////////////////////////////////////////////////
SetCurrentDir( ExtractFilePath( ParamStr( 0 ) ) );
end. //######################################################################### ■