basilisk-engine 0.1.2__py3-none-any.whl → 0.1.4__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/__init__.py +2 -1
- basilisk/collisions/collider.py +16 -4
- basilisk/collisions/collider_handler.py +8 -11
- basilisk/collisions/narrow/dataclasses.py +7 -1
- basilisk/collisions/narrow/helper.py +2 -2
- basilisk/draw/draw_handler.py +6 -36
- basilisk/engine.py +6 -2
- basilisk/generic/input_validation.py +41 -2
- basilisk/generic/raycast_result.py +24 -0
- basilisk/input/mouse.py +2 -0
- basilisk/input/path.py +14 -0
- basilisk/mesh/mesh_from_data.py +0 -2
- basilisk/nodes/helper.py +29 -0
- basilisk/nodes/node.py +109 -45
- basilisk/nodes/node_handler.py +9 -32
- basilisk/particles/particle_handler.py +11 -2
- basilisk/render/camera.py +6 -1
- basilisk/render/frame.py +48 -131
- basilisk/render/framebuffer.py +106 -0
- basilisk/render/image.py +22 -10
- basilisk/render/post_process.py +133 -0
- basilisk/scene.py +76 -30
- basilisk/shaders/crt.frag +32 -0
- {basilisk_engine-0.1.2.dist-info → basilisk_engine-0.1.4.dist-info}/METADATA +1 -1
- {basilisk_engine-0.1.2.dist-info → basilisk_engine-0.1.4.dist-info}/RECORD +27 -21
- {basilisk_engine-0.1.2.dist-info → basilisk_engine-0.1.4.dist-info}/WHEEL +0 -0
- {basilisk_engine-0.1.2.dist-info → basilisk_engine-0.1.4.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import moderngl as mgl
|
|
2
|
+
from PIL import Image
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Framebuffer:
|
|
7
|
+
engine: ...
|
|
8
|
+
"""Reference to the parent engine"""
|
|
9
|
+
fbo: mgl.Framebuffer = None
|
|
10
|
+
"""The core framebuffer the object provides abstraction for."""
|
|
11
|
+
texture: mgl.Texture = None
|
|
12
|
+
"""The color texture of the framebuffer"""
|
|
13
|
+
depth: mgl.Texture = None
|
|
14
|
+
"""The depth texture of the framebuffer"""
|
|
15
|
+
size: tuple[int]
|
|
16
|
+
"""The dimensions of the framebuffer (x, y)"""
|
|
17
|
+
|
|
18
|
+
def __init__(self, engine, size: tuple[int]=None, components: int=4, filter=(mgl.LINEAR, mgl.LINEAR)) -> None:
|
|
19
|
+
"""
|
|
20
|
+
Abstraction to the mgl framebuffer
|
|
21
|
+
Args:
|
|
22
|
+
engine: mgl.Engine:
|
|
23
|
+
The parent engine
|
|
24
|
+
size: tuple[int]:
|
|
25
|
+
The dimensions of the framebuffer (x, y)
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
# Set attributes
|
|
29
|
+
self.engine = engine
|
|
30
|
+
self.ctx = engine.ctx
|
|
31
|
+
self.size = size if size else engine.win_size
|
|
32
|
+
self.components = components
|
|
33
|
+
|
|
34
|
+
# Create the fbo
|
|
35
|
+
self.texture = self.ctx.texture(self.size, components=self.components)
|
|
36
|
+
self.depth = self.ctx.depth_texture(self.size)
|
|
37
|
+
self.fbo = self.ctx.framebuffer([self.texture], self.depth)
|
|
38
|
+
|
|
39
|
+
print()
|
|
40
|
+
|
|
41
|
+
self.filter = filter
|
|
42
|
+
|
|
43
|
+
def use(self) -> None:
|
|
44
|
+
"""
|
|
45
|
+
Select this framebuffer for use
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
self.fbo.use()
|
|
49
|
+
|
|
50
|
+
def clear(self) -> None:
|
|
51
|
+
"""
|
|
52
|
+
Clear all data currently in the textures (set to black)
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
self.fbo.clear()
|
|
56
|
+
|
|
57
|
+
def save(self, destination: str=None) -> None:
|
|
58
|
+
"""
|
|
59
|
+
Saves the frame as an image to the given file destination
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
path = destination if destination else 'screenshot'
|
|
63
|
+
|
|
64
|
+
data = self.fbo.read(components=3, alignment=1)
|
|
65
|
+
img = Image.frombytes('RGB', self.size, data).transpose(Image.FLIP_TOP_BOTTOM)
|
|
66
|
+
img.save(f'{path}.png')
|
|
67
|
+
|
|
68
|
+
def resize(self, size: tuple[int]=None) -> None:
|
|
69
|
+
"""
|
|
70
|
+
Resize the buffer to the given size. None for window size
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
# Release old memory
|
|
74
|
+
self.__del__()
|
|
75
|
+
|
|
76
|
+
# Set/get size attribute
|
|
77
|
+
self.size = size if size else self.engine.win_size
|
|
78
|
+
|
|
79
|
+
# Create the fbo
|
|
80
|
+
self.texture = self.ctx.texture(self.size, components=self.components)
|
|
81
|
+
self.depth = self.ctx.depth_texture(self.size)
|
|
82
|
+
self.fbo = self.ctx.framebuffer([self.texture], self.depth)
|
|
83
|
+
|
|
84
|
+
self.filter = self._filter
|
|
85
|
+
|
|
86
|
+
@property
|
|
87
|
+
def data(self):
|
|
88
|
+
return self.fbo.read(components=3, alignment=1)
|
|
89
|
+
|
|
90
|
+
@property
|
|
91
|
+
def filter(self):
|
|
92
|
+
return self.texture.filter
|
|
93
|
+
|
|
94
|
+
@filter.setter
|
|
95
|
+
def filter(self, value):
|
|
96
|
+
self._filter = value
|
|
97
|
+
self.texture.filter = value
|
|
98
|
+
|
|
99
|
+
def __repr__(self) -> str:
|
|
100
|
+
return f'<bsk.Framebuffer | size: {self.size}>'
|
|
101
|
+
|
|
102
|
+
def __del__(self) -> None:
|
|
103
|
+
# Release any existing memory in case of a resize
|
|
104
|
+
if self.texture: self.texture.release()
|
|
105
|
+
if self.depth: self.depth.release()
|
|
106
|
+
if self.fbo: self.fbo.release()
|
basilisk/render/image.py
CHANGED
|
@@ -20,7 +20,7 @@ class Image():
|
|
|
20
20
|
size: int
|
|
21
21
|
"""The width and height in pixels of the image"""
|
|
22
22
|
|
|
23
|
-
def __init__(self, path: str | os.PathLike | pg.Surface) -> None:
|
|
23
|
+
def __init__(self, path: str | os.PathLike | pg.Surface | mgl.Texture) -> None:
|
|
24
24
|
"""
|
|
25
25
|
A basilisk image object that contains a moderngl texture
|
|
26
26
|
Args:
|
|
@@ -29,18 +29,24 @@ class Image():
|
|
|
29
29
|
"""
|
|
30
30
|
|
|
31
31
|
# Check if the user is loading a pygame surface
|
|
32
|
-
if isinstance(path,
|
|
33
|
-
self.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
if isinstance(path, str) or isinstance(path, os.PathLike):
|
|
33
|
+
return self._from_path(path)
|
|
34
|
+
elif isinstance(path, pg.Surface):
|
|
35
|
+
return self._from_surfaces(path)
|
|
36
|
+
elif isinstance(path, mgl.Texture):
|
|
37
|
+
return self._from_texture(path)
|
|
38
|
+
|
|
39
|
+
raise TypeError(f'Invalid path type: {type(path)}. Expected a string or os.PathLike')
|
|
39
40
|
|
|
41
|
+
def _from_path(self, path: str | os.PathLike) -> None:
|
|
42
|
+
"""
|
|
43
|
+
Loads a basilisk image from a pygame surface
|
|
44
|
+
Args:
|
|
45
|
+
"""
|
|
46
|
+
|
|
40
47
|
# Get name from path
|
|
41
48
|
self.name = path.split('/')[-1].split('\\')[-1].split('.')[0]
|
|
42
49
|
|
|
43
|
-
# Set the texture
|
|
44
50
|
# Load image
|
|
45
51
|
img = PIL_Image.open(path).convert('RGBA')
|
|
46
52
|
# Set the size in one of the size buckets
|
|
@@ -53,7 +59,7 @@ class Image():
|
|
|
53
59
|
# Default index value (to be set by image handler)
|
|
54
60
|
self.index = glm.ivec2(1, 1)
|
|
55
61
|
|
|
56
|
-
def
|
|
62
|
+
def _from_surface(self, surf: pg.Surface) -> None:
|
|
57
63
|
"""
|
|
58
64
|
Loads a basilisk image from a pygame surface
|
|
59
65
|
Args:
|
|
@@ -69,6 +75,12 @@ class Image():
|
|
|
69
75
|
# Default index value (to be set by image handler)
|
|
70
76
|
self.index = glm.ivec2(1, 1)
|
|
71
77
|
|
|
78
|
+
def _from_texture(self, texture: mgl.Texture):
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
"""
|
|
82
|
+
...
|
|
83
|
+
|
|
72
84
|
def __repr__(self) -> str:
|
|
73
85
|
"""
|
|
74
86
|
Returns a string representation of the object
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import moderngl as mgl
|
|
3
|
+
from .shader import Shader
|
|
4
|
+
from .image import Image
|
|
5
|
+
from .framebuffer import Framebuffer
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class PostProcess:
|
|
9
|
+
engine: ...
|
|
10
|
+
"""Reference to the parent engine"""
|
|
11
|
+
ctx: mgl.Context
|
|
12
|
+
"""Reference to the parent context"""
|
|
13
|
+
shader: Shader
|
|
14
|
+
"""Shader object used by the post process"""
|
|
15
|
+
vao: mgl.VertexArray
|
|
16
|
+
"""Screenspace render vao"""
|
|
17
|
+
|
|
18
|
+
def __init__(self, engine, shader_path: str=None, size: tuple=None, components: int=4, filter=(mgl.LINEAR, mgl.LINEAR)) -> None:
|
|
19
|
+
"""
|
|
20
|
+
Object to apply post processing to a texture
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
# Reference attributes
|
|
24
|
+
self.engine = engine
|
|
25
|
+
self.ctx = engine.ctx
|
|
26
|
+
|
|
27
|
+
# Size of the destination
|
|
28
|
+
self.size = size if size else engine.win_size
|
|
29
|
+
self.components = components
|
|
30
|
+
|
|
31
|
+
# Load default fragment if none given
|
|
32
|
+
if not (isinstance(shader_path, str) or isinstance(shader_path, type(None))):
|
|
33
|
+
raise ValueError(f'PostProces.apply: Invalid post process source type {type(shader_path)}. Expected string path destination of fragment shader.')
|
|
34
|
+
frag = shader_path if shader_path else self.engine.root + f'/shaders/frame.frag'
|
|
35
|
+
|
|
36
|
+
# Load Shaders
|
|
37
|
+
self.shader = Shader(self.engine, self.engine.root + f'/shaders/frame.vert', frag)
|
|
38
|
+
self.engine.scene.shader_handler.add(self.shader)
|
|
39
|
+
|
|
40
|
+
# Load VAO
|
|
41
|
+
self.vbo = self.ctx.buffer(np.array([[-1, -1, 0, 0, 0], [1, -1, 0, 1, 0], [1, 1, 0, 1, 1], [-1, 1, 0, 0, 1], [-1, -1, 0, 0, 0], [1, 1, 0, 1, 1]], dtype='f4'))
|
|
42
|
+
self.vao = self.ctx.vertex_array(self.shader.program, [(self.vbo, '3f 2f', 'in_position', 'in_uv')], skip_errors=True)
|
|
43
|
+
|
|
44
|
+
# Temporary render destination
|
|
45
|
+
self.fbo = Framebuffer(engine, self.size, components)
|
|
46
|
+
|
|
47
|
+
# Filter settings
|
|
48
|
+
self.filter = filter
|
|
49
|
+
self.fbo.texture.filter = self.filter
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def apply(self, source: mgl.Texture | Image | Framebuffer, destination: mgl.Texture | Image | Framebuffer=None) -> mgl.Texture | Image | Framebuffer:
|
|
53
|
+
"""
|
|
54
|
+
Applies a post process shader to a texture source.
|
|
55
|
+
Returns the modified texture or renders to the destination if given
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
if isinstance(source, Framebuffer): return self._apply_to_framebuffer(source, destination)
|
|
59
|
+
elif isinstance(source, mgl.Texture): return self._apply_to_texture(source, destination)
|
|
60
|
+
elif isinstance(source, Image): return self._apply_to_image(source, destination)
|
|
61
|
+
|
|
62
|
+
raise ValueError(f'PostProces.apply: Invalid postprocess source type {type(source)}')
|
|
63
|
+
|
|
64
|
+
def _render_post_process(self, source: mgl.Texture):
|
|
65
|
+
# Clear and use the fbo as a render target
|
|
66
|
+
self.fbo.use()
|
|
67
|
+
self.fbo.clear()
|
|
68
|
+
|
|
69
|
+
# Load the source texture to the shader
|
|
70
|
+
self.shader.program['screenTexture'] = 0
|
|
71
|
+
source.use(location=0)
|
|
72
|
+
|
|
73
|
+
# Apply the post process
|
|
74
|
+
self.vao.render()
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _apply_to_framebuffer(self, source: Framebuffer, detination: Framebuffer=None) -> Framebuffer:
|
|
78
|
+
"""
|
|
79
|
+
Applies a post process to a bsk.Framebuffer
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
# Create a blank framebuffer
|
|
83
|
+
if not detination:
|
|
84
|
+
fbo = Framebuffer(self.engine, self.size, self.components)
|
|
85
|
+
old_filter = None
|
|
86
|
+
fbo.texture.filter = self.filter
|
|
87
|
+
else:
|
|
88
|
+
fbo = detination
|
|
89
|
+
old_filter = fbo.filter
|
|
90
|
+
fbo.texture.filter = self.filter
|
|
91
|
+
|
|
92
|
+
# Load the source texture to the shader
|
|
93
|
+
self.shader.program['screenTexture'] = 0
|
|
94
|
+
source.texture.use(location=0)
|
|
95
|
+
|
|
96
|
+
fbo.use()
|
|
97
|
+
fbo.clear()
|
|
98
|
+
# Apply the post process
|
|
99
|
+
self.vao.render()
|
|
100
|
+
|
|
101
|
+
# Reset filter if needed
|
|
102
|
+
if old_filter: fbo.texture.filter = old_filter
|
|
103
|
+
|
|
104
|
+
# Return the fbo for the user
|
|
105
|
+
return fbo
|
|
106
|
+
|
|
107
|
+
def _apply_to_texture(self, source: mgl.Texture, destination: mgl.Texture) -> mgl.Texture:
|
|
108
|
+
"""
|
|
109
|
+
Applies a post process to a mgl.Texture
|
|
110
|
+
"""
|
|
111
|
+
|
|
112
|
+
# Render the post processs with the given texture
|
|
113
|
+
self._render_post_process(source)
|
|
114
|
+
|
|
115
|
+
# Make a deep copy of the modified texture
|
|
116
|
+
texture = self.ctx.texture(self.fbo.size, self.fbo.components, self.fbo.data)
|
|
117
|
+
|
|
118
|
+
return texture
|
|
119
|
+
|
|
120
|
+
def _apply_to_image(self, source: Image, destination: Image) -> Image:
|
|
121
|
+
"""
|
|
122
|
+
Applies a post process to a bsk.Image
|
|
123
|
+
"""
|
|
124
|
+
|
|
125
|
+
# Create a texture from the image data
|
|
126
|
+
texture = self.ctx.texture(self.fbo.size, self.fbo.components, source.data)
|
|
127
|
+
|
|
128
|
+
# Render the post processs with the given texture
|
|
129
|
+
self._render_post_process(source)
|
|
130
|
+
|
|
131
|
+
# Make an image from the texture
|
|
132
|
+
image = Image()
|
|
133
|
+
return image
|
basilisk/scene.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import moderngl as mgl
|
|
2
2
|
import glm
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
from .mesh.mesh import Mesh
|
|
5
5
|
from .render.material import Material
|
|
6
|
+
from .render.shader_handler import ShaderHandler
|
|
6
7
|
from .render.material_handler import MaterialHandler
|
|
7
8
|
from .render.light_handler import LightHandler
|
|
8
9
|
from .render.camera import Camera, FreeCamera
|
|
@@ -15,6 +16,8 @@ from .render.frame import Frame
|
|
|
15
16
|
from .particles.particle_handler import ParticleHandler
|
|
16
17
|
from .nodes.node import Node
|
|
17
18
|
from .generic.collisions import moller_trumbore
|
|
19
|
+
from .generic.raycast_result import RaycastResult
|
|
20
|
+
from .render.post_process import PostProcess
|
|
18
21
|
|
|
19
22
|
class Scene():
|
|
20
23
|
engine: any
|
|
@@ -43,11 +46,13 @@ class Scene():
|
|
|
43
46
|
"""
|
|
44
47
|
Updates the physics and in the scene
|
|
45
48
|
"""
|
|
46
|
-
|
|
47
|
-
self.node_handler.update()
|
|
48
49
|
self.particle.update()
|
|
49
50
|
self.camera.update()
|
|
50
|
-
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
self.node_handler.update()
|
|
54
|
+
if self.engine.delta_time < 0.5: # TODO this will cause physics to slow down when on low frame rate, this is probabl;y acceptable
|
|
55
|
+
self.collider_handler.resolve_collisions()
|
|
51
56
|
|
|
52
57
|
def render(self) -> None:
|
|
53
58
|
"""
|
|
@@ -64,42 +69,68 @@ class Scene():
|
|
|
64
69
|
if self.engine.headless: return
|
|
65
70
|
self.frame.render()
|
|
66
71
|
|
|
67
|
-
def add(self,
|
|
72
|
+
def add(self, *objects: Node | None) -> None | Node | list:
|
|
68
73
|
"""
|
|
69
|
-
Adds
|
|
74
|
+
Adds the given object(s) to the scene. Can pass in any scene objects:
|
|
70
75
|
Argument overloads:
|
|
71
76
|
object: Node - Adds the given node to the scene.
|
|
72
77
|
"""
|
|
73
78
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return self.node_handler.add(bsk_object)
|
|
80
|
-
# Light
|
|
79
|
+
# List of all return values for the added objects
|
|
80
|
+
returns = []
|
|
81
|
+
|
|
82
|
+
# Loop through all objects passed in
|
|
83
|
+
for bsk_object in objects:
|
|
81
84
|
|
|
82
|
-
|
|
85
|
+
# Considered well defined behavior to add None
|
|
86
|
+
if isinstance(bsk_object, type(None)):
|
|
87
|
+
continue
|
|
83
88
|
|
|
84
|
-
|
|
85
|
-
|
|
89
|
+
# Add a node to the scene
|
|
90
|
+
elif isinstance(bsk_object, Node):
|
|
91
|
+
returns.append(self.node_handler.add(bsk_object)); continue
|
|
92
|
+
|
|
93
|
+
# Add a node to the scene
|
|
94
|
+
elif isinstance(bsk_object, PostProcess):
|
|
95
|
+
returns.append(self.frame.add_post_process(bsk_object)); continue
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
# Recived incompatable type
|
|
99
|
+
else:
|
|
100
|
+
raise ValueError(f'scene.add: Incompatable object add type {type(bsk_object)}')
|
|
86
101
|
|
|
87
|
-
|
|
102
|
+
# Return based on what the user passed in
|
|
103
|
+
if not returns: return None
|
|
104
|
+
if len(returns) == 1: return returns[0]
|
|
105
|
+
return returns
|
|
88
106
|
|
|
89
|
-
def remove(self,
|
|
107
|
+
def remove(self, *objects: Node | None) -> None | Node | list:
|
|
90
108
|
"""
|
|
91
109
|
Removes the given baskilsk object from the scene
|
|
92
110
|
"""
|
|
93
111
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
112
|
+
# List of all return values for the added objects
|
|
113
|
+
returns = []
|
|
114
|
+
|
|
115
|
+
# Loop through all objects passed in
|
|
116
|
+
for bsk_object in objects:
|
|
117
|
+
|
|
118
|
+
# Considered well defined behavior to remove None
|
|
119
|
+
if isinstance(bsk_object, type(None)):
|
|
120
|
+
continue
|
|
101
121
|
|
|
102
|
-
|
|
122
|
+
# Remove a node from the scene
|
|
123
|
+
elif isinstance(bsk_object, Node):
|
|
124
|
+
returns.append(self.node_handler.remove(bsk_object)); continue
|
|
125
|
+
|
|
126
|
+
# Recived incompatable type
|
|
127
|
+
else:
|
|
128
|
+
raise ValueError(f'scene.remove: Incompatable object remove type {type(bsk_object)}')
|
|
129
|
+
|
|
130
|
+
# Return based on what the user passed in
|
|
131
|
+
if not returns: return None
|
|
132
|
+
if len(returns) == 1: return returns[0]
|
|
133
|
+
return returns
|
|
103
134
|
|
|
104
135
|
def set_engine(self, engine: any) -> None:
|
|
105
136
|
"""
|
|
@@ -121,9 +152,10 @@ class Scene():
|
|
|
121
152
|
self.frame = Frame(self)
|
|
122
153
|
self.sky = Sky(self.engine)
|
|
123
154
|
|
|
124
|
-
def raycast(self, position: glm.vec3=None, forward: glm.vec3=None, max_distance: float=1e5, has_collisions: bool=None, has_physics: bool=None, tags: list[str]=[]) ->
|
|
155
|
+
def raycast(self, position: glm.vec3=None, forward: glm.vec3=None, max_distance: float=1e5, has_collisions: bool=None, has_physics: bool=None, tags: list[str]=[]) -> RaycastResult:
|
|
125
156
|
"""
|
|
126
|
-
Ray cast from any posiiton and forward vector and returns the nearest node.
|
|
157
|
+
Ray cast from any posiiton and forward vector and returns a RaycastResult eith the nearest node.
|
|
158
|
+
If no position or forward is given, uses the scene camera's current position and forward
|
|
127
159
|
"""
|
|
128
160
|
if not position: position = self.camera.position
|
|
129
161
|
if not forward: forward = self.camera.forward
|
|
@@ -167,9 +199,9 @@ class Scene():
|
|
|
167
199
|
best_point = intersection
|
|
168
200
|
best_node = node
|
|
169
201
|
|
|
170
|
-
return best_node, best_point
|
|
202
|
+
return RaycastResult(best_node, best_point)
|
|
171
203
|
|
|
172
|
-
def raycast_mouse(self, position: tuple[int, int] | glm.vec2, max_distance: float=1e5, has_collisions: bool=None, has_pshyics: bool=None, tags: list[str]=[]) ->
|
|
204
|
+
def raycast_mouse(self, position: tuple[int, int] | glm.vec2, max_distance: float=1e5, has_collisions: bool=None, has_pshyics: bool=None, tags: list[str]=[]) -> RaycastResult:
|
|
173
205
|
"""
|
|
174
206
|
Ray casts from the mouse position with respect to the camera. Returns the nearest node that was clicked, if none was clicked, returns None.
|
|
175
207
|
"""
|
|
@@ -189,11 +221,25 @@ class Scene():
|
|
|
189
221
|
has_physics=has_pshyics,
|
|
190
222
|
tags=tags
|
|
191
223
|
)
|
|
224
|
+
|
|
225
|
+
def get(self, position: glm.vec3=None, scale: glm.vec3=None, rotation: glm.quat=None, forward: glm.vec3=None, mesh: Mesh=None, material: Material=None, velocity: glm.vec3=None, rotational_velocity: glm.quat=None, physics: bool=None, mass: float=None, collisions: bool=None, static_friction: float=None, kinetic_friction: float=None, elasticity: float=None, collision_group: float=None, name: str=None, tags: list[str]=None,static: bool=None) -> Node:
|
|
226
|
+
"""
|
|
227
|
+
Returns the first node with the given traits
|
|
228
|
+
"""
|
|
229
|
+
self.node_handler.get(position, scale, rotation, forward, mesh, material, velocity, rotational_velocity, physics, mass, collisions, static_friction, kinetic_friction, elasticity, collision_group, name, tags, static)
|
|
230
|
+
|
|
231
|
+
def get_all(self, position: glm.vec3=None, scale: glm.vec3=None, rotation: glm.quat=None, forward: glm.vec3=None, mesh: Mesh=None, material: Material=None, velocity: glm.vec3=None, rotational_velocity: glm.quat=None, physics: bool=None, mass: float=None, collisions: bool=None, static_friction: float=None, kinetic_friction: float=None, elasticity: float=None, collision_group: float=None, name: str=None, tags: list[str]=None,static: bool=None) -> list[Node]:
|
|
232
|
+
"""
|
|
233
|
+
Returns all nodes with the given traits
|
|
234
|
+
"""
|
|
235
|
+
self.node_handler.get_all(position, scale, rotation, forward, mesh, material, velocity, rotational_velocity, physics, mass, collisions, static_friction, kinetic_friction, elasticity, collision_group, name, tags, static)
|
|
192
236
|
|
|
193
237
|
@property
|
|
194
238
|
def camera(self): return self._camera
|
|
195
239
|
@property
|
|
196
240
|
def sky(self): return self._sky
|
|
241
|
+
@property
|
|
242
|
+
def nodes(self): return self.node_handler.nodes
|
|
197
243
|
|
|
198
244
|
@camera.setter
|
|
199
245
|
def camera(self, value: Camera):
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#version 330 core
|
|
2
|
+
|
|
3
|
+
out vec4 fragColor;
|
|
4
|
+
|
|
5
|
+
in vec2 uv;
|
|
6
|
+
|
|
7
|
+
uniform sampler2D screenTexture;
|
|
8
|
+
|
|
9
|
+
float warp = 0.75; // simulate curvature of CRT monitor
|
|
10
|
+
float scan = 0.75; // simulate darkness between scanlines
|
|
11
|
+
|
|
12
|
+
void main(){
|
|
13
|
+
// squared distance from center
|
|
14
|
+
vec2 crt_uv = uv;
|
|
15
|
+
vec2 dc = abs(0.5-uv);
|
|
16
|
+
dc *= dc;
|
|
17
|
+
|
|
18
|
+
// warp the fragment coordinates
|
|
19
|
+
crt_uv.x -= 0.5; crt_uv.x *= 1.0+(dc.y*(0.3*warp)); crt_uv.x += 0.5;
|
|
20
|
+
crt_uv.y -= 0.5; crt_uv.y *= 1.0+(dc.x*(0.4*warp)); crt_uv.y += 0.5;
|
|
21
|
+
|
|
22
|
+
// sample inside boundaries, otherwise set to black
|
|
23
|
+
if (crt_uv.y > 1.0 || crt_uv.x < 0.0 || crt_uv.x > 1.0 || crt_uv.y < 0.0) {
|
|
24
|
+
fragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
// determine if we are drawing in a scanline
|
|
28
|
+
float apply = abs(sin(crt_uv.y * 300)*0.5*scan);
|
|
29
|
+
//sample the texture
|
|
30
|
+
fragColor = vec4(mix(texture(screenTexture, crt_uv).rgb,vec3(0.0), apply), 1.0);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -1,58 +1,61 @@
|
|
|
1
|
-
basilisk/__init__.py,sha256=
|
|
1
|
+
basilisk/__init__.py,sha256=NuCTELN2mKVpKCqDt6n2ZEVnNYawRRT_a2-TyUERrRQ,468
|
|
2
2
|
basilisk/config.py,sha256=ynTRlX633DGoEtZOeAK8KNJF6offV3k3XFD7cia3Keg,61
|
|
3
|
-
basilisk/engine.py,sha256=
|
|
4
|
-
basilisk/scene.py,sha256=
|
|
3
|
+
basilisk/engine.py,sha256=7eIPyyLiZqL74j4zjCW2XBiHtrrSXte88HIYLD_yRys,6669
|
|
4
|
+
basilisk/scene.py,sha256=i0PCBN40mpQlKjCNqpv0e-YooVbn0h36tlG3fidfJQI,11337
|
|
5
5
|
basilisk/bsk_assets/Roboto-Regular.ttf,sha256=kqYnZjMRQMpbyLulIChCLSdgYa1XF8GsUIoRi2Gcauw,168260
|
|
6
6
|
basilisk/bsk_assets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
basilisk/bsk_assets/basilisk.png,sha256=1xePD8qDycxlRQ7hjEmfuw900BRykhRyumJePi6hxi8,21299
|
|
8
8
|
basilisk/bsk_assets/cube.obj,sha256=rLm2nNcfj1zPZUx-VSF5CxqnToteHjzXQNxfRNq5iKU,1189
|
|
9
9
|
basilisk/bsk_assets/skybox.png,sha256=0C9MvWUwNzewyiMtWLKrZJzAcLC1Ce72T3-Lq4hJZu0,1206153
|
|
10
10
|
basilisk/collisions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
-
basilisk/collisions/collider.py,sha256=
|
|
12
|
-
basilisk/collisions/collider_handler.py,sha256=
|
|
11
|
+
basilisk/collisions/collider.py,sha256=PTb14D2ppia3zdHRVlMvsXhRHBJJZyxUv5diLbQ59K8,4573
|
|
12
|
+
basilisk/collisions/collider_handler.py,sha256=dEaIcpV6596P9clbgMFOJnnr_VYXiHSEl48oUZZ0BYk,11519
|
|
13
13
|
basilisk/collisions/broad/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
basilisk/collisions/broad/broad_aabb.py,sha256=cyBCFFFkMY0yNDqBUY0HZ711m3QSSzoW2Ao9f8cFshE,4708
|
|
15
15
|
basilisk/collisions/broad/broad_bvh.py,sha256=M7sMYRzxAwjIu_nkYKrL8HW3YxzBvfrSN1qKClNY568,5127
|
|
16
16
|
basilisk/collisions/narrow/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
17
|
basilisk/collisions/narrow/contact_manifold.py,sha256=rBqFAKvCR8ksYs54GkjZf8GVzN7hoJ6ZLbjd4bDd39Q,4819
|
|
18
|
-
basilisk/collisions/narrow/dataclasses.py,sha256=
|
|
18
|
+
basilisk/collisions/narrow/dataclasses.py,sha256=IbRJFCJl4atJjDv1ub_OMZt7OdzwTt1s4tTKdFhfNCM,912
|
|
19
19
|
basilisk/collisions/narrow/deprecated.py,sha256=yQh6VOoVcwYENU4TThk_pXPSmwT3EfxMKILVR43sEDI,2751
|
|
20
20
|
basilisk/collisions/narrow/epa.py,sha256=kzKRs62kpTDqIqPz7Te1SV6OGWmfFb9Z7kZ1PqAMEwQ,4711
|
|
21
21
|
basilisk/collisions/narrow/gjk.py,sha256=lncqQ4ZkmSa-wPlAUpkdzdSdbiJjiYKDTqqGSr9xRGc,3338
|
|
22
22
|
basilisk/collisions/narrow/graham_scan.py,sha256=4cpsK2qbvLPw09LGXZp779Z536B-bpQciF-atZ4ngEI,862
|
|
23
|
-
basilisk/collisions/narrow/helper.py,sha256=
|
|
23
|
+
basilisk/collisions/narrow/helper.py,sha256=SyLuxBLlgoLAQ1Wk6eC-7BubNsjx3Nd3-Aek73R9Bm4,1256
|
|
24
24
|
basilisk/collisions/narrow/line_intersections.py,sha256=CGtttZ6n51u4l8JtQXzkClgZ_uvgx9IyrrGqli6JDbI,4629
|
|
25
25
|
basilisk/collisions/narrow/sutherland_hodgman.py,sha256=SUjSU5y7AuzIDiljMcTXxlGuFHT5IwtrOJ_k5HS1S2Y,3140
|
|
26
26
|
basilisk/draw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
27
|
basilisk/draw/draw.py,sha256=S1eMkuOiM2M0GQTxb1LgFMX7OCDn3YsUCkNc6-t-ClU,3631
|
|
28
|
-
basilisk/draw/draw_handler.py,sha256=
|
|
28
|
+
basilisk/draw/draw_handler.py,sha256=cqgjm8HXR9XcL723XSHhTSxYPz9Awhw2q4gmW7Oi6uY,6278
|
|
29
29
|
basilisk/draw/font_renderer.py,sha256=gyI59fW3DUswIcSg5VJLLcJti3OLTMdXNQrYJaw18dE,1092
|
|
30
30
|
basilisk/generic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
31
|
basilisk/generic/abstract_bvh.py,sha256=iQ6HjcI8Msw34dZ3YuDAhWSqEc4NTBHAaGqAZZAoLL8,383
|
|
32
32
|
basilisk/generic/abstract_custom.py,sha256=EPE2_2OxXyrx1YYO3niSxQ05ocxXnbAmFo7fr121Zxk,4537
|
|
33
33
|
basilisk/generic/collisions.py,sha256=N0A2eShH4wkXXvYQcFB_dTTouYxQs51qb3CpWDyxiak,2659
|
|
34
|
-
basilisk/generic/input_validation.py,sha256
|
|
34
|
+
basilisk/generic/input_validation.py,sha256=0e0H7EOAMgSfxctfh8ITfnY2xglqpO44SLqi2-i0BNA,3577
|
|
35
35
|
basilisk/generic/math.py,sha256=_MfMdu1t0JIdGplGnU9_Tj4ECuxhSNmauLg8zw1zcNs,176
|
|
36
36
|
basilisk/generic/matrices.py,sha256=NNvD0m6Y8lZLa5m6TeXI9k_pMJH0Bo2recL8eVqKjvo,1254
|
|
37
37
|
basilisk/generic/meshes.py,sha256=0Zq5EkWEtqz-2V-kEQt-R3JZvUS5RTqflih8Mj9vL4o,2639
|
|
38
38
|
basilisk/generic/quat.py,sha256=2yXZ5x1GjWQRCui0XDFITGWl9cf3W1KxTtMYfNMbU64,5110
|
|
39
39
|
basilisk/generic/quat_methods.py,sha256=FFqS2Iy1OLH6oJf1elhH9RbWiE_KMXe5eO95ayrEhbc,241
|
|
40
|
+
basilisk/generic/raycast_result.py,sha256=KHolRJkYZagnw_0GhYMfsS05q03n9ng3GJlRY0k4Ndo,675
|
|
40
41
|
basilisk/generic/vec3.py,sha256=n_OAVVFtzH-ctqU8Pqhs2426MQ0WOgBbq2Lfo3Nt498,5280
|
|
41
42
|
basilisk/input/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
42
|
-
basilisk/input/mouse.py,sha256=
|
|
43
|
+
basilisk/input/mouse.py,sha256=K2An-VI3r3VZLEx9bChKp2U2jHfSdxrvHtmyBu4yzCE,1998
|
|
44
|
+
basilisk/input/path.py,sha256=GiO1OS1UGujnl3KdIB7fGzI5BgIg7RHyI8LxsGWskcs,455
|
|
43
45
|
basilisk/mesh/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
44
46
|
basilisk/mesh/cube.py,sha256=UAwjEmaoWfUdtSKjxATU6vUbksDYj7_bBIr1k1xDsYc,1077
|
|
45
47
|
basilisk/mesh/mesh.py,sha256=vujJ0VxwCvvIKBAScPzo8nWWAouyRzE97M4-JVpqco0,9782
|
|
46
|
-
basilisk/mesh/mesh_from_data.py,sha256=
|
|
48
|
+
basilisk/mesh/mesh_from_data.py,sha256=P3cjtRbH1aNv0o9yeJXPu_TCp7IdZ4rVQG8kLIizlgs,4370
|
|
47
49
|
basilisk/mesh/model.py,sha256=uVnYm_XYSoZslNWmOego59Ku-gqKxZHpta_dHi65X1s,11993
|
|
48
50
|
basilisk/mesh/narrow_aabb.py,sha256=0lc06JgdfhUbzxUnCz4dcbEYSB3xjAf7DY7ec2096is,3868
|
|
49
51
|
basilisk/mesh/narrow_bvh.py,sha256=jLQhmUNi6mFyU2wVwB_SOf4PIaOAygBTtcnQIyaMOGg,4351
|
|
50
52
|
basilisk/mesh/narrow_primative.py,sha256=vWpIeo8I9le-EAvcr9rFUQlbl9mi6eYroqCSMK-m9eY,953
|
|
51
53
|
basilisk/nodes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
52
|
-
basilisk/nodes/
|
|
53
|
-
basilisk/nodes/
|
|
54
|
+
basilisk/nodes/helper.py,sha256=VdlGuEaMtLa992_8yNOB-QIgz4Izr5wNMSm8H6KftKE,2097
|
|
55
|
+
basilisk/nodes/node.py,sha256=knKs9ttO7kfMBBsRgvPZ3xe4OUIHplEeQkbSZskpsNk,32076
|
|
56
|
+
basilisk/nodes/node_handler.py,sha256=zN7z_XhgJhxcKHq137h5xAcF8RqRD1mjQjkYgnC8Fpk,4097
|
|
54
57
|
basilisk/particles/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
55
|
-
basilisk/particles/particle_handler.py,sha256=
|
|
58
|
+
basilisk/particles/particle_handler.py,sha256=8TXVE4drKwwErqgFzWLyQgU-kk97cABsEMitrfSY4SA,2916
|
|
56
59
|
basilisk/particles/particle_renderer.py,sha256=3OpkKLw4NUik4stORqMkCx1vqibXkdYVq0NDDjigAdo,3623
|
|
57
60
|
basilisk/physics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
58
61
|
basilisk/physics/impulse.py,sha256=zv6MoGTSlu8qVbsbe2QxERGeyQZYbtzR_WVSqVLsmhw,5873
|
|
@@ -60,22 +63,25 @@ basilisk/physics/physics_body.py,sha256=_mi-AVMgQqUsC3bQIca5tgk2xWXTIUw0D_uC4DcQ
|
|
|
60
63
|
basilisk/physics/physics_engine.py,sha256=IPMshr4j5TII5JdcRqiULc6BfkeCLPxdICKqQeZGAtY,1735
|
|
61
64
|
basilisk/render/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
62
65
|
basilisk/render/batch.py,sha256=Vmsm7zA2xi2xE4KKutxkasYfhnRNfyF8CI_HBIZNBIc,2998
|
|
63
|
-
basilisk/render/camera.py,sha256=
|
|
66
|
+
basilisk/render/camera.py,sha256=PDWOToHe1qgS3f3-FD1myq1JaAFQvPv8gb9N1megyAI,7487
|
|
64
67
|
basilisk/render/chunk.py,sha256=YNtoXrZN175u0USSCkpO3_0FiMrBIoaqMZl9XAoJLAA,2656
|
|
65
68
|
basilisk/render/chunk_handler.py,sha256=-vlrlEDqZIoBom2YK8c1yu9sGb7AHH-IbkI4IWYYd5Y,6168
|
|
66
|
-
basilisk/render/frame.py,sha256=
|
|
67
|
-
basilisk/render/
|
|
69
|
+
basilisk/render/frame.py,sha256=iHc792gKR8GCTDVKzxfAcO1TTwaKscTLaS1rbPuEplE,3222
|
|
70
|
+
basilisk/render/framebuffer.py,sha256=aSdnqkht4OihEHxIDuRjLf1rrLNeMEY6tChkFaAr7mk,3166
|
|
71
|
+
basilisk/render/image.py,sha256=e5EDImMdqkdSeK76cPiTPH9TRdIfUZ_HljiP4EQMedo,2961
|
|
68
72
|
basilisk/render/image_handler.py,sha256=6limLZvLznUK_l1UdEBsQ3XEPnnrCLzmBzSyifbV81M,4351
|
|
69
73
|
basilisk/render/light.py,sha256=hFqODv9iK4GEDZeDyBHxOWwwd4v8Pm089_xoScBMjVY,3879
|
|
70
74
|
basilisk/render/light_handler.py,sha256=Le5InqqjgglSXUu7MwkVVsb7WbNJeRkRKldYDQGr6kg,2161
|
|
71
75
|
basilisk/render/material.py,sha256=JmmwCxSYkPLHw73bH-7SzPo5ewzbU3QPTIvI_2pInXQ,9655
|
|
72
76
|
basilisk/render/material_handler.py,sha256=dbfQs0u7qkEan0e0FsnqPpxbmkSNAQmH2B9jv4vx-bs,4242
|
|
77
|
+
basilisk/render/post_process.py,sha256=xq5Iad2J_WxECG_ee472IJeFRiGsITRSQeCFLZS_h5k,4894
|
|
73
78
|
basilisk/render/shader.py,sha256=uFV1gv-MiWRG-nvv2akB0K2SrADWQ54vBYqHeJoy0PY,3913
|
|
74
79
|
basilisk/render/shader_handler.py,sha256=YDl4XGsAUrA_JavmsG2nuoo6k8WyzKNsx20App-RVSk,2511
|
|
75
80
|
basilisk/render/sky.py,sha256=TwLJ_6dYWCOAb06HZocrRdBzlbR6mQ0ojmmJgCC6im4,4910
|
|
76
81
|
basilisk/shaders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
77
82
|
basilisk/shaders/batch.frag,sha256=658z5GLegHDarroeqUpoiWDCCT2FHMr0ZHnYJ21qMhQ,9339
|
|
78
83
|
basilisk/shaders/batch.vert,sha256=nUZKd5uBTFJm1aOG0auQRxE2ElhcAGf1YmepyzWeG8g,5403
|
|
84
|
+
basilisk/shaders/crt.frag,sha256=7o0SoHAzi3-PYMVO8DpwhfAzRP0-P-OG1LCKgBM2AOc,965
|
|
79
85
|
basilisk/shaders/draw.frag,sha256=XV7dcVm-RhZXs6e6ddJhesR6BAmVWEHZqQgEJQEA77Q,450
|
|
80
86
|
basilisk/shaders/draw.vert,sha256=UQtceYDIUfrluXZSb_Y_L8_-Ky_bjAj9Uyvuu8KkpeE,509
|
|
81
87
|
basilisk/shaders/filter.frag,sha256=m_egR4yiFRmIHGwCCfpcdvGXQi1w1Ago_iABlbnX80c,584
|
|
@@ -89,7 +95,7 @@ basilisk/shaders/particle.frag,sha256=Cv8cWQpVVQvhZeWj3NqL0D5nLtSO3EWV0VzOU-ZVL4
|
|
|
89
95
|
basilisk/shaders/particle.vert,sha256=ElXzT7ywiZ0SjrFcUistVDBi4wOobQ7_J5O7XVxrsVs,3027
|
|
90
96
|
basilisk/shaders/sky.frag,sha256=vTmZ1Xsd601_gmeBRfLYodHuBoBDI-M_1IybRt0ZDFk,178
|
|
91
97
|
basilisk/shaders/sky.vert,sha256=v_BSdnMiljSJGPqno-J_apAiom38IrBzbDoxM7pIgwI,345
|
|
92
|
-
basilisk_engine-0.1.
|
|
93
|
-
basilisk_engine-0.1.
|
|
94
|
-
basilisk_engine-0.1.
|
|
95
|
-
basilisk_engine-0.1.
|
|
98
|
+
basilisk_engine-0.1.4.dist-info/METADATA,sha256=QVZ6ZqjIialwVSIreprtYro1yCIxxTbZ9W84Xk6WTJY,1146
|
|
99
|
+
basilisk_engine-0.1.4.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
|
100
|
+
basilisk_engine-0.1.4.dist-info/top_level.txt,sha256=enlSYSf7CUyAly1jmUCNNGInTbaFUjGk4SKwyckZQkw,9
|
|
101
|
+
basilisk_engine-0.1.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|