voxelengine 0.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- voxelengine-0.0.0/LICENCE +0 -0
- voxelengine-0.0.0/PKG-INFO +5 -0
- voxelengine-0.0.0/README.md +0 -0
- voxelengine-0.0.0/pyproject.toml +0 -0
- voxelengine-0.0.0/setup.cfg +4 -0
- voxelengine-0.0.0/voxelengine/__init__.py +201 -0
- voxelengine-0.0.0/voxelengine.egg-info/PKG-INFO +5 -0
- voxelengine-0.0.0/voxelengine.egg-info/SOURCES.txt +8 -0
- voxelengine-0.0.0/voxelengine.egg-info/dependency_links.txt +1 -0
- voxelengine-0.0.0/voxelengine.egg-info/top_level.txt +1 -0
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
from ursina import *
|
|
2
|
+
import ursina
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# -----------------------------
|
|
7
|
+
# APP START (FIRST)
|
|
8
|
+
# -----------------------------
|
|
9
|
+
|
|
10
|
+
app = Ursina(development_mode=False, fullscreen=False) # dev mode OFF
|
|
11
|
+
window.title = "voxel"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# -----------------------------
|
|
15
|
+
# VOXEL MAKER
|
|
16
|
+
# -----------------------------
|
|
17
|
+
|
|
18
|
+
class MakeVoxel:
|
|
19
|
+
@staticmethod
|
|
20
|
+
def blockFaces(
|
|
21
|
+
color=None,
|
|
22
|
+
width=1,
|
|
23
|
+
height=1,
|
|
24
|
+
sxpos=0,
|
|
25
|
+
sypos=0,
|
|
26
|
+
szpos=0,
|
|
27
|
+
texturefront=None,
|
|
28
|
+
textureback=None,
|
|
29
|
+
textureleft=None,
|
|
30
|
+
textureright=None,
|
|
31
|
+
textureup=None,
|
|
32
|
+
texturedown=None,
|
|
33
|
+
double_sided=True,
|
|
34
|
+
):
|
|
35
|
+
use_textures = all(
|
|
36
|
+
t is not None
|
|
37
|
+
for t in [
|
|
38
|
+
texturefront,
|
|
39
|
+
textureback,
|
|
40
|
+
textureleft,
|
|
41
|
+
textureright,
|
|
42
|
+
textureup,
|
|
43
|
+
texturedown,
|
|
44
|
+
]
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
if color is None and not use_textures:
|
|
48
|
+
raise ValueError("Provide either color OR all 6 textures.")
|
|
49
|
+
|
|
50
|
+
# Check texture paths
|
|
51
|
+
if use_textures:
|
|
52
|
+
for t in [
|
|
53
|
+
texturefront,
|
|
54
|
+
textureback,
|
|
55
|
+
textureleft,
|
|
56
|
+
textureright,
|
|
57
|
+
textureup,
|
|
58
|
+
texturedown,
|
|
59
|
+
]:
|
|
60
|
+
if not Path(t).exists():
|
|
61
|
+
print(f"⚠ Texture not found: {t}")
|
|
62
|
+
|
|
63
|
+
common = {
|
|
64
|
+
"model": "quad",
|
|
65
|
+
"scale": (width, height),
|
|
66
|
+
"double_sided": double_sided,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
face_data = [
|
|
70
|
+
("right", (0, 90, 0), (sxpos + 0.5, sypos, szpos), textureright),
|
|
71
|
+
("left", (0, -90, 0), (sxpos - 0.5, sypos, szpos), textureleft),
|
|
72
|
+
("up", (-90, 180, 0), (sxpos, sypos + 0.5, szpos), textureup),
|
|
73
|
+
("down", (90, 0, 0), (sxpos, sypos - 0.5, szpos), texturedown),
|
|
74
|
+
("front", (0, 0, 0), (sxpos, sypos, szpos + 0.5), texturefront),
|
|
75
|
+
("back", (0, 180, 0), (sxpos, sypos, szpos - 0.5), textureback),
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
faces = []
|
|
79
|
+
|
|
80
|
+
for facetype, rot, pos, tex in face_data:
|
|
81
|
+
kwargs = dict(common)
|
|
82
|
+
kwargs["rotation"] = rot
|
|
83
|
+
kwargs["position"] = pos
|
|
84
|
+
|
|
85
|
+
if use_textures:
|
|
86
|
+
kwargs["texture"] = ursina.load_texture(str(tex))
|
|
87
|
+
else:
|
|
88
|
+
kwargs["color"] = color
|
|
89
|
+
|
|
90
|
+
faces.append(Entity(**kwargs))
|
|
91
|
+
|
|
92
|
+
return tuple(faces)
|
|
93
|
+
# -----------------------------
|
|
94
|
+
# DATA STORAGE
|
|
95
|
+
# -----------------------------
|
|
96
|
+
|
|
97
|
+
building_blocks = []
|
|
98
|
+
ingredients = []
|
|
99
|
+
nature = []
|
|
100
|
+
technical_blocks = []
|
|
101
|
+
utility_blocks = []
|
|
102
|
+
voxels = []
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def voxelData(blockname=None, blocktype=None):
|
|
106
|
+
if blockname is None:
|
|
107
|
+
return
|
|
108
|
+
|
|
109
|
+
voxels.append(blockname)
|
|
110
|
+
|
|
111
|
+
if blocktype == "building blocks":
|
|
112
|
+
building_blocks.append(blockname)
|
|
113
|
+
elif blocktype == "ingredients":
|
|
114
|
+
ingredients.append(blockname)
|
|
115
|
+
elif blocktype == "nature":
|
|
116
|
+
nature.append(blockname)
|
|
117
|
+
elif blocktype == "technical blocks":
|
|
118
|
+
technical_blocks.append(blockname)
|
|
119
|
+
elif blocktype == "utility blocks":
|
|
120
|
+
utility_blocks.append(blockname)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
# -----------------------------
|
|
124
|
+
# VOXEL CREATOR
|
|
125
|
+
# -----------------------------
|
|
126
|
+
|
|
127
|
+
def makeVoxel2(
|
|
128
|
+
blockname=None,
|
|
129
|
+
blocktype=None,
|
|
130
|
+
texture1=None,
|
|
131
|
+
texture2=None,
|
|
132
|
+
texture3=None,
|
|
133
|
+
texture4=None,
|
|
134
|
+
texture5=None,
|
|
135
|
+
texture6=None,
|
|
136
|
+
sxpos=0,
|
|
137
|
+
sypos=0,
|
|
138
|
+
szpos=0,
|
|
139
|
+
):
|
|
140
|
+
if blockname and blocktype:
|
|
141
|
+
voxelData(blockname=blockname, blocktype=blocktype)
|
|
142
|
+
|
|
143
|
+
if all(t is not None for t in [texture1, texture2, texture3, texture4, texture5, texture6]):
|
|
144
|
+
return MakeVoxel.blockFaces(
|
|
145
|
+
texturefront=texture1,
|
|
146
|
+
textureback=texture2,
|
|
147
|
+
textureup=texture3,
|
|
148
|
+
texturedown=texture4,
|
|
149
|
+
textureright=texture5,
|
|
150
|
+
textureleft=texture6,
|
|
151
|
+
double_sided=True,
|
|
152
|
+
sxpos=sxpos,
|
|
153
|
+
sypos=sypos,
|
|
154
|
+
szpos=szpos,
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
return MakeVoxel.blockFaces(color=color.white, double_sided=True)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
# -----------------------------
|
|
161
|
+
# GRID GENERATOR
|
|
162
|
+
# -----------------------------
|
|
163
|
+
|
|
164
|
+
def generateBlockGrid(
|
|
165
|
+
size,
|
|
166
|
+
origin,
|
|
167
|
+
block,
|
|
168
|
+
block_name2=None,
|
|
169
|
+
block_type2=None,
|
|
170
|
+
texture1=None,
|
|
171
|
+
texture2=None,
|
|
172
|
+
texture3=None,
|
|
173
|
+
texture4=None,
|
|
174
|
+
texture5=None,
|
|
175
|
+
texture6=None,
|
|
176
|
+
):
|
|
177
|
+
ox, oy, oz = origin
|
|
178
|
+
|
|
179
|
+
for x in range(size):
|
|
180
|
+
for z in range(size):
|
|
181
|
+
makeVoxel2(
|
|
182
|
+
blockname=block_name2,
|
|
183
|
+
blocktype=block_type2,
|
|
184
|
+
texture1=texture1,
|
|
185
|
+
texture2=texture2,
|
|
186
|
+
texture3=texture3,
|
|
187
|
+
texture4=texture4,
|
|
188
|
+
texture5=texture5,
|
|
189
|
+
texture6=texture6,
|
|
190
|
+
sxpos=ox + x,
|
|
191
|
+
sypos=oy,
|
|
192
|
+
szpos=oz + z,
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
print(f"Generated a grid of {size}x{size}, of {block} blocks, starting at {origin}.")
|
|
196
|
+
|
|
197
|
+
# -----------------------------
|
|
198
|
+
# RUN APP
|
|
199
|
+
# -----------------------------
|
|
200
|
+
|
|
201
|
+
app.run()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
voxelengine
|