gamengine3d 1.5.2__tar.gz → 1.6.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.
Files changed (29) hide show
  1. {gamengine3d-1.5.2 → gamengine3d-1.6.0}/PKG-INFO +3 -1
  2. {gamengine3d-1.5.2 → gamengine3d-1.6.0}/README.md +2 -0
  3. {gamengine3d-1.5.2 → gamengine3d-1.6.0}/gamengine3d/__init__.py +1 -0
  4. gamengine3d-1.6.0/gamengine3d/cli.py +34 -0
  5. {gamengine3d-1.5.2 → gamengine3d-1.6.0}/gamengine3d/context.py +5 -1
  6. gamengine3d-1.6.0/gamengine3d/examples/basics.py +11 -0
  7. gamengine3d-1.6.0/gamengine3d/examples/player_movement.py +83 -0
  8. gamengine3d-1.6.0/gamengine3d/examples/scripts/cylinder.py +21 -0
  9. gamengine3d-1.6.0/gamengine3d/examples/scripts/player_movement.py +94 -0
  10. gamengine3d-1.6.0/gamengine3d/examples/scripts/settings.py +6 -0
  11. gamengine3d-1.6.0/gamengine3d/examples/the_everything_demo.py +42 -0
  12. {gamengine3d-1.5.2 → gamengine3d-1.6.0}/gamengine3d/helper.py +97 -5
  13. gamengine3d-1.6.0/gamengine3d/shaders/__init__.py +0 -0
  14. {gamengine3d-1.5.2 → gamengine3d-1.6.0}/gamengine3d/shaders/default.frag +4 -3
  15. {gamengine3d-1.5.2 → gamengine3d-1.6.0}/gamengine3d.egg-info/PKG-INFO +3 -1
  16. {gamengine3d-1.5.2 → gamengine3d-1.6.0}/gamengine3d.egg-info/SOURCES.txt +9 -0
  17. gamengine3d-1.6.0/gamengine3d.egg-info/entry_points.txt +2 -0
  18. {gamengine3d-1.5.2 → gamengine3d-1.6.0}/pyproject.toml +4 -1
  19. {gamengine3d-1.5.2 → gamengine3d-1.6.0}/LICENSE.txt +0 -0
  20. {gamengine3d-1.5.2 → gamengine3d-1.6.0}/gamengine3d/engine.py +0 -0
  21. {gamengine3d-1.5.2/gamengine3d/shaders → gamengine3d-1.6.0/gamengine3d/examples}/__init__.py +0 -0
  22. {gamengine3d-1.5.2 → gamengine3d-1.6.0}/gamengine3d/game_objects.py +0 -0
  23. {gamengine3d-1.5.2 → gamengine3d-1.6.0}/gamengine3d/shaders/default.vert +0 -0
  24. {gamengine3d-1.5.2 → gamengine3d-1.6.0}/gamengine3d/shaders/depth.frag +0 -0
  25. {gamengine3d-1.5.2 → gamengine3d-1.6.0}/gamengine3d/shaders/depth.vert +0 -0
  26. {gamengine3d-1.5.2 → gamengine3d-1.6.0}/gamengine3d.egg-info/dependency_links.txt +0 -0
  27. {gamengine3d-1.5.2 → gamengine3d-1.6.0}/gamengine3d.egg-info/requires.txt +0 -0
  28. {gamengine3d-1.5.2 → gamengine3d-1.6.0}/gamengine3d.egg-info/top_level.txt +0 -0
  29. {gamengine3d-1.5.2 → gamengine3d-1.6.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gamengine3d
3
- Version: 1.5.2
3
+ Version: 1.6.0
4
4
  Summary: A Unity-like 3D engine in Python using pygame
5
5
  Author-email: Samarth Javagal <samarthjavagal@gmail.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -75,4 +75,6 @@ class PlayerController:
75
75
  ```
76
76
  This minimal PlayerController shows how to attach a script to an object and respond to input.
77
77
 
78
+ You can run any built-in demo with ``gamengine3d demo <demo_name>`` and see all available options using ``gamengine3d demo -h``.
79
+
78
80
  The 2d version of ```gamengine3d``` is out under ``gamengine2d``
@@ -57,4 +57,6 @@ class PlayerController:
57
57
  ```
58
58
  This minimal PlayerController shows how to attach a script to an object and respond to input.
59
59
 
60
+ You can run any built-in demo with ``gamengine3d demo <demo_name>`` and see all available options using ``gamengine3d demo -h``.
61
+
60
62
  The 2d version of ```gamengine3d``` is out under ``gamengine2d``
@@ -4,6 +4,7 @@ from .game_objects import (
4
4
  GameObject,
5
5
  Cuboid,
6
6
  Cylinder,
7
+ Sphere,
7
8
  )
8
9
 
9
10
  from .helper import (
@@ -0,0 +1,34 @@
1
+
2
+ import argparse
3
+ import runpy
4
+ from pathlib import Path
5
+
6
+ def main():
7
+ parser = argparse.ArgumentParser(prog="gamengine3d")
8
+ sub = parser.add_subparsers(dest="command", required=True)
9
+
10
+ # Get the list of available demos from the examples folder
11
+ examples_dir = Path(__file__).parent / "examples"
12
+ available_demos = [
13
+ f.stem for f in examples_dir.glob("*.py") if f.is_file() and f.name != "__init__.py"
14
+ ]
15
+
16
+ demo_cmd = sub.add_parser("demo", help="Run a built-in example")
17
+ demo_cmd.add_argument(
18
+ "demo_name",
19
+ nargs="?",
20
+ default="basics",
21
+ choices=available_demos, # restrict to available demos
22
+ help=f"The name of the example to run. Available: {', '.join(available_demos)}"
23
+ )
24
+
25
+ args = parser.parse_args()
26
+
27
+ if args.command == "demo":
28
+ module = f"gamengine3d.examples.{args.demo_name}"
29
+ print(f"Running example: {args.demo_name}")
30
+ print(f"Path: {module}")
31
+ runpy.run_module(module, run_name="__main__")
32
+
33
+ if __name__ == "__main__":
34
+ main()
@@ -104,6 +104,9 @@ class ScheduledCaller:
104
104
  self.caller_id = caller_id
105
105
  self.finished = False
106
106
  self.delay_obj = Delay(self.delay, self.callback)
107
+ self.forever = False
108
+ if n_times == -1:
109
+ self.forever = True
107
110
 
108
111
  def update(self):
109
112
  self.delay_obj.update()
@@ -111,7 +114,8 @@ class ScheduledCaller:
111
114
  self.n_times -= 1
112
115
  self.delay_obj = Delay(self.delay, self.callback)
113
116
 
114
- self.finished = self.n_times < 0
117
+ if not self.forever:
118
+ self.finished = self.n_times <= 0
115
119
 
116
120
  class RuntimeVars:
117
121
  def from_settings(self, module_name):
@@ -0,0 +1,11 @@
1
+ from gamengine3d import Engine, Cuboid, vector3d, Light, Color # import all the classes
2
+
3
+ engine = Engine(500, 500, resizable=True, name="Basics Demo", background_color=Color.light_blue, ambient_light=0.4) # define the Engine object.
4
+
5
+ floor = Cuboid(pos=vector3d.zero, size=vector3d(10, .5, 10), color=Color.light_grey) # create the floor
6
+
7
+ engine.add_light(Light(position=vector3d(0, 4, .1), color=Color.white)) # create and add a light (x or z values of 0 don't create the light in this case, fixes are being made
8
+
9
+ engine.add_object(floor) # add the floor object
10
+
11
+ engine.run() # run the game
@@ -0,0 +1,83 @@
1
+ from pathlib import Path
2
+ from gamengine3d import Engine, vector3d, Color, Cuboid, Light
3
+
4
+ # Initialize engine
5
+ engine = Engine(
6
+ 1200, 800,
7
+ background_color=Color.light_blue,
8
+ ambient_light=0.3,
9
+ name="Player Movement Demo"
10
+ )
11
+
12
+ # Room setup
13
+ room_size = vector3d(5, 1.5, 2.5)
14
+ half_size = room_size / 2
15
+ room_color = Color.white
16
+ light_intensity = 0.3
17
+
18
+ # Camera positioning
19
+ engine.camera.move_to(vector3d(0.0, 1.4, 2.3))
20
+
21
+ # Floor
22
+ floor = Cuboid(
23
+ size=vector3d(room_size.x, 1, room_size.z),
24
+ color=Color.light_grey,
25
+ name="Floor",
26
+ pos=vector3d(0, 0.05 - 0.5)
27
+ )
28
+ engine.add_object(floor)
29
+
30
+ # Walls
31
+ left_wall = Cuboid(
32
+ pos=vector3d(-half_size.x, half_size.y, 0),
33
+ size=vector3d(0.1, room_size.y, room_size.z),
34
+ color=room_color,
35
+ name="Left"
36
+ )
37
+ engine.add_object(left_wall)
38
+
39
+ right_wall = Cuboid(
40
+ pos=vector3d(half_size.x, half_size.y, 0),
41
+ size=vector3d(0.1, room_size.y, room_size.z),
42
+ color=room_color,
43
+ name="Right"
44
+ )
45
+ engine.add_object(right_wall)
46
+
47
+ back_wall = Cuboid(
48
+ pos=vector3d(0, half_size.y, -half_size.z),
49
+ size=vector3d(room_size.x, room_size.y, 0.1),
50
+ color=room_color,
51
+ name="Back"
52
+ )
53
+ engine.add_object(back_wall)
54
+
55
+ # Player
56
+ player = Cuboid(
57
+ name="Player",
58
+ color=Color.light_red,
59
+ size=vector3d(0.2),
60
+ pos=vector3d(0, 1)
61
+ )
62
+ EXAMPLE_DIR = Path(__file__).parent
63
+ player_script = EXAMPLE_DIR / "scripts" / "player_movement.py" # get the player_movement script path
64
+
65
+ player.attach(player_script, engine.context) # attach movement script
66
+ # you can directly add a relative path like "scripts/player_movement.py"
67
+
68
+ engine.add_object(player)
69
+
70
+ # Lights
71
+ engine.add_light(Light(
72
+ vector3d(1/3 * room_size.x, room_size.y, 1),
73
+ Color.white,
74
+ light_intensity
75
+ ))
76
+ engine.add_light(Light(
77
+ vector3d(-1/3 * room_size.x, room_size.y, 1),
78
+ Color.white,
79
+ light_intensity
80
+ ))
81
+
82
+ # Run the demo
83
+ engine.run(dynamic_view=True)
@@ -0,0 +1,21 @@
1
+ from gamengine3d import *
2
+
3
+ class Cylinder:
4
+ def __init__(self, obj: Cylinder, context: Context):
5
+ self.obj = obj
6
+ self.context = context
7
+ self.color_idx = 0
8
+ self.obj.color = self.context.runtime_vars.cylinder_colors[0]
9
+ self.context.add_scheduled_caller(n_times=-1, delay=1, callback=self.switch_color)
10
+ self.context.on_key_held("w", self.draw_cylinder)
11
+ self.obj.visible = False
12
+
13
+ def update(self, dt):
14
+ pass
15
+
16
+ def switch_color(self):
17
+ self.color_idx += 1
18
+ self.obj.color = self.context.runtime_vars.cylinder_colors[self.color_idx % self.context.runtime_vars.num_cylinder_colors]
19
+
20
+ def draw_cylinder(self):
21
+ self.context.renderer.render_cylinder(vector3d.zero, 2, .1, Color.blue, 32)
@@ -0,0 +1,94 @@
1
+ from gamengine3d import vector3d, Context, Cuboid
2
+ import math
3
+
4
+
5
+ class PlayerMovement: # Class name must match file name in PascalCase
6
+ def __init__(self, obj: Cuboid, context: Context):
7
+ self.obj = obj
8
+ self.context = context
9
+
10
+ self.speed = 1 # units per second
11
+ self.rotate_speed = 100 # degrees per second
12
+ self.gravity = vector3d(0, -4.8, 0)
13
+ self.velocity = vector3d.zero
14
+
15
+ # Movement bindings
16
+ self.context.on_key_held("w", callback=self.handle_controls, dt=True, args=["forward"])
17
+ self.context.on_key_held("s", callback=self.handle_controls, dt=True, args=["backward"])
18
+ self.context.on_key_held("a", callback=self.handle_controls, dt=True, args=["left"])
19
+ self.context.on_key_held("d", callback=self.handle_controls, dt=True, args=["right"])
20
+ self.context.on_key_held("space", callback=self.handle_controls, dt=True, args=["up"])
21
+
22
+ self.obj.rotation = vector3d(0) # start facing forward
23
+
24
+
25
+ def update(self, dt):
26
+ # Gravity runs every frame
27
+ self.handle_gravity(dt)
28
+
29
+
30
+ def handle_controls(self, dt, direction):
31
+ forward = get_forward(self.obj.rotation) # forward relative to facing direction
32
+
33
+ if direction == "forward":
34
+ delta_pos = forward * self.speed * dt
35
+ self.obj.pos += delta_pos
36
+
37
+ # undo if hitting walls
38
+ if any([
39
+ self.context.functions.is_colliding(self.obj.name, "Left"),
40
+ self.context.functions.is_colliding(self.obj.name, "Right"),
41
+ self.context.functions.is_colliding(self.obj.name, "Back"),
42
+ ]):
43
+ self.obj.pos -= delta_pos
44
+
45
+ elif direction == "backward":
46
+ delta_pos = forward * self.speed * dt
47
+ self.obj.pos -= delta_pos
48
+
49
+ # undo if hitting walls
50
+ if any([
51
+ self.context.functions.is_colliding(self.obj.name, "Left"),
52
+ self.context.functions.is_colliding(self.obj.name, "Right"),
53
+ self.context.functions.is_colliding(self.obj.name, "Back"),
54
+ ]):
55
+ self.obj.pos += delta_pos
56
+
57
+ elif direction == "left":
58
+ self.obj.rotation.z -= self.rotate_speed * dt # turn left
59
+
60
+ elif direction == "right":
61
+ self.obj.rotation.z += self.rotate_speed * dt # turn right
62
+
63
+ elif direction == "up":
64
+ # jump only if grounded
65
+ if self.context.functions.is_colliding(self.obj.name, "Floor"):
66
+ self.velocity.y = 3
67
+ self.obj.pos.y += 0.1 # small lift to ensure gravity applies next frame
68
+
69
+
70
+ def handle_gravity(self, dt):
71
+ grounded = self.context.functions.is_colliding(self.obj.name, "Floor")
72
+
73
+ if not grounded:
74
+ self.velocity += self.gravity * dt # accelerate downward
75
+ else:
76
+ floor = self.context.functions.get_game_object("Floor")
77
+ self.obj.pos.y = floor.pos.y + floor.size.y/2 + self.obj.size.y/2 # snap to surface
78
+ self.velocity = vector3d.zero
79
+
80
+ # check predicted collision next frame
81
+ if self.context.functions.is_colliding_pos("Floor", self.obj.pos + self.velocity * dt):
82
+ floor = self.context.functions.get_game_object("Floor")
83
+ self.obj.pos.y = floor.pos.y + floor.size.y/2 + self.obj.size.y/2
84
+ else:
85
+ self.obj.pos += self.velocity * dt # apply gravity motion
86
+
87
+
88
+ def get_forward(rotation):
89
+ # Converts yaw (z rotation) into a directional vector on the XZ plane
90
+ yaw = math.radians(rotation.z)
91
+ fx = -math.sin(yaw)
92
+ fy = 0
93
+ fz = math.cos(yaw)
94
+ return vector3d(fx, fy, fz)
@@ -0,0 +1,6 @@
1
+ from gamengine3d import Color, vector3d
2
+
3
+ cylinder_colors = [Color.light_red, Color.light_green, Color.light_blue, Color.light_yellow, Color.orange, Color.magenta]
4
+ num_cylinder_colors = len(cylinder_colors)
5
+
6
+ sphere_pos = vector3d(0, 1, 4)
@@ -0,0 +1,42 @@
1
+ from gamengine3d import *
2
+ import random
3
+ from pathlib import Path
4
+
5
+ engine = Engine(1000, 800, name="The Everything DEMO", background_color=Color.grey)
6
+ engine.context.runtime_vars.from_settings("gamengine3d.examples.scripts.settings") # set the runtime vars from a module
7
+
8
+ positions = [
9
+ vector3d(0, 4, 0.5),
10
+ vector3d(-3, 2, 2),
11
+ vector3d(3, 3, -2),
12
+ vector3d(-2, 5, -3),
13
+ vector3d(4, 6, 4),
14
+ vector3d(1, 6, 7),
15
+ vector3d(-4, 3, 5),
16
+ vector3d(5, 5, 9),
17
+ vector3d(0, 7, -4),
18
+ vector3d(-5, 4, 3),
19
+ vector3d(2, 8, 2),
20
+ vector3d(3, 5, -5),
21
+ vector3d(-3, 6, 6),
22
+ vector3d(6, 3, 3)
23
+ ]
24
+
25
+ for pos in positions:
26
+ intensity = random.uniform(0.4, .8)
27
+ engine.add_light(Light(position=pos, color=Color.white, intensity=intensity))
28
+
29
+ EXAMPLE_DIR = Path(__file__).parent
30
+ scripts_dir = EXAMPLE_DIR / "scripts"
31
+
32
+ cylinder = Cylinder(vector3d.zero, 2, .5, Color.light_green, 64, vector3d(40, 60, 100), "Cylinder")
33
+ cylinder.attach(scripts_dir/"cylinder.py", engine.context)
34
+ engine.add_object(cylinder)
35
+
36
+ # cuboid = Cuboid(vector3d(3, 2, 5), color=Color.orange, size=vector3d(2, 1, 3))
37
+ # engine.add_object(cuboid)
38
+ #
39
+ # sphere = Sphere(vector3d(0, 5, 2), color=Color.light_blue, radius=1, rings=32, segments=64)
40
+ # engine.add_object(sphere)
41
+
42
+ engine.run()
@@ -227,7 +227,6 @@ class Light:
227
227
  self.show = show
228
228
  self.name = name
229
229
 
230
-
231
230
  class Renderer:
232
231
  def __init__(self, width=800, height=600, flags=DOUBLEBUF | OPENGL):
233
232
  pygame.init()
@@ -321,7 +320,7 @@ class Renderer:
321
320
 
322
321
  def compute_light_matrix(self, light: Light):
323
322
  """Compute light-space projection * view for shadow mapping."""
324
- light_proj = Matrix44.orthogonal_projection(-10, 10, -10, 10, 1, 30)
323
+ light_proj = Matrix44.orthogonal_projection(-20, 20, -20, 20, 1, 30)
325
324
  light_view = Matrix44.look_at(
326
325
  eye=light.position.totuple(),
327
326
  target=(0, 0, 0),
@@ -365,9 +364,6 @@ class Renderer:
365
364
 
366
365
  self.ctx.screen.use()
367
366
 
368
- # ------------------------------------------
369
- # Render Functions
370
- # ------------------------------------------
371
367
  def render_plane(self, p1, p2, p3, color):
372
368
  normal = self._compute_normal(p1, p2, p3)
373
369
  vertices = np.array([
@@ -387,6 +383,102 @@ class Renderer:
387
383
  vao.release()
388
384
  vbo.release()
389
385
 
386
+
387
+ def render_cylinder(self, center, height, radius, color, segments=32, rotation=vector3d(0, 0, 0)):
388
+ vertices = []
389
+
390
+ # Helper functions for matrix multiplication
391
+ def apply_matrix(v: vector3d, m: Matrix44) -> vector3d:
392
+ vec4 = np.array([v.x, v.y, v.z, 1.0], dtype="f4")
393
+ transformed = m @ vec4
394
+ return vector3d(*transformed[:3])
395
+
396
+ def apply_matrix_normal(n: vector3d, m: Matrix44) -> vector3d:
397
+ vec4 = np.array([n.x, n.y, n.z, 0.0], dtype="f4") # w=0 for direction
398
+ transformed = m @ vec4
399
+ return vector3d(*transformed[:3]).normalized
400
+
401
+ # Precompute rotation matrix if rotation is provided
402
+ rot_x = Matrix44.from_x_rotation(math.radians(rotation.x))
403
+ rot_y = Matrix44.from_y_rotation(math.radians(rotation.y))
404
+ rot_z = Matrix44.from_z_rotation(math.radians(rotation.z))
405
+ rot_matrix = rot_z * rot_y * rot_x
406
+
407
+ for i in range(segments):
408
+ theta1 = 2 * math.pi * i / segments
409
+ theta2 = 2 * math.pi * (i + 1) / segments
410
+
411
+ # Top circle vertices
412
+ top1 = vector3d(radius * math.cos(theta1), height / 2, radius * math.sin(theta1))
413
+ top2 = vector3d(radius * math.cos(theta2), height / 2, radius * math.sin(theta2))
414
+
415
+ # Bottom circle vertices
416
+ bottom1 = vector3d(radius * math.cos(theta1), -height / 2, radius * math.sin(theta1))
417
+ bottom2 = vector3d(radius * math.cos(theta2), -height / 2, radius * math.sin(theta2))
418
+
419
+ # Apply rotation
420
+ top1 = apply_matrix(top1, rot_matrix)
421
+ top2 = apply_matrix(top2, rot_matrix)
422
+ bottom1 = apply_matrix(bottom1, rot_matrix)
423
+ bottom2 = apply_matrix(bottom2, rot_matrix)
424
+
425
+ # Translate to center
426
+ top1 += center
427
+ top2 += center
428
+ bottom1 += center
429
+ bottom2 += center
430
+
431
+ # Compute normals for sides
432
+ normal1 = vector3d(math.cos(theta1), 0, math.sin(theta1))
433
+ normal2 = vector3d(math.cos(theta2), 0, math.sin(theta2))
434
+ normal1 = apply_matrix_normal(normal1, rot_matrix)
435
+ normal2 = apply_matrix_normal(normal2, rot_matrix)
436
+
437
+ # Side quad (two triangles)
438
+ for tri in [(top1, bottom1, bottom2), (top1, bottom2, top2)]:
439
+ n1 = (tri[0] - center).normalized
440
+ n2 = (tri[1] - center).normalized
441
+ n3 = (tri[2] - center).normalized
442
+ vertices.extend([
443
+ *tri[0].totuple(), *color.to_rgb(), *n1.totuple(),
444
+ *tri[1].totuple(), *color.to_rgb(), *n2.totuple(),
445
+ *tri[2].totuple(), *color.to_rgb(), *n3.totuple(),
446
+ ])
447
+
448
+ # Top cap
449
+ top_center = vector3d(0, height / 2, 0)
450
+ top_center = apply_matrix(top_center, rot_matrix) + center
451
+ normal_top = apply_matrix_normal(vector3d(0, 1, 0), rot_matrix)
452
+ vertices.extend([
453
+ *top_center.totuple(), *color.to_rgb(), *normal_top.totuple(),
454
+ *top2.totuple(), *color.to_rgb(), *normal_top.totuple(),
455
+ *top1.totuple(), *color.to_rgb(), *normal_top.totuple(),
456
+ ])
457
+
458
+ # Bottom cap
459
+ bottom_center = vector3d(0, -height / 2, 0)
460
+ bottom_center = apply_matrix(bottom_center, rot_matrix) + center
461
+ normal_bottom = apply_matrix_normal(vector3d(0, -1, 0), rot_matrix)
462
+ vertices.extend([
463
+ *bottom_center.totuple(), *color.to_rgb(), *normal_bottom.totuple(),
464
+ *bottom1.totuple(), *color.to_rgb(), *normal_bottom.totuple(),
465
+ *bottom2.totuple(), *color.to_rgb(), *normal_bottom.totuple(),
466
+ ])
467
+
468
+ vertices = np.array(vertices, dtype="f4")
469
+ vbo = self.ctx.buffer(vertices.tobytes())
470
+ vao = self.ctx.vertex_array(
471
+ self.prog, [(vbo, "3f 3f 3f", "in_vert", "in_color", "in_normal")]
472
+ )
473
+ self._send_lights()
474
+ self.prog["light_space_matrix"].write(self.light_space_matrix.astype("f4").tobytes())
475
+ self.shadow_depth_tex.use(location=0)
476
+ self.prog["shadow_map"].value = 0
477
+ vao.render()
478
+ vao.release()
479
+ vbo.release()
480
+
481
+
390
482
  def render_quad(self, p1, p2, p3, p4, color):
391
483
  normal = self._compute_normal(p1, p2, p3)
392
484
  vertices = np.array([
File without changes
@@ -27,7 +27,8 @@ void main() {
27
27
 
28
28
  for (int i = 0; i < num_lights; i++) {
29
29
  vec3 light_dir = normalize(lights[i].position - frag_pos);
30
- float diff = max(dot(normal, light_dir), 0.0);
30
+ float ndotl = dot(normal, light_dir);
31
+ float diff = max(ndotl, 0.05); // stable at grazing angles
31
32
 
32
33
  // Project to [0,1] for shadow sampling
33
34
  vec3 proj_coords = frag_pos_light_space.xyz / frag_pos_light_space.w;
@@ -38,8 +39,8 @@ void main() {
38
39
  if (proj_coords.x >= 0.0 && proj_coords.x <= 1.0 &&
39
40
  proj_coords.y >= 0.0 && proj_coords.y <= 1.0) {
40
41
 
41
- float bias = max(0.02 * (1.0 - dot(normal, light_dir)), 0.005);
42
-
42
+ float ndotl = dot(normal, light_dir);
43
+ float bias = mix(0.002, 0.02, 1.0 - clamp(ndotl, 0.0, 1.0));
43
44
  // Simple 3x3 PCF
44
45
  ivec2 texSize = textureSize(shadow_map, 0);
45
46
  float texelSizeX = 1.0 / float(texSize.x);
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gamengine3d
3
- Version: 1.5.2
3
+ Version: 1.6.0
4
4
  Summary: A Unity-like 3D engine in Python using pygame
5
5
  Author-email: Samarth Javagal <samarthjavagal@gmail.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -75,4 +75,6 @@ class PlayerController:
75
75
  ```
76
76
  This minimal PlayerController shows how to attach a script to an object and respond to input.
77
77
 
78
+ You can run any built-in demo with ``gamengine3d demo <demo_name>`` and see all available options using ``gamengine3d demo -h``.
79
+
78
80
  The 2d version of ```gamengine3d``` is out under ``gamengine2d``
@@ -2,6 +2,7 @@ LICENSE.txt
2
2
  README.md
3
3
  pyproject.toml
4
4
  gamengine3d/__init__.py
5
+ gamengine3d/cli.py
5
6
  gamengine3d/context.py
6
7
  gamengine3d/engine.py
7
8
  gamengine3d/game_objects.py
@@ -9,8 +10,16 @@ gamengine3d/helper.py
9
10
  gamengine3d.egg-info/PKG-INFO
10
11
  gamengine3d.egg-info/SOURCES.txt
11
12
  gamengine3d.egg-info/dependency_links.txt
13
+ gamengine3d.egg-info/entry_points.txt
12
14
  gamengine3d.egg-info/requires.txt
13
15
  gamengine3d.egg-info/top_level.txt
16
+ gamengine3d/examples/__init__.py
17
+ gamengine3d/examples/basics.py
18
+ gamengine3d/examples/player_movement.py
19
+ gamengine3d/examples/the_everything_demo.py
20
+ gamengine3d/examples/scripts/cylinder.py
21
+ gamengine3d/examples/scripts/player_movement.py
22
+ gamengine3d/examples/scripts/settings.py
14
23
  gamengine3d/shaders/__init__.py
15
24
  gamengine3d/shaders/default.frag
16
25
  gamengine3d/shaders/default.vert
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ gamengine3d = gamengine3d.cli:main
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
 
6
6
  [project]
7
7
  name = "gamengine3d"
8
- version = "1.5.2"
8
+ version = "1.6.0"
9
9
  description = "A Unity-like 3D engine in Python using pygame"
10
10
  authors = [
11
11
  { name = "Samarth Javagal", email = "samarthjavagal@gmail.com" }
@@ -31,5 +31,8 @@ classifiers = [
31
31
  where = ["."]
32
32
  include = ["gamengine3d*"]
33
33
 
34
+ [project.scripts]
35
+ gamengine3d = "gamengine3d.cli:main"
36
+
34
37
  [tool.setuptools.package-data]
35
38
  "gamengine3d" = ["shaders/*.vert", "shaders/*.frag"]
File without changes
File without changes