-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathGS.Soft3D.View.pas
More file actions
134 lines (102 loc) · 2.79 KB
/
Copy pathGS.Soft3D.View.pas
File metadata and controls
134 lines (102 loc) · 2.79 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
unit GS.Soft3D.View;
interface
uses SysUtils,
classes,
contNrs,
Math,
GS.Geometry,
GS.Soft3D,
GS.Soft3D.Types,
GS.Soft3D.PipeLine;
Type
TView3d = class
private
FWireframe: boolean;
Frasterframe: boolean;
procedure SetProjection(const Value: TS3DProjectionType);
function GetProjection: TS3DProjectionType;
function GetCamZ: single;
procedure SetCamZ(const Value: single);
public
PipeLine : TS3DPipeline;
procedure ResizeBuffers(w,h : Uint32);
constructor Create; virtual;
destructor Destroy; override;
procedure Execute;
procedure SetCamPos(X,Y,Z : single);
procedure SetCamRotate(X,Y,Z : single);
Property CameraZ : single read GetCamZ Write SetCamZ;
// Property CameraX : single read FCamX Write FCamX;
// Property CameraY : single read FCamY Write FCamY;
property rasterFrame : boolean read Frasterframe write fRasterframe;
property wireFrame : boolean read FWireframe write FWireframe;
property Projection : TS3DProjectionType read GetProjection write SetProjection;
end;
implementation
{ TView3d }
constructor TView3d.Create;
begin
PipeLine := TS3DPipeline.Create; //build all the 3D pipeline.
CameraZ := -15;
Projection := TS3DProjectionType.Perspective;
FWireframe := false;
Frasterframe := true;
end;
destructor TView3d.Destroy;
begin
freeAndNil(PipeLine);
inherited;
end;
function CalculateSurfaceNormal(AVecA, AVecB,
AVecC: vec3) : vec3;
var
LVecU, LVecV: vec3;
begin
LVecU := AVecB;
LVecU := LVecU - AVecA;
LVecV := AVecC;
LVecV := LVecV - AVecA;
Result.X := (LVecU.Y*LVecV.Z) - (LVecU.Z*LVecV.Y);
Result.Y := (LVecU.Z*LVecV.X) - (LVecU.X*LVecV.Z);
Result.Z := (LVecU.X*LVecV.Y) - (LVecU.Y*LVecV.X);
end;
procedure TView3d.Execute;
begin
PipeLine.Process;
end;
procedure TView3d.SetCamPos(X, Y, Z: single);
begin
PipeLine.InputData.CameraPos.X := X;
PipeLine.InputData.CameraPos.Y := Y;
PipeLine.InputData.CameraPos.Z := Z;
end;
procedure TView3d.SetCamRotate(X, Y, Z: single);
begin
PipeLine.InputData.CameraRot.X := X;
PipeLine.InputData.CameraRot.Y := Y;
PipeLine.InputData.CameraRot.Z := Z;
end;
procedure TView3d.SetCamZ(const Value: single);
begin
PipeLine.InputData.CameraPos.z := value;
end;
procedure TView3d.SetProjection(const Value: TS3DProjectionType);
begin
PipeLine.InputData.Projection := Value;
end;
function TView3d.GetCamZ: single;
begin
result := PipeLine.InputData.CameraPos.z;
end;
function TView3d.GetProjection: TS3DProjectionType;
begin
Result := PipeLine.InputData.Projection;
end;
procedure TView3d.ResizeBuffers(w, h: Uint32);
begin
PipeLine.InputData.Resolution.width := w;
PipeLine.InputData.Resolution.height := h;
PipeLine.RasterOperation.Resize(w,h);
PipeLine.RasterControl.BackMem.resize(w,h);
end;
end.