Repository navigation
Expand file tree
/
Copy pathgrid.py
More file actions
46 lines (39 loc) · 1.38 KB
/
Copy pathgrid.py
File metadata and controls
46 lines (39 loc) · 1.38 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
import ctypes
import os
import mmap
import random
voxels_x = 128
voxels_y = 128
voxels_z = 64
class voxel_double_buffer_t(ctypes.Structure):
_fields_ = [("buffers", ctypes.c_uint8 * voxels_z * voxels_x * voxels_y * 2),
("page", ctypes.c_uint8),
("bpc", ctypes.c_uint8),
("flags", ctypes.c_uint16),
("rpm", ctypes.c_uint16),
("uspf", ctypes.c_uint16)]
shm_fd = os.open("/dev/shm/vortex_double_buffer", os.O_RDWR)
shm_mm = mmap.mmap(shm_fd, ctypes.sizeof(voxel_double_buffer_t), mmap.MAP_SHARED, mmap.PROT_READ | mmap.PROT_WRITE)
buffer = voxel_double_buffer_t.from_buffer(shm_mm)
#buffer.bpc = 1
for z in range(voxels_z):
for x in range(voxels_x):
for y in range(voxels_y):
c = 0
if z == 0:
if ((x^y)&1) == 0:
c |= 0b00000010
if ((x^y)&2) == 0:
c |= 0b00010000
if ((x^y)&4) == 0:
c |= 0b10000000
if z == voxels_z / 2:
c = 0b10000000
if z == voxels_z - 1:
if ((x^y)&8) == 0:
c |= 0b10000000
else:
c |= 0b00010000
buffer.buffers[0][y][x][z] = c
buffer.buffers[1][y][x][z] = c
buffer.page = 1 - buffer.page