basilisk-engine 0.1.46__py3-none-any.whl → 0.1.47__py3-none-any.whl
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.
Potentially problematic release.
This version of basilisk-engine might be problematic. Click here for more details.
- basilisk/input/__init__.py +0 -0
- basilisk/input/mouse.py +62 -0
- basilisk/input/path.py +14 -0
- basilisk/render/image.py +15 -7
- basilisk/render/sky.py +2 -2
- basilisk/render/tempCodeRunnerFile.py +1 -0
- basilisk/shaders/bloom_frame.frag +25 -0
- {basilisk_engine-0.1.46.dist-info → basilisk_engine-0.1.47.dist-info}/METADATA +1 -1
- {basilisk_engine-0.1.46.dist-info → basilisk_engine-0.1.47.dist-info}/RECORD +11 -6
- {basilisk_engine-0.1.46.dist-info → basilisk_engine-0.1.47.dist-info}/WHEEL +0 -0
- {basilisk_engine-0.1.46.dist-info → basilisk_engine-0.1.47.dist-info}/top_level.txt +0 -0
|
File without changes
|
basilisk/input/mouse.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import pygame as pg
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Mouse():
|
|
5
|
+
def __init__(self, grab=True):
|
|
6
|
+
self.x, self.y = pg.mouse.get_pos()
|
|
7
|
+
self.buttons = pg.mouse.get_pressed()
|
|
8
|
+
self.previous_buttons = pg.mouse.get_pressed()
|
|
9
|
+
self.grab = grab
|
|
10
|
+
|
|
11
|
+
def update(self, events):
|
|
12
|
+
"""
|
|
13
|
+
Updates all mouse state variables.
|
|
14
|
+
Checks for mouse-related events.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
self.x, self.y = pg.mouse.get_pos()
|
|
18
|
+
self.previous_buttons = self.buttons
|
|
19
|
+
self.buttons = pg.mouse.get_pressed()
|
|
20
|
+
|
|
21
|
+
for event in events:
|
|
22
|
+
if event.type == pg.KEYUP:
|
|
23
|
+
if event.key == pg.K_ESCAPE and self.grab:
|
|
24
|
+
# Unlock mouse
|
|
25
|
+
pg.event.set_grab(False)
|
|
26
|
+
pg.mouse.set_visible(True)
|
|
27
|
+
if event.type == pg.MOUSEBUTTONUP and self.grab:
|
|
28
|
+
# Lock mouse
|
|
29
|
+
pg.event.set_grab(True)
|
|
30
|
+
pg.mouse.set_visible(False)
|
|
31
|
+
|
|
32
|
+
def set_pos(self, x, y):
|
|
33
|
+
"""Set the mouse position"""
|
|
34
|
+
pg.mouse.set_pos(x, y)
|
|
35
|
+
|
|
36
|
+
@property
|
|
37
|
+
def click(self): return self.buttons[0] and not self.previous_buttons[0]
|
|
38
|
+
@property
|
|
39
|
+
def left_click(self): return self.buttons[0] and not self.previous_buttons[0]
|
|
40
|
+
@property
|
|
41
|
+
def middle_click(self): return self.buttons[1] and not self.previous_buttons[1]
|
|
42
|
+
@property
|
|
43
|
+
def right_click(self): return self.buttons[2] and not self.previous_buttons[2]
|
|
44
|
+
@property
|
|
45
|
+
def left_down(self): return self.buttons[0]
|
|
46
|
+
@property
|
|
47
|
+
def middle_down(self): return self.buttons[1]
|
|
48
|
+
@property
|
|
49
|
+
def right_down(self): return self.buttons[2]
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def grab(self): return self._grab
|
|
53
|
+
|
|
54
|
+
@grab.setter
|
|
55
|
+
def grab(self, value):
|
|
56
|
+
self._grab = value
|
|
57
|
+
if self._grab:
|
|
58
|
+
pg.event.set_grab(True)
|
|
59
|
+
pg.mouse.set_visible(False)
|
|
60
|
+
else:
|
|
61
|
+
pg.event.set_grab(False)
|
|
62
|
+
pg.mouse.set_visible(True)
|
basilisk/input/path.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
# Credit for function: https://stackoverflow.com/questions/7674790/bundling-data-files-with-pyinstaller-onefile
|
|
6
|
+
def get_root():
|
|
7
|
+
""" Get absolute path to resource, works for dev and for PyInstaller """
|
|
8
|
+
try:
|
|
9
|
+
# PyInstaller creates a temp folder and stores path in _MEIPASS
|
|
10
|
+
base_path = sys._MEIPASS
|
|
11
|
+
except Exception:
|
|
12
|
+
base_path = os.path.abspath(".")
|
|
13
|
+
|
|
14
|
+
return base_path + '/basilisk'
|
basilisk/render/image.py
CHANGED
|
@@ -22,25 +22,29 @@ class Image():
|
|
|
22
22
|
texture: mgl.Texture | None=None
|
|
23
23
|
"""Texture of the image. Only created and retrived if needed by other module"""
|
|
24
24
|
|
|
25
|
-
def __init__(self, path: str | os.PathLike | pg.Surface | mgl.Texture) -> None:
|
|
25
|
+
def __init__(self, path: str | os.PathLike | pg.Surface | mgl.Texture, flip_x: bool=False, flip_y: bool=True) -> None:
|
|
26
26
|
"""
|
|
27
27
|
A basilisk image object that contains a moderngl texture
|
|
28
28
|
Args:
|
|
29
29
|
path: str | os.PathLike | pg.Surface
|
|
30
30
|
The string path to the image. Can also read a pygame surface
|
|
31
|
+
flip_x: bool=True
|
|
32
|
+
Flips the image vertically. Should be True for using the internal cube lmao
|
|
33
|
+
flip_y: bool=True
|
|
34
|
+
Flips the image vertically. Should be True for blender imports
|
|
31
35
|
"""
|
|
32
36
|
|
|
33
37
|
# Check if the user is loading a pygame surface
|
|
34
38
|
if isinstance(path, str) or isinstance(path, os.PathLike):
|
|
35
|
-
return self._from_path(path)
|
|
39
|
+
return self._from_path(path, flip_x, flip_y)
|
|
36
40
|
elif isinstance(path, pg.Surface):
|
|
37
|
-
return self._from_surface(path)
|
|
41
|
+
return self._from_surface(path, flip_x, flip_y)
|
|
38
42
|
elif isinstance(path, mgl.Texture):
|
|
39
|
-
return self._from_texture(path)
|
|
43
|
+
return self._from_texture(path, flip_x, flip_y)
|
|
40
44
|
|
|
41
45
|
raise TypeError(f'Invalid path type: {type(path)}. Expected a string or os.PathLike')
|
|
42
46
|
|
|
43
|
-
def _from_path(self, path: str | os.PathLike) -> None:
|
|
47
|
+
def _from_path(self, path: str | os.PathLike, flip_x: bool=False, flip_y: bool=True) -> None:
|
|
44
48
|
"""
|
|
45
49
|
Loads a basilisk image from a pygame surface
|
|
46
50
|
Args:
|
|
@@ -51,6 +55,8 @@ class Image():
|
|
|
51
55
|
|
|
52
56
|
# Load image
|
|
53
57
|
img = PIL_Image.open(path).convert('RGBA')
|
|
58
|
+
if flip_x: img = img.transpose(PIL_Image.FLIP_LEFT_RIGHT)
|
|
59
|
+
if flip_y: img = img.transpose(PIL_Image.FLIP_TOP_BOTTOM)
|
|
54
60
|
# Set the size in one of the size buckets
|
|
55
61
|
size_buckets = texture_sizes
|
|
56
62
|
self.size = size_buckets[np.argmin(np.array([abs(size - img.size[0]) for size in size_buckets]))]
|
|
@@ -61,11 +67,13 @@ class Image():
|
|
|
61
67
|
# Default index value (to be set by image handler)
|
|
62
68
|
self.index = glm.ivec2(1, 1)
|
|
63
69
|
|
|
64
|
-
def _from_surface(self, surf: pg.Surface) -> None:
|
|
70
|
+
def _from_surface(self, surf: pg.Surface, flip_x: bool=False, flip_y: bool=True) -> None:
|
|
65
71
|
"""
|
|
66
72
|
Loads a basilisk image from a pygame surface
|
|
67
73
|
Args:
|
|
68
74
|
"""
|
|
75
|
+
|
|
76
|
+
surf = pg.transform.flip(surf, flip_x, flip_y)
|
|
69
77
|
|
|
70
78
|
# Set the size in one of the size buckets
|
|
71
79
|
size_buckets = texture_sizes
|
|
@@ -77,7 +85,7 @@ class Image():
|
|
|
77
85
|
# Default index value (to be set by image handler)
|
|
78
86
|
self.index = glm.ivec2(1, 1)
|
|
79
87
|
|
|
80
|
-
def _from_texture(self, texture: mgl.Texture):
|
|
88
|
+
def _from_texture(self, texture: mgl.Texture, flip_x: bool=False, flip_y: bool=True):
|
|
81
89
|
"""
|
|
82
90
|
|
|
83
91
|
"""
|
basilisk/render/sky.py
CHANGED
|
@@ -26,11 +26,11 @@ class Sky:
|
|
|
26
26
|
"""
|
|
27
27
|
self.vao.render()
|
|
28
28
|
|
|
29
|
-
def write(self):
|
|
29
|
+
def write(self, target: ...=None):
|
|
30
30
|
# Write the texture cube to the sky shader
|
|
31
31
|
self.shader.bind(self.texture_cube, 'skyboxTexture', 8)
|
|
32
32
|
|
|
33
|
-
shader = self.
|
|
33
|
+
shader = target if target else self.scene.shader
|
|
34
34
|
if 'skyboxTexture' not in shader.uniforms: return
|
|
35
35
|
shader.bind(self.texture_cube, 'skyboxTexture', 8)
|
|
36
36
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
source[0][
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#version 330 core
|
|
2
|
+
|
|
3
|
+
out vec4 fragColor;
|
|
4
|
+
|
|
5
|
+
in vec2 uv;
|
|
6
|
+
|
|
7
|
+
uniform sampler2D screenTexture;
|
|
8
|
+
uniform sampler2D bloomTexture;
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
void main()
|
|
13
|
+
{
|
|
14
|
+
const float gamma = 2.2;
|
|
15
|
+
const float exposure = 1.2;
|
|
16
|
+
vec3 hdrColor = texture(screenTexture, uv).rgb + texture(bloomTexture, uv).rgb / 2;
|
|
17
|
+
|
|
18
|
+
// exposure tone mapping
|
|
19
|
+
vec3 mapped = vec3(1.0) - exp(-hdrColor * exposure);
|
|
20
|
+
// gamma correction
|
|
21
|
+
mapped = pow(mapped, vec3(1.0 / gamma));
|
|
22
|
+
|
|
23
|
+
fragColor = vec4(mapped, 1.0);
|
|
24
|
+
//fragColor = texture(screenTexture, uv) + texture(bloomTexture, uv) / 20000.0;
|
|
25
|
+
}
|
|
@@ -41,6 +41,9 @@ basilisk/generic/quat.py,sha256=gEqvQvNwx5K7e0zqY0TFTAFtNFSkOatleoP9HQQ-xyk,5102
|
|
|
41
41
|
basilisk/generic/quat_methods.py,sha256=SO18ush7pfeGUmncPy4i5nsab1e_zkQkY6zT1bAsSDY,234
|
|
42
42
|
basilisk/generic/raycast_result.py,sha256=waVmS9fYhLoz_G_DU2Mj7896rF0Xy_59JVGALq-kD7g,783
|
|
43
43
|
basilisk/generic/vec3.py,sha256=AtPSz2S1ZqAm-sZUz4phB09hgFxMIsJnQdU1wmxiOBw,5137
|
|
44
|
+
basilisk/input/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
45
|
+
basilisk/input/mouse.py,sha256=waXJLIyka4IVe3W2WH5SNNxiOQRouYo3NxafP3fg0qg,1937
|
|
46
|
+
basilisk/input/path.py,sha256=GpFYe3Uu6VZAuKh9Q2nQM1H8immiCp_snznLG9FKcvU,441
|
|
44
47
|
basilisk/input_output/IO_handler.py,sha256=DDQEjmIHzWo99rk1riT_QJKGQ5F8-lOilmchRXeQuYI,2822
|
|
45
48
|
basilisk/input_output/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
46
49
|
basilisk/input_output/clock.py,sha256=GHTagpPyPlLjWyonaHV8M-nPCcdHcHL4JobbuUOxYf0,1462
|
|
@@ -74,7 +77,7 @@ basilisk/render/chunk.py,sha256=WZ5cC-FPndbkdWEQLQ0v9tBvybjbbLMjXLJC2mYnXfA,2927
|
|
|
74
77
|
basilisk/render/chunk_handler.py,sha256=-Hozyus67mgJ8fTWx3fsLezFVt3W4d-I0I1ai29odWA,6405
|
|
75
78
|
basilisk/render/frame.py,sha256=EIdqo49ztcNCqB4E7PxkcwgUMv9BDdl_RsNKKTw8P2Y,4128
|
|
76
79
|
basilisk/render/framebuffer.py,sha256=8QVpnh0mPfbtkSF9McqmlK9i77Q-hpjWmvx8Ff73vp8,6871
|
|
77
|
-
basilisk/render/image.py,sha256=
|
|
80
|
+
basilisk/render/image.py,sha256=xqBSYqV5iy_QDiu8cs_KzrBE49NTMPim_7qInKaHJGk,4607
|
|
78
81
|
basilisk/render/image_handler.py,sha256=K3cTm9GNVCT0GfN874AqNRGsRfrTr8VZJbNO7J1tXAY,4183
|
|
79
82
|
basilisk/render/light.py,sha256=SOOh5zAGUCgQdJjWb5MlJgtvdxkEV8AWqQ4P93bJj2g,3783
|
|
80
83
|
basilisk/render/light_handler.py,sha256=gvg4OhDMy8dZg5XNcOZB4_1G2uE1gBFRxlBeoG3l3vM,2104
|
|
@@ -83,11 +86,13 @@ basilisk/render/material_handler.py,sha256=mNgLNJCFYGqMwr0qZQiZ8mMwEXqvFgBMlHBFb
|
|
|
83
86
|
basilisk/render/post_process.py,sha256=QAIwNccycEJqA1UVGKUqwVus11sJX9qm3Mjl0gdGYSo,6519
|
|
84
87
|
basilisk/render/shader.py,sha256=xh2p8kPFCPD479wyf6X3NUsgGfy3sbnSypNqFd8k83c,4870
|
|
85
88
|
basilisk/render/shader_handler.py,sha256=Tk-wbejg7UhXyq1c9pHjb-590zqAakNLCZu2ZbKCCAs,3260
|
|
86
|
-
basilisk/render/sky.py,sha256=
|
|
89
|
+
basilisk/render/sky.py,sha256=10kPdEpo8l7s8Iz-XP0W9_CXAHTANHZ3BRjzkdPVTnQ,4786
|
|
90
|
+
basilisk/render/tempCodeRunnerFile.py,sha256=ep1eVZzUd30SDCNE5l3OJsqp2fW2LEXrjYGW31AMWgw,10
|
|
87
91
|
basilisk/shaders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
88
92
|
basilisk/shaders/batch.frag,sha256=F_rGIQaY5jfep3WTCNY9Q3uLfu2lNuUSZZR7GZy_HCk,9514
|
|
89
93
|
basilisk/shaders/batch.vert,sha256=LYzcqcwCyCpnxF5V-ilx79HU2cYz66hylBmZChcVmos,5555
|
|
90
94
|
basilisk/shaders/bloom_downsample.frag,sha256=rIQTnBkSNiTF57D-yvWwQv_3_PmxznquHdlma8ua8Uw,685
|
|
95
|
+
basilisk/shaders/bloom_frame.frag,sha256=Y0m8DnQKz3G9FKq7VjCGrVXZw2vSigyGX7-tlxZN0lE,567
|
|
91
96
|
basilisk/shaders/bloom_upsample.frag,sha256=Pe1AupjM2OCMieW7oEYHoEx2LhbPtbpwcylruF5Ntm4,1156
|
|
92
97
|
basilisk/shaders/crt.frag,sha256=ss6xhXwwOH9bXEhqyim--K4o1BOo1Wwq6tGAwjpRHEQ,1043
|
|
93
98
|
basilisk/shaders/draw.frag,sha256=rcPmGMh850M1ypcFNlJCyFWxfZ739lVNl6OPTxPIYIE,605
|
|
@@ -104,7 +109,7 @@ basilisk/shaders/particle.frag,sha256=IskhyXelHs9GqABKwTYSwooWL0nP-nkmXl6a5iT6Q3
|
|
|
104
109
|
basilisk/shaders/particle.vert,sha256=oiBz6S_2dzqioAhyzVYT1ZKOED4h4R6IoP-UJ8KRHhU,3227
|
|
105
110
|
basilisk/shaders/sky.frag,sha256=dJRdSbg16aZYYjxdoG1spVQRIVBGNVdyX0rqp4ER6v8,556
|
|
106
111
|
basilisk/shaders/sky.vert,sha256=oAnrknEgsd9MawE_zx8P0u9nUSFEBYBg5ykBmWpqZ_g,332
|
|
107
|
-
basilisk_engine-0.1.
|
|
108
|
-
basilisk_engine-0.1.
|
|
109
|
-
basilisk_engine-0.1.
|
|
110
|
-
basilisk_engine-0.1.
|
|
112
|
+
basilisk_engine-0.1.47.dist-info/METADATA,sha256=rN-PmGy9nCCH8qq33qX1nHSJFMczgGvqso2pd5sbOog,3793
|
|
113
|
+
basilisk_engine-0.1.47.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
114
|
+
basilisk_engine-0.1.47.dist-info/top_level.txt,sha256=enlSYSf7CUyAly1jmUCNNGInTbaFUjGk4SKwyckZQkw,9
|
|
115
|
+
basilisk_engine-0.1.47.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|