basilisk-engine 0.1.35__py3-none-any.whl → 0.1.36__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 +26 -26
- basilisk/audio/sound.py +27 -27
- basilisk/bsk_assets/cube.obj +48 -48
- basilisk/collisions/broad/broad_aabb.py +102 -102
- basilisk/collisions/broad/broad_bvh.py +137 -137
- basilisk/collisions/collider.py +95 -95
- basilisk/collisions/collider_handler.py +225 -225
- basilisk/collisions/narrow/contact_manifold.py +95 -95
- basilisk/collisions/narrow/dataclasses.py +34 -34
- basilisk/collisions/narrow/deprecated.py +46 -46
- basilisk/collisions/narrow/epa.py +91 -91
- basilisk/collisions/narrow/gjk.py +66 -66
- basilisk/collisions/narrow/graham_scan.py +24 -24
- basilisk/collisions/narrow/helper.py +29 -29
- basilisk/collisions/narrow/line_intersections.py +106 -106
- basilisk/collisions/narrow/sutherland_hodgman.py +75 -75
- basilisk/config.py +54 -4
- basilisk/draw/draw.py +100 -100
- basilisk/draw/draw_handler.py +175 -175
- basilisk/draw/font_renderer.py +28 -28
- basilisk/engine.py +165 -165
- basilisk/generic/abstract_bvh.py +15 -15
- basilisk/generic/abstract_custom.py +133 -133
- basilisk/generic/collisions.py +70 -70
- basilisk/generic/input_validation.py +82 -74
- basilisk/generic/math.py +6 -6
- basilisk/generic/matrices.py +35 -35
- basilisk/generic/meshes.py +72 -72
- basilisk/generic/quat.py +142 -142
- basilisk/generic/quat_methods.py +7 -7
- basilisk/generic/raycast_result.py +26 -26
- basilisk/generic/vec3.py +143 -143
- basilisk/input_output/IO_handler.py +91 -91
- basilisk/input_output/clock.py +49 -49
- basilisk/input_output/keys.py +43 -43
- basilisk/input_output/mouse.py +90 -89
- basilisk/input_output/path.py +14 -14
- basilisk/mesh/cube.py +33 -33
- basilisk/mesh/mesh.py +233 -233
- basilisk/mesh/mesh_from_data.py +150 -150
- basilisk/mesh/model.py +271 -271
- basilisk/mesh/narrow_aabb.py +89 -89
- basilisk/mesh/narrow_bvh.py +91 -91
- basilisk/mesh/narrow_primative.py +23 -23
- basilisk/nodes/helper.py +28 -28
- basilisk/nodes/node.py +704 -695
- basilisk/nodes/node_handler.py +97 -97
- basilisk/particles/particle_handler.py +64 -64
- basilisk/particles/particle_renderer.py +92 -92
- basilisk/physics/impulse.py +112 -112
- basilisk/physics/physics_body.py +43 -43
- basilisk/physics/physics_engine.py +35 -35
- basilisk/render/batch.py +103 -103
- basilisk/render/bloom.py +108 -0
- basilisk/render/camera.py +260 -260
- basilisk/render/chunk.py +108 -106
- basilisk/render/chunk_handler.py +167 -165
- basilisk/render/frame.py +107 -95
- basilisk/render/framebuffer.py +203 -192
- basilisk/render/image.py +120 -120
- basilisk/render/image_handler.py +120 -120
- basilisk/render/light.py +96 -96
- basilisk/render/light_handler.py +58 -58
- basilisk/render/material.py +232 -221
- basilisk/render/material_handler.py +133 -133
- basilisk/render/post_process.py +139 -139
- basilisk/render/shader.py +134 -134
- basilisk/render/shader_handler.py +85 -83
- basilisk/render/sky.py +120 -120
- basilisk/scene.py +289 -289
- basilisk/shaders/batch.frag +289 -276
- basilisk/shaders/batch.vert +117 -115
- basilisk/shaders/bloom_downsample.frag +43 -0
- basilisk/shaders/bloom_frame.frag +25 -0
- basilisk/shaders/bloom_upsample.frag +34 -0
- basilisk/shaders/crt.frag +31 -31
- basilisk/shaders/draw.frag +25 -22
- basilisk/shaders/draw.vert +25 -25
- basilisk/shaders/filter.frag +22 -22
- basilisk/shaders/frame.frag +12 -12
- basilisk/shaders/frame.vert +13 -13
- basilisk/shaders/geometry.frag +8 -8
- basilisk/shaders/geometry.vert +41 -41
- basilisk/shaders/normal.frag +59 -59
- basilisk/shaders/normal.vert +96 -96
- basilisk/shaders/particle.frag +71 -71
- basilisk/shaders/particle.vert +84 -84
- basilisk/shaders/sky.frag +23 -9
- basilisk/shaders/sky.vert +13 -13
- basilisk_engine-0.1.36.dist-info/METADATA +89 -0
- basilisk_engine-0.1.36.dist-info/RECORD +110 -0
- {basilisk_engine-0.1.35.dist-info → basilisk_engine-0.1.36.dist-info}/WHEEL +1 -1
- basilisk/input/__init__.py +0 -0
- basilisk/input/mouse.py +0 -62
- basilisk/input/path.py +0 -14
- basilisk_engine-0.1.35.dist-info/METADATA +0 -45
- basilisk_engine-0.1.35.dist-info/RECORD +0 -109
- {basilisk_engine-0.1.35.dist-info → basilisk_engine-0.1.36.dist-info}/top_level.txt +0 -0
basilisk/render/light.py
CHANGED
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
import glm
|
|
2
|
-
import numpy as np
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Light():
|
|
6
|
-
light_handler: ...
|
|
7
|
-
"""Back reference to the parent light handler"""
|
|
8
|
-
intensity: float
|
|
9
|
-
"""The brightness of the light"""
|
|
10
|
-
color: glm.vec3
|
|
11
|
-
"""The color of the light"""
|
|
12
|
-
|
|
13
|
-
def __init__(self, light_handler, intensity: float=1.0, color: tuple=(255, 255, 255)):
|
|
14
|
-
"""
|
|
15
|
-
Abstract light class for Basilisk Engine.
|
|
16
|
-
Cannot be added to a scene.
|
|
17
|
-
"""
|
|
18
|
-
|
|
19
|
-
# Back References
|
|
20
|
-
self.light_handler = light_handler
|
|
21
|
-
|
|
22
|
-
# Light attributes
|
|
23
|
-
self.intensity = intensity
|
|
24
|
-
self.color = color
|
|
25
|
-
|
|
26
|
-
@property
|
|
27
|
-
def intensity(self): return self._intensity
|
|
28
|
-
@property
|
|
29
|
-
def color(self): return self._color
|
|
30
|
-
|
|
31
|
-
@intensity.setter
|
|
32
|
-
def intensity(self, value: float | int):
|
|
33
|
-
if isinstance(value, float) or isinstance(value, int):
|
|
34
|
-
self._intensity = value
|
|
35
|
-
else:
|
|
36
|
-
raise TypeError(f"Light: Invalid intensity value type {type(value)}. Expected float or int")
|
|
37
|
-
self.light_handler.write()
|
|
38
|
-
|
|
39
|
-
@color.setter
|
|
40
|
-
def color(self, value: tuple | list | glm.vec3 | np.ndarray):
|
|
41
|
-
if isinstance(value, tuple) or isinstance(value, list) or isinstance(value, np.ndarray):
|
|
42
|
-
if len(value) != 3: raise ValueError(f"Light: Invalid number of values for color. Expected 3 values, got {len(value)} values")
|
|
43
|
-
self._color = glm.vec3(value)
|
|
44
|
-
elif isinstance(value, glm.vec3):
|
|
45
|
-
self._color = glm.vec3(value)
|
|
46
|
-
else:
|
|
47
|
-
raise TypeError(f"Light: Invalid color value type {type(value)}. Expected tuple, list, glm.vec3, or numpy array")
|
|
48
|
-
self.light_handler.write()
|
|
49
|
-
|
|
50
|
-
class DirectionalLight(Light):
|
|
51
|
-
direction: glm.vec3
|
|
52
|
-
"""The direction that the light is applied to objects"""
|
|
53
|
-
ambient: float
|
|
54
|
-
"""Base value of light that is applied at all locations, regardless of direction"""
|
|
55
|
-
|
|
56
|
-
def __init__(self, light_handler, direction: tuple=(1.5, -2.0, 1.0), intensity:float=1.0, color: tuple=(255, 255, 255), ambient: float=0.0):
|
|
57
|
-
"""
|
|
58
|
-
Diractional/Global light for Basilisk Engine.
|
|
59
|
-
Has same intensity and direction everywhere.
|
|
60
|
-
Args:
|
|
61
|
-
direction: tuple
|
|
62
|
-
The direction that the light is applied to objects
|
|
63
|
-
intensity: float
|
|
64
|
-
The brightness of the light
|
|
65
|
-
color: tuple
|
|
66
|
-
The color of the light
|
|
67
|
-
ambient: float
|
|
68
|
-
Base value of light that is applied at all locations, regardless of direction
|
|
69
|
-
"""
|
|
70
|
-
|
|
71
|
-
super().__init__(light_handler, intensity, color)
|
|
72
|
-
self.direction = direction
|
|
73
|
-
self.ambient = ambient
|
|
74
|
-
|
|
75
|
-
@property
|
|
76
|
-
def direction(self): return self._direction
|
|
77
|
-
@property
|
|
78
|
-
def ambient(self): return self._ambient
|
|
79
|
-
|
|
80
|
-
@direction.setter
|
|
81
|
-
def direction(self, value: tuple | list | glm.vec3 | np.ndarray):
|
|
82
|
-
if isinstance(value, tuple) or isinstance(value, list) or isinstance(value, np.ndarray):
|
|
83
|
-
if len(value) != 3: raise ValueError(f"Light: Invalid number of values for direction. Expected 3 values, got {len(value)} values")
|
|
84
|
-
self._direction = glm.normalize(glm.vec3(value))
|
|
85
|
-
elif isinstance(value, glm.vec3):
|
|
86
|
-
self._direction = glm.normalize(glm.vec3(value))
|
|
87
|
-
else:
|
|
88
|
-
raise TypeError(f"Light: Invalid direction value type {type(value)}. Expected tuple, list, glm.vec3, or numpy array")
|
|
89
|
-
self.light_handler.write()
|
|
90
|
-
|
|
91
|
-
@ambient.setter
|
|
92
|
-
def ambient(self, value: float | int):
|
|
93
|
-
if isinstance(value, float) or isinstance(value, int):
|
|
94
|
-
self._ambient = value
|
|
95
|
-
else:
|
|
96
|
-
raise TypeError(f"Light: Invalid ambient value type {type(value)}. Expected float or int")
|
|
1
|
+
import glm
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Light():
|
|
6
|
+
light_handler: ...
|
|
7
|
+
"""Back reference to the parent light handler"""
|
|
8
|
+
intensity: float
|
|
9
|
+
"""The brightness of the light"""
|
|
10
|
+
color: glm.vec3
|
|
11
|
+
"""The color of the light"""
|
|
12
|
+
|
|
13
|
+
def __init__(self, light_handler, intensity: float=1.0, color: tuple=(255, 255, 255)):
|
|
14
|
+
"""
|
|
15
|
+
Abstract light class for Basilisk Engine.
|
|
16
|
+
Cannot be added to a scene.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
# Back References
|
|
20
|
+
self.light_handler = light_handler
|
|
21
|
+
|
|
22
|
+
# Light attributes
|
|
23
|
+
self.intensity = intensity
|
|
24
|
+
self.color = color
|
|
25
|
+
|
|
26
|
+
@property
|
|
27
|
+
def intensity(self): return self._intensity
|
|
28
|
+
@property
|
|
29
|
+
def color(self): return self._color
|
|
30
|
+
|
|
31
|
+
@intensity.setter
|
|
32
|
+
def intensity(self, value: float | int):
|
|
33
|
+
if isinstance(value, float) or isinstance(value, int):
|
|
34
|
+
self._intensity = value
|
|
35
|
+
else:
|
|
36
|
+
raise TypeError(f"Light: Invalid intensity value type {type(value)}. Expected float or int")
|
|
37
|
+
self.light_handler.write()
|
|
38
|
+
|
|
39
|
+
@color.setter
|
|
40
|
+
def color(self, value: tuple | list | glm.vec3 | np.ndarray):
|
|
41
|
+
if isinstance(value, tuple) or isinstance(value, list) or isinstance(value, np.ndarray):
|
|
42
|
+
if len(value) != 3: raise ValueError(f"Light: Invalid number of values for color. Expected 3 values, got {len(value)} values")
|
|
43
|
+
self._color = glm.vec3(value)
|
|
44
|
+
elif isinstance(value, glm.vec3):
|
|
45
|
+
self._color = glm.vec3(value)
|
|
46
|
+
else:
|
|
47
|
+
raise TypeError(f"Light: Invalid color value type {type(value)}. Expected tuple, list, glm.vec3, or numpy array")
|
|
48
|
+
self.light_handler.write()
|
|
49
|
+
|
|
50
|
+
class DirectionalLight(Light):
|
|
51
|
+
direction: glm.vec3
|
|
52
|
+
"""The direction that the light is applied to objects"""
|
|
53
|
+
ambient: float
|
|
54
|
+
"""Base value of light that is applied at all locations, regardless of direction"""
|
|
55
|
+
|
|
56
|
+
def __init__(self, light_handler, direction: tuple=(1.5, -2.0, 1.0), intensity:float=1.0, color: tuple=(255, 255, 255), ambient: float=0.0):
|
|
57
|
+
"""
|
|
58
|
+
Diractional/Global light for Basilisk Engine.
|
|
59
|
+
Has same intensity and direction everywhere.
|
|
60
|
+
Args:
|
|
61
|
+
direction: tuple
|
|
62
|
+
The direction that the light is applied to objects
|
|
63
|
+
intensity: float
|
|
64
|
+
The brightness of the light
|
|
65
|
+
color: tuple
|
|
66
|
+
The color of the light
|
|
67
|
+
ambient: float
|
|
68
|
+
Base value of light that is applied at all locations, regardless of direction
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
super().__init__(light_handler, intensity, color)
|
|
72
|
+
self.direction = direction
|
|
73
|
+
self.ambient = ambient
|
|
74
|
+
|
|
75
|
+
@property
|
|
76
|
+
def direction(self): return self._direction
|
|
77
|
+
@property
|
|
78
|
+
def ambient(self): return self._ambient
|
|
79
|
+
|
|
80
|
+
@direction.setter
|
|
81
|
+
def direction(self, value: tuple | list | glm.vec3 | np.ndarray):
|
|
82
|
+
if isinstance(value, tuple) or isinstance(value, list) or isinstance(value, np.ndarray):
|
|
83
|
+
if len(value) != 3: raise ValueError(f"Light: Invalid number of values for direction. Expected 3 values, got {len(value)} values")
|
|
84
|
+
self._direction = glm.normalize(glm.vec3(value))
|
|
85
|
+
elif isinstance(value, glm.vec3):
|
|
86
|
+
self._direction = glm.normalize(glm.vec3(value))
|
|
87
|
+
else:
|
|
88
|
+
raise TypeError(f"Light: Invalid direction value type {type(value)}. Expected tuple, list, glm.vec3, or numpy array")
|
|
89
|
+
self.light_handler.write()
|
|
90
|
+
|
|
91
|
+
@ambient.setter
|
|
92
|
+
def ambient(self, value: float | int):
|
|
93
|
+
if isinstance(value, float) or isinstance(value, int):
|
|
94
|
+
self._ambient = value
|
|
95
|
+
else:
|
|
96
|
+
raise TypeError(f"Light: Invalid ambient value type {type(value)}. Expected float or int")
|
|
97
97
|
self.light_handler.write()
|
basilisk/render/light_handler.py
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import moderngl as mgl
|
|
2
|
-
import glm
|
|
3
|
-
from ..render.light import DirectionalLight
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class LightHandler():
|
|
7
|
-
engine: ...
|
|
8
|
-
"""Back reference to the parent engine"""
|
|
9
|
-
scene: ...
|
|
10
|
-
"""Back reference to the parent scene"""
|
|
11
|
-
ctx: mgl.Context
|
|
12
|
-
"""Back reference to the parent context"""
|
|
13
|
-
directional_light: DirectionalLight
|
|
14
|
-
"""The directional light of the scene"""
|
|
15
|
-
point_lights: list
|
|
16
|
-
"""List of all the point lights in the scene"""
|
|
17
|
-
|
|
18
|
-
def __init__(self, scene) -> None:
|
|
19
|
-
"""
|
|
20
|
-
Handles all the lights in a Basilisk scene.
|
|
21
|
-
"""
|
|
22
|
-
|
|
23
|
-
# Back references
|
|
24
|
-
self.scene = scene
|
|
25
|
-
self.engine = scene.engine
|
|
26
|
-
self.ctx = scene.engine.ctx
|
|
27
|
-
|
|
28
|
-
# Intialize light variables
|
|
29
|
-
self.directional_lights = None
|
|
30
|
-
self.directional_lights = [DirectionalLight(self, direction=dir, intensity=intensity) for dir, intensity in zip(((1, -1, 1), (-.1, 3, -.1)), (1, .05))]
|
|
31
|
-
self.point_lights = []
|
|
32
|
-
|
|
33
|
-
# Initalize uniforms
|
|
34
|
-
self.write()
|
|
35
|
-
|
|
36
|
-
def write(self, program: mgl.Program=None, directional=True, point=False) -> None:
|
|
37
|
-
"""
|
|
38
|
-
Writes all the lights in a scene to the given shader program
|
|
39
|
-
"""
|
|
40
|
-
|
|
41
|
-
# if not program: program = self.engine.shader.program
|
|
42
|
-
|
|
43
|
-
for shader in self.engine.shader_handler.shaders:
|
|
44
|
-
if 'numDirLights' not in shader.uniforms: continue
|
|
45
|
-
|
|
46
|
-
program = shader.program
|
|
47
|
-
|
|
48
|
-
if directional and self.directional_lights and 'numDirLights' in self.engine.shader.uniforms:
|
|
49
|
-
|
|
50
|
-
program['numDirLights'].write(glm.int32(len(self.directional_lights)))
|
|
51
|
-
|
|
52
|
-
for i, light in enumerate(self.directional_lights):
|
|
53
|
-
program[f'dirLights[{i}].direction'].write(light.direction)
|
|
54
|
-
program[f'dirLights[{i}].intensity'].write(glm.float32(light.intensity))
|
|
55
|
-
program[f'dirLights[{i}].color' ].write(light.color / 255.0)
|
|
56
|
-
program[f'dirLights[{i}].ambient' ].write(glm.float32(light.ambient))
|
|
57
|
-
|
|
58
|
-
if point:
|
|
1
|
+
import moderngl as mgl
|
|
2
|
+
import glm
|
|
3
|
+
from ..render.light import DirectionalLight
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class LightHandler():
|
|
7
|
+
engine: ...
|
|
8
|
+
"""Back reference to the parent engine"""
|
|
9
|
+
scene: ...
|
|
10
|
+
"""Back reference to the parent scene"""
|
|
11
|
+
ctx: mgl.Context
|
|
12
|
+
"""Back reference to the parent context"""
|
|
13
|
+
directional_light: DirectionalLight
|
|
14
|
+
"""The directional light of the scene"""
|
|
15
|
+
point_lights: list
|
|
16
|
+
"""List of all the point lights in the scene"""
|
|
17
|
+
|
|
18
|
+
def __init__(self, scene) -> None:
|
|
19
|
+
"""
|
|
20
|
+
Handles all the lights in a Basilisk scene.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
# Back references
|
|
24
|
+
self.scene = scene
|
|
25
|
+
self.engine = scene.engine
|
|
26
|
+
self.ctx = scene.engine.ctx
|
|
27
|
+
|
|
28
|
+
# Intialize light variables
|
|
29
|
+
self.directional_lights = None
|
|
30
|
+
self.directional_lights = [DirectionalLight(self, direction=dir, intensity=intensity) for dir, intensity in zip(((1, -1, 1), (-.1, 3, -.1)), (1, .05))]
|
|
31
|
+
self.point_lights = []
|
|
32
|
+
|
|
33
|
+
# Initalize uniforms
|
|
34
|
+
self.write()
|
|
35
|
+
|
|
36
|
+
def write(self, program: mgl.Program=None, directional=True, point=False) -> None:
|
|
37
|
+
"""
|
|
38
|
+
Writes all the lights in a scene to the given shader program
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
# if not program: program = self.engine.shader.program
|
|
42
|
+
|
|
43
|
+
for shader in self.engine.shader_handler.shaders:
|
|
44
|
+
if 'numDirLights' not in shader.uniforms: continue
|
|
45
|
+
|
|
46
|
+
program = shader.program
|
|
47
|
+
|
|
48
|
+
if directional and self.directional_lights and 'numDirLights' in self.engine.shader.uniforms:
|
|
49
|
+
|
|
50
|
+
program['numDirLights'].write(glm.int32(len(self.directional_lights)))
|
|
51
|
+
|
|
52
|
+
for i, light in enumerate(self.directional_lights):
|
|
53
|
+
program[f'dirLights[{i}].direction'].write(light.direction)
|
|
54
|
+
program[f'dirLights[{i}].intensity'].write(glm.float32(light.intensity))
|
|
55
|
+
program[f'dirLights[{i}].color' ].write(light.color / 255.0)
|
|
56
|
+
program[f'dirLights[{i}].ambient' ].write(glm.float32(light.ambient))
|
|
57
|
+
|
|
58
|
+
if point:
|
|
59
59
|
...
|