basilisk-engine 0.1.43__py3-none-any.whl → 0.1.45__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.

Files changed (98) hide show
  1. basilisk/__init__.py +26 -26
  2. basilisk/audio/sound.py +27 -27
  3. basilisk/bsk_assets/cube.obj +48 -48
  4. basilisk/collisions/broad/broad_aabb.py +102 -102
  5. basilisk/collisions/broad/broad_bvh.py +137 -137
  6. basilisk/collisions/collider.py +95 -95
  7. basilisk/collisions/collider_handler.py +225 -225
  8. basilisk/collisions/narrow/contact_manifold.py +95 -95
  9. basilisk/collisions/narrow/dataclasses.py +34 -34
  10. basilisk/collisions/narrow/deprecated.py +46 -46
  11. basilisk/collisions/narrow/epa.py +91 -91
  12. basilisk/collisions/narrow/gjk.py +66 -66
  13. basilisk/collisions/narrow/graham_scan.py +24 -24
  14. basilisk/collisions/narrow/helper.py +29 -29
  15. basilisk/collisions/narrow/line_intersections.py +106 -106
  16. basilisk/collisions/narrow/sutherland_hodgman.py +75 -75
  17. basilisk/config.py +53 -53
  18. basilisk/draw/draw.py +100 -100
  19. basilisk/draw/draw_handler.py +181 -178
  20. basilisk/draw/font_renderer.py +28 -28
  21. basilisk/engine.py +168 -169
  22. basilisk/generic/abstract_bvh.py +15 -15
  23. basilisk/generic/abstract_custom.py +133 -133
  24. basilisk/generic/collisions.py +70 -70
  25. basilisk/generic/input_validation.py +82 -82
  26. basilisk/generic/math.py +17 -17
  27. basilisk/generic/matrices.py +35 -35
  28. basilisk/generic/meshes.py +72 -72
  29. basilisk/generic/quat.py +142 -142
  30. basilisk/generic/quat_methods.py +7 -7
  31. basilisk/generic/raycast_result.py +26 -26
  32. basilisk/generic/vec3.py +143 -143
  33. basilisk/input/__init__.py +0 -0
  34. basilisk/input/mouse.py +62 -0
  35. basilisk/input/path.py +14 -0
  36. basilisk/input_output/IO_handler.py +91 -91
  37. basilisk/input_output/clock.py +49 -49
  38. basilisk/input_output/keys.py +43 -43
  39. basilisk/input_output/mouse.py +90 -90
  40. basilisk/input_output/path.py +14 -14
  41. basilisk/mesh/cube.py +33 -33
  42. basilisk/mesh/mesh.py +233 -233
  43. basilisk/mesh/mesh_from_data.py +150 -150
  44. basilisk/mesh/model.py +271 -271
  45. basilisk/mesh/narrow_aabb.py +89 -89
  46. basilisk/mesh/narrow_bvh.py +91 -91
  47. basilisk/mesh/narrow_primative.py +23 -23
  48. basilisk/nodes/helper.py +28 -28
  49. basilisk/nodes/node.py +709 -709
  50. basilisk/nodes/node_handler.py +97 -97
  51. basilisk/particles/particle_handler.py +64 -64
  52. basilisk/particles/particle_renderer.py +93 -93
  53. basilisk/physics/impulse.py +112 -112
  54. basilisk/physics/physics_body.py +43 -43
  55. basilisk/physics/physics_engine.py +35 -35
  56. basilisk/render/batch.py +103 -103
  57. basilisk/render/bloom.py +117 -117
  58. basilisk/render/camera.py +260 -260
  59. basilisk/render/chunk.py +113 -113
  60. basilisk/render/chunk_handler.py +167 -167
  61. basilisk/render/frame.py +130 -130
  62. basilisk/render/framebuffer.py +192 -192
  63. basilisk/render/image.py +120 -120
  64. basilisk/render/image_handler.py +120 -120
  65. basilisk/render/light.py +96 -96
  66. basilisk/render/light_handler.py +58 -58
  67. basilisk/render/material.py +232 -232
  68. basilisk/render/material_handler.py +133 -133
  69. basilisk/render/post_process.py +180 -180
  70. basilisk/render/shader.py +135 -135
  71. basilisk/render/shader_handler.py +109 -109
  72. basilisk/render/sky.py +119 -119
  73. basilisk/scene.py +287 -287
  74. basilisk/shaders/batch.frag +291 -293
  75. basilisk/shaders/batch.vert +117 -117
  76. basilisk/shaders/bloom_downsample.frag +23 -23
  77. basilisk/shaders/bloom_frame.frag +25 -0
  78. basilisk/shaders/bloom_upsample.frag +33 -33
  79. basilisk/shaders/crt.frag +34 -34
  80. basilisk/shaders/draw.frag +27 -27
  81. basilisk/shaders/draw.vert +25 -25
  82. basilisk/shaders/filter.frag +22 -22
  83. basilisk/shaders/frame.frag +13 -13
  84. basilisk/shaders/frame.vert +13 -13
  85. basilisk/shaders/frame_hdr.frag +27 -27
  86. basilisk/shaders/geometry.frag +10 -10
  87. basilisk/shaders/geometry.vert +41 -41
  88. basilisk/shaders/normal.frag +62 -62
  89. basilisk/shaders/normal.vert +96 -96
  90. basilisk/shaders/particle.frag +81 -81
  91. basilisk/shaders/particle.vert +86 -86
  92. basilisk/shaders/sky.frag +23 -23
  93. basilisk/shaders/sky.vert +13 -13
  94. {basilisk_engine-0.1.43.dist-info → basilisk_engine-0.1.45.dist-info}/METADATA +89 -89
  95. basilisk_engine-0.1.45.dist-info/RECORD +115 -0
  96. {basilisk_engine-0.1.43.dist-info → basilisk_engine-0.1.45.dist-info}/WHEEL +1 -1
  97. basilisk_engine-0.1.43.dist-info/RECORD +0 -111
  98. {basilisk_engine-0.1.43.dist-info → basilisk_engine-0.1.45.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()
@@ -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
  ...