-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrw_shared.lua
More file actions
859 lines (632 loc) · 23.5 KB
/
rw_shared.lua
File metadata and controls
859 lines (632 loc) · 23.5 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
-- RenderWare stream parsing implementations by (c)The_GTA.
-- Since Lua cannot process data as efficiently as native languages, the implementations
-- in this file are optimized for comfort instead of performance.
-- We do not implement reading "broken RW files" with their chunk sizes borked; fix them with
-- public tools before loading them.
local RW_DEBUG = true;
local function _read_byte(filePtr)
local numbytes = fileRead(filePtr, 1);
if not (numbytes) or (#numbytes < 1) then
return false;
end
return string.byte(numbytes, 1);
end
local function _read_uint16(filePtr)
local numbytes = fileRead(filePtr, 2);
if not (numbytes) or (#numbytes < 2) then
return false;
end
return ( string.byte(numbytes, 2) * 0x0100 + string.byte(numbytes, 1) );
end
local function _read_uint32(filePtr)
local numbytes = fileRead(filePtr, 4);
if not (numbytes) or (#numbytes < 4) then
return false;
end
return ( string.byte(numbytes, 4) * 0x01000000 + string.byte(numbytes, 3) * 0x00010000 + string.byte(numbytes, 2) * 0x00000100 + string.byte(numbytes, 1) );
end
local function _read_float32(filePtr)
local bytes = fileRead(filePtr, 4);
if not (bytes) or (#bytes < 4) then return false; end;
-- Vendor function.
return bytes2float(bytes);
end
local function _read_rwversion(filePtr)
local verBytes = fileRead(filePtr, 4);
if not (verBytes) or (#verBytes < 4) then return false; end;
local vb1 = string.byte(verBytes, 1);
local vb2 = string.byte(verBytes, 2);
local vb3 = string.byte(verBytes, 3);
local vb4 = string.byte(verBytes, 4);
local rwLibMajor = bitExtract(vb4, 6, 2);
local rwRelMajor = bitExtract(vb4, 2, 4);
local rwRelMinor = bitExtract(vb4, 0, 2) * 0x0F + bitExtract(vb3, 6, 2);
local rwBinFmtRev = bitExtract(vb3, 0, 6);
local buildNumber = ( vb2 * 0x0100 + vb1 );
local verInfo = {};
verInfo.libMajor = rwLibMajor + 3;
verInfo.relMajor = rwRelMajor;
verInfo.relMinor = rwRelMinor;
verInfo.binFmtRev = rwBinFmtRev;
verInfo.buildNumber = buildNumber;
return verInfo;
end
local function rwReadChunkHeader(filePtr)
local chunkType = _read_uint32(filePtr);
local chunkSize = _read_uint32(filePtr);
local chunkVersion = _read_rwversion(filePtr);
if not (chunkType) or not (chunkSize) or not (chunkVersion) then return false; end;
local chunk = {};
chunk.type = chunkType;
chunk.version = chunkVersion;
chunk.size = chunkSize;
return chunk;
end
local function readPackedVector(filePtr)
local vec = {};
vec.x = _read_float32(filePtr);
vec.y = _read_float32(filePtr);
vec.z = _read_float32(filePtr);
return vec;
end
local function readPackedMatrix(filePtr)
local matrix = {};
matrix.right = readPackedVector(filePtr);
matrix.up = readPackedVector(filePtr);
matrix.front = readPackedVector(filePtr);
if not (matrix.right) or not (matrix.up) or not (matrix.front) then return false; end;
return matrix;
end
local function readExtensions(filePtr)
local chunkHeader = rwReadChunkHeader(filePtr);
if not (chunkHeader) then
return false, "failed to read chunk header";
end
if not (chunkHeader.type == 0x03) then
return false, "not an extension (got " .. chunkHeader.type .. ")";
end
-- We just skip extensions, for now.
local curSeek = fileGetPos(filePtr);
fileSetPos(filePtr, curSeek + chunkHeader.size );
return {};
end
function rwCreateFrame()
local frame = {};
return frame;
end
local function readFrameList(filePtr)
local chunkHeader = rwReadChunkHeader(filePtr);
if not (chunkHeader) then
return false, "failed to read chunk header";
end
if not (chunkHeader.type == 0xE) then
return false, "not a frame list";
end
local structHeader = rwReadChunkHeader(filePtr);
if not (structHeader) then
return false, "failed to read struct chunk header";
end
if not (structHeader.type == 1) then
return false, "not a struct chunk";
end
local num_frames = _read_uint32(filePtr);
if not (num_frames) then
return false, "failed to read number of frames";
end
local frames = {};
for iter=1,num_frames,1 do
local rotation_mat = readPackedMatrix(filePtr);
if not (rotation_mat) then
return false, "failed to read rotation matrix";
end
local translation = readPackedVector(filePtr);
if not (translation) then
return false, "failed to read translation offset";
end
local frame_idx = _read_uint32(filePtr);
if not (frame_idx) then
return false, "failed to read frame index";
end
local matrix_flags = _read_uint32(filePtr);
if not (matrix_flags) then
return false, "failed to read matrix flags";
end
local frame = rwCreateFrame();
frame.rotation_mat = rotation_mat;
frame.idx = frame_idx;
frame.translation = translation;
frame.mat_flags = matrix_flags;
frames[iter] = frame;
end
for n=1,num_frames,1 do
local extensions, err = readExtensions(filePtr);
if not (extensions) then
return false, "failed to read extensions: " .. err;
end
frames[n].extensions = extensions;
end
local framelist = {};
framelist.frames = frames;
return framelist;
end
local function readBoundingSphere(filePtr)
local sphere = {};
sphere.x = _read_float32(filePtr);
sphere.y = _read_float32(filePtr);
sphere.z = _read_float32(filePtr);
sphere.r = _read_float32(filePtr);
if not (sphere.x) or not (sphere.y) or not (sphere.z) or not (sphere.r) then
return false;
end
return sphere;
end
local function readStringChunk(filePtr)
local chunkHeader = rwReadChunkHeader(filePtr);
if not (chunkHeader) then
return false, "failed to read chunk header";
end
if not (chunkHeader.type == 0x02) then
return false, "not a string";
end
local data = fileRead(filePtr, chunkHeader.size);
if not (data) then
return false, "failed to read string character bytes";
end
-- Remove trailing bytes of zeroes.
local non_zero_cnt = string.find(data, "\0");
if (non_zero_cnt) then
return string.sub(data, 1, non_zero_cnt - 1);
end
return data;
end
function rwReadTextureInfo(filePtr)
local chunkHeader = rwReadChunkHeader(filePtr);
if not (chunkHeader) then
return false, "failed to read chunk header";
end
if not (chunkHeader.type == 0x06) then
return false, "not a texture info";
end
local structHeader = rwReadChunkHeader(filePtr);
if not (structHeader) then
return false, "failed to read struct chunk header";
end
if not (structHeader.type == 1) then
return false, "not a struct chunk";
end
local tex_flags = _read_uint32(filePtr);
if not (tex_flags) then
return false, "failed to read texture info flags";
end
local filterMode = bitExtract(tex_flags, 0, 8);
local uAddr = bitExtract(tex_flags, 8, 4);
local vAddr = bitExtract(tex_flags, 12, 4);
local hasMips = bitExtract(tex_flags, 16, 1);
local texName = readStringChunk(filePtr);
if not (texName) then
return false, "failed to read texture name";
end
local maskName = readStringChunk(filePtr);
if not (maskName) then
return false, "failed to read mask name";
end
local extension = readExtensions(filePtr);
if not (extension) then
return false, "failed to read extensions";
end
local textureInfo = {};
textureInfo.filterMode = filterMode;
textureInfo.uAddr = uAddr;
textureInfo.vAddr = vAddr;
textureInfo.hasMips = hasMips;
textureInfo.texName = texName;
textureInfo.maskName = maskName;
textureInfo.extension = extension;
return textureInfo;
end
function rwReadMaterial(filePtr)
local chunkHeader = rwReadChunkHeader(filePtr);
if not (chunkHeader) then
return false, "failed to read chunk header";
end
if not (chunkHeader.type == 0x07) then
return false, "not a material";
end
local structHeader = rwReadChunkHeader(filePtr);
if not (structHeader) then
return false, "failed to read struct chunk header";
end
if not (structHeader.type == 1) then
return false, "not a struct chunk";
end
local mat_flags = _read_uint32(filePtr);
local red = _read_byte(filePtr);
local green = _read_byte(filePtr);
local blue = _read_byte(filePtr);
local alpha = _read_byte(filePtr);
local pad0 = _read_uint32(filePtr);
local int_isTextured = _read_uint32(filePtr);
local ambient = _read_float32(filePtr);
local specular = _read_float32(filePtr);
local diffuse = _read_float32(filePtr);
if not (mat_flags) or not (red) or not (green) or not (blue) or not (alpha) or
not (pad0) or not (int_isTextured) or not (ambient) or not (specular) or
not (diffuse) then
return false, "failed to read struct data";
end
local isTextured = not (int_isTextured == 0);
local texture = false;
if (isTextured) then
local err;
texture, err = rwReadTextureInfo(filePtr);
if not (texture) then
return false, "failed to read texture: " .. err;
end
end
local extension, err = readExtensions(filePtr);
if not (extension) then
return false, "failed to read extensions: " .. err;
end
local material = {};
material.flags = mat_flags;
material.red = red;
material.green = green;
material.blue = blue;
material.alpha = alpha;
material.texture = texture;
material.ambient = ambient;
material.specular = specular;
material.diffuse = diffuse;
material.extension = extension;
return material;
end
local function readMaterialList(filePtr)
local chunkHeader = rwReadChunkHeader(filePtr);
if not (chunkHeader) then
return false, "failed to read chunk header";
end
if not (chunkHeader.type == 0x08) then
return false, "not a material list";
end
local structHeader = rwReadChunkHeader(filePtr);
if not (structHeader) then
return false, "failed to read struct header";
end
if not (structHeader.type == 1) then
return false, "not a struct header";
end
local num_materials = _read_uint32(filePtr);
if not (num_materials) then
return false, "failed to read number of materials";
end
local mat_indices = {};
for iter=1,num_materials,1 do
local mat_idx = _read_uint32(filePtr);
if not (mat_idx) then
return false, "failed to read material index";
end
mat_indices[iter] = mat_idx;
end
local materials = {};
for iter=1,num_materials,1 do
local mat, err = rwReadMaterial(filePtr);
if not (mat) then
return false, "failed to read material #" .. iter ..": " .. err;
end
materials[iter] = mat;
end
local materialList = {};
materialList.list = materials;
materialList.indices = mat_indices;
return materialList;
end
local function rwReadGeometry(filePtr)
local chunkHeader = rwReadChunkHeader(filePtr);
if not (chunkHeader) then
return false, "failed to read chunk header";
end
if not (chunkHeader.type == 0x0F) then
return false, "not a geometry";
end
local structHeader = rwReadChunkHeader(filePtr);
if not (structHeader) then
return false, "failed to read struct chunk header";
end
if not (structHeader.type == 1) then
return false, "not a struct chunk";
end
local formatFlags = _read_uint32(filePtr);
local numTriangles = _read_uint32(filePtr);
local numVertices = _read_uint32(filePtr);
local numMorphTargets = _read_uint32(filePtr);
if not (formatFlags) then
return false, "failed to read format flags";
end
if not (numTriangles) then
return false, "failed to read num triangles";
end
if not (numVertices) then
return false, "failed to read num vertices";
end
if not (numMorphTargets) then
return false, "failed to read num morph targets";
end
if (RW_DEBUG) then
outputDebugString( "formatFlags: " .. formatFlags );
outputDebugString( "numTriangles: " .. numTriangles );
outputDebugString( "numVertices: " .. numVertices );
outputDebugString( "numMorphTargets: " .. numMorphTargets );
end
-- What do we actually have?
local is_tri_strip = bitTest(formatFlags, 0x00000001);
local has_vertex_pos = bitTest(formatFlags, 0x00000002);
local has_vertex_texcoord = bitTest(formatFlags, 0x00000004);
local has_vertex_colors = bitTest(formatFlags, 0x00000008);
local has_vertex_normals = bitTest(formatFlags, 0x00000010);
local has_geom_lighting = bitTest(formatFlags, 0x00000020);
local has_geom_mat_modulation = bitTest(formatFlags, 0x00000040);
local has_geom_texcoord_2 = bitTest(formatFlags, 0x00000080);
local is_geom_native = bitTest(formatFlags, 0x01000000);
-- We ignore the flag bits that we do not care about
-- This should not happen in clean implementations.
-- I guess geometry can be missing from the container BUT DOES NOT HAVE TO.
if (is_geom_native) then
return false, "fatal: native geometry not supported";
end
local arbitrary_numTexSets = bitExtract(formatFlags, 16, 8);
local numTexSets = 0;
if (arbitrary_numTexSets > 0) then
numTexSets = arbitrary_numTexSets;
else
if (has_geom_texcoord) then
numTexSets = 1;
elseif (has_geom_texcoord_2) then
numTexSets = 2;
end
end
local commondata_vertices = {};
for iter=1,numVertices,1 do
local vert = {};
vert.red = 0;
vert.green = 0;
vert.blue = 0;
vert.alpha = 0;
vert.texcoords = {};
commondata_vertices[iter] = vert;
end
if (has_vertex_colors) then
for iter=1,numVertices,1 do
local vert = commondata_vertices[iter];
vert.red = _read_byte(filePtr);
vert.green = _read_byte(filePtr);
vert.blue = _read_byte(filePtr);
vert.alpha = _read_byte(filePtr);
if not (vert.red) or not (vert.green) or not (vert.blue) or not (vert.alpha) then
return false, "failed to read vertex color";
end
end
end
for tsetn=1,numTexSets,1 do
for iter=1,numVertices,1 do
local vert = commondata_vertices[iter];
local texcoord = {};
texcoord.u = _read_float32(filePtr);
texcoord.v = _read_float32(filePtr);
if not (texcoord.u) or not (texcoord.v) then
return false, "failed to read vertex texture coordinate #" .. tsetn;
end
vert.texcoords[tsetn] = texcoord;
end
end
local triangles = {};
for iter=1,numTriangles,1 do
local tri = {};
tri.vertex2 = _read_uint16(filePtr);
tri.vertex1 = _read_uint16(filePtr);
tri.mat_id = _read_uint16(filePtr);
tri.vertex3 = _read_uint16(filePtr);
if not (tri.vertex2) or not (tri.vertex1) or not (tri.mat_id) or not (tri.vertex3) then
return false, "failed to read triangle";
end
triangles[iter] = tri;
end
local morphTargets = {};
for mtiter=1,numMorphTargets,1 do
local mtarget = {};
mtarget.sphere = readBoundingSphere(filePtr);
local int_hasVertices = _read_uint32(filePtr);
local int_hasNormals = _read_uint32(filePtr);
if not (mtarget.sphere) or not (int_hasVertices) or not (int_hasNormals) then
return false, "failed to read morph target #" .. mtiter;
end
local vertices = false;
local hasVertices = not (int_hasVertices == 0);
local hasNormals = not (int_hasNormals == 0);
if (hasVertices) or (hasNormals) then
vertices = {};
for iter=1,numVertices,1 do
local vert = {};
vert.x = 0;
vert.y = 0;
vert.z = 0;
vert.nx = 0;
vert.ny = 0;
vert.nz = 0;
vertices[iter] = vert;
end
end
if (hasVertices) then
for iter=1,numVertices,1 do
local vert = vertices[iter];
vert.x = _read_float32(filePtr);
vert.y = _read_float32(filePtr);
vert.z = _read_float32(filePtr);
if not (vert.x) or not (vert.y) or not (vert.z) then
return false, "failed to read morph target vertex translation";
end
end
end
if (hasNormals) then
for iter=1,numVertices,1 do
local vert = vertices[iter];
vert.nx = _read_float32(filePtr);
vert.ny = _read_float32(filePtr);
vert.nz = _read_float32(filePtr);
if not (vert.nx) or not (vert.ny) or not (vert.nz) then
return false, "failed to read morph target vertex normal";
end
end
end
mtarget.vertices = vertices;
morphTargets[mtiter] = mtarget;
end
local materials, err = readMaterialList(filePtr);
if not (materials) then
return false, "failed to read material list: " .. err;
end
local extension, err = readExtensions(filePtr);
if not (extension) then
return false, "failed to read extensions: " .. err;
end
local geom = {};
geom.common_vertData = commondata_vertices;
geom.triangles = triangles;
geom.morphTargets = morphTargets;
geom.hasDynamicLighting = has_geom_lighting;
geom.hasMaterialModulation = has_geom_mat_modulation;
geom.hasNativeData = is_geom_native;
geom.materialList = materials;
geom.extension = extension;
return geom;
end
local function readGeometryList(filePtr)
local chunkHeader = rwReadChunkHeader(filePtr);
if not (chunkHeader) then
return false, "failed to read chunk header";
end
if not (chunkHeader.type == 0x1A) then
return false, "not a geometry list";
end
local structHeader = rwReadChunkHeader(filePtr);
if not (structHeader) then
return false, "failed to read struct chunk";
end
if not (structHeader.type == 1) then
return false, "not a struct chunk";
end
local num_geoms = _read_uint32(filePtr);
if not (num_geoms) then
return false, "failed to read number of geometries";
end
local geometries = {};
for iter=1,num_geoms,1 do
local geom, err = rwReadGeometry(filePtr);
if not (geom) then
return false, "failed to read geometry #" .. iter .. ": " .. err;
end
geometries[iter] = geom;
end
return geometries;
end
function rwReadAtomic(filePtr)
local chunkHeader = rwReadChunkHeader(filePtr);
if not (chunkHeader) then
return false, "failed to read chunk header";
end
if not (chunkHeader.type == 0x14) then
return false, "not an atomic";
end
local structHeader = rwReadChunkHeader(filePtr);
if not (structHeader) then
return false, "failed to read struct chunk header";
end
if not (structHeader.type == 1) then
return false, "not a struct chunk";
end
local frameIndex = _read_uint32(filePtr);
local geomIndex = _read_uint32(filePtr);
local flags = _read_uint32(filePtr);
local unused = _read_uint32(filePtr);
if not (frameIndex) or not (geomIndex) or not (flags) or not (unused) then
return false, "failed to read struct members";
end
local doCollisionTest = bitTest(flags, 0x01);
local doRender = bitTest(flags, 0x04);
local extension, err = readExtensions(filePtr);
if not (extension) then
return false, "failed to read extension: " .. err;
end
local atomic = {};
atomic.frameIndex = frameIndex;
atomic.geomIndex = geomIndex;
atomic.doCollisionText = doCollisionTest;
atomic.doRender = doRender;
atomic.extension = extension;
return atomic;
end
function rwReadClump(filePtr)
local mainChunkHeader = rwReadChunkHeader(filePtr);
if not (mainChunkHeader) then
fileClose(filePtr);
return false, "failed to read DFF chunk header";
end
if not (mainChunkHeader.version.libMajor == 3) or not (mainChunkHeader.version.relMajor >= 5) then
return false, "only San Andreas files are supported (got "
.. mainChunkHeader.version.libMajor .. "." .. mainChunkHeader.version.relMajor .. ")";
end
if not (mainChunkHeader.type == 0x10) then
return false, "not a DFF file (ID: " .. mainChunkHeader.type .. ")";
end
-- Process clump stuff.
local clumpMetaHeader = rwReadChunkHeader(filePtr);
if not (clumpMetaHeader) then
return false, "failed to read clump meta header";
end
if not (clumpMetaHeader.type == 0x01) then
return false, "not a struct chunk";
end
local num_atomics = _read_uint32(filePtr);
local num_lights = _read_uint32(filePtr);
local num_cameras = _read_uint32(filePtr);
if not (num_atomics) then
return false, "failed to read number of atomics";
end
if not (num_lights) then
return false, "failed to read number of lights";
end
if not (num_cameras) then
return false, "failed to read number of cameras";
end
if (num_lights > 0) then
return false, "fatal: lights are not supported";
end
if (num_cameras > 0) then
return false, "fatal: cameras are not supported";
end
local framelist, err = readFrameList(filePtr);
if not (framelist) then
return false, "failed to read framelist: " .. err;
end
local geomlist, err = readGeometryList(filePtr);
if not (geomlist) then
return false, "failed to read geometrylist: " .. err;
end
local atomics = {};
for iter=1,num_atomics,1 do
local atomic, err = rwReadAtomic(filePtr);
if not (atomic) then
return false, "failed to read atomic: " .. err;
end
atomics[iter] = atomic;
end
local extension, err = readExtensions(filePtr);
if not (extension) then
return false, "failed to read extension: " .. err;
end
-- TODO: link up geometries with atomics and their frames.
local dff = {};
dff.framelist = framelist;
dff.geomlist = geomlist;
dff.atomics = atomics;
return dff;
end