-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpsv_voxelbuffer.pas
133 lines (110 loc) · 3.62 KB
/
psv_voxelbuffer.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//------------------------------------------------------------------------------
//
// DD_VOXEL: DelphiDoom Voxel Editor
// Copyright (C) 2013-2018 by Jim Valavanis
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
// DESCRIPTION:
// Voxelbuffer RTL object
//
//------------------------------------------------------------------------------
// E-Mail: [email protected]
// Site : https://sourceforge.net/projects/delphidoom-voxel-editor/
// https://sourceforge.net/projects/delphidoom/files/DDVoxels/
//------------------------------------------------------------------------------
unit psv_voxelbuffer;
interface
uses
uPSCompiler, uPSRuntime;
type
TVoxelBuffer = class(TObject)
protected
function Get(x, y, z: byte): LongWord; virtual;
procedure Put(x, y, z: byte; const value: LongWord); virtual;
public
constructor Create; virtual;
property value[x, y, z: byte]: LongWord read Get write Put; default;
procedure ClearColor(c: LongWord);
procedure Clear;
end;
procedure SIRegister_VoxelBuffer(CL: TPSPascalCompiler);
procedure RIRegister_VoxelBuffer(CL: TPSRuntimeClassImporter);
procedure RIRegisterRTL_VoxelBuffer(Exec: TPSExec);
implementation
uses
psv_voxel;
function TVoxelBuffer.Get(x, y, z: byte): LongWord;
begin
Result := VDLS_GetVoxel(x, y, z);
end;
procedure TVoxelBuffer.Put(x, y, z: byte; const value: LongWord);
begin
VDLS_SetVoxel(x, y, z, value);
end;
procedure TVoxelBuffer.ClearColor(c: LongWord);
begin
VDLS_ClearVoxel(c);
end;
procedure TVoxelBuffer.Clear;
begin
VDLS_Clear;
end;
constructor TVoxelBuffer.Create;
begin
Inherited;
end;
procedure SIRegister_VoxelBuffer(CL: TPSPascalCompiler);
begin
with CL.AddClassN(CL.FindClass('!TOBJECT'), '!TVoxelBuffer') do
begin
RegisterMethod('constructor Create');
RegisterMethod('procedure ClearColor(c: LongWord)');
RegisterMethod('procedure Clear');
RegisterProperty('value', 'longword byte byte byte', iptRW);
SetDefaultPropery('value');
end;
AddImportedClassVariable(CL, 'VoxelBuffer', '!TVoxelBuffer');
end;
procedure TVoxelBuffervalue_W(Self: TVoxelBuffer; const T: LongWord; const x, y, z: byte);
begin
Self.value[x, y, z] := T;
end;
procedure TVoxelBuffervalue_R(Self: TVoxelBuffer; var T: LongWord; const x, y, z: byte);
begin
T := Self.value[x, y, z];
end;
procedure RIRegister_VoxelBuffer(CL: TPSRuntimeClassImporter);
begin
with CL.Add2(TVoxelBuffer, '!TVOXELBUFFER') do
begin
RegisterConstructor(@TVoxelBuffer.Create, 'Create');
RegisterMethod(@TVoxelBuffer.ClearColor, 'ClearColor');
RegisterMethod(@TVoxelBuffer.Clear, 'Clear');
RegisterPropertyHelper(@TVoxelBuffervalue_R, @TVoxelBuffervalue_W, 'value');
end;
end;
var
RTL_VoxelBuffer: TVoxelBuffer;
procedure RIRegisterRTL_VoxelBuffer(Exec: TPSExec);
begin
SetVariantToClass(Exec.GetVarNo(Exec.GetVar('voxelbuffer')), RTL_VoxelBuffer);
end;
initialization
RTL_VoxelBuffer := TVoxelBuffer.Create;
finalization
RTL_VoxelBuffer.Free;
end.