gamengine3d 1.18.0__tar.gz → 1.20.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.
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/PKG-INFO +1 -1
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/engine.py +7 -6
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/examples/scripts/solar_system.py +9 -5
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/examples/solar_system.py +1 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/game_objects.py +38 -20
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/helper.py +102 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/renderer.py +297 -127
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/shaders/default.frag +11 -13
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/shaders/default.vert +4 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d.egg-info/PKG-INFO +1 -1
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/pyproject.toml +1 -1
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/LICENSE.txt +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/README.md +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/__init__.py +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/cli.py +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/context.py +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/examples/__init__.py +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/examples/basics.py +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/examples/from_obj.py +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/examples/load_scene.py +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/examples/messages_demo.py +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/examples/objects/__init__.py +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/examples/objects/icosahedron.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/examples/player_movement.py +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/examples/save_scene.py +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/examples/scripts/cylinder.py +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/examples/scripts/message_receiver.py +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/examples/scripts/messanger_script.py +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/examples/scripts/player_movement.py +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/examples/scripts/settings.py +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/examples/the_everything_demo.py +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/obj_reader.py +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/0.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/1.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/2.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/3.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/4.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/5.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/6.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/7.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/8.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/9.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/A_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/B_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/C_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/D_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/E_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/F_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/G_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/H_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/I_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/J_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/K_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/L_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/M_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/N_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/O_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/P_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/Q_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/R_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/S_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/T_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/U_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/V_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/W_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/X_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/Y_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/Z_capital.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/__init__.py +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/a.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/ampersand.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/asterisk.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/at.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/b.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/backslash.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/brace_close.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/brace_open.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/bracket_close.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/bracket_open.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/c.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/caret.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/colon.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/comma.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/d.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/dash.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/dollar.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/dot.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/doublequote.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/e.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/equals.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/exclamation.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/f.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/g.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/greater.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/h.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/hash.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/i.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/j.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/k.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/l.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/less.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/m.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/n.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/o.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/p.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/paren_close.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/paren_open.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/percent.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/plus.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/q.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/question.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/r.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/s.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/semicolon.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/singlequote.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/slash.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/t.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/u.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/underscore.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/v.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/w.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/x.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/y.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/objects/z.obj +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/shaders/__init__.py +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/shaders/depth.frag +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d/shaders/depth.vert +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d.egg-info/SOURCES.txt +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d.egg-info/dependency_links.txt +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d.egg-info/entry_points.txt +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d.egg-info/requires.txt +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/gamengine3d.egg-info/top_level.txt +0 -0
- {gamengine3d-1.18.0 → gamengine3d-1.20.0}/setup.cfg +0 -0
|
@@ -217,7 +217,7 @@ class Engine:
|
|
|
217
217
|
|
|
218
218
|
return obj.is_point_in(pos)
|
|
219
219
|
|
|
220
|
-
def draw_cuboid(self, pos: vector3d=vector3d.zero, size: vector3d=vector3d(2), rotation: vector3d=vector3d.zero, color: Color = Color.light_blue):
|
|
220
|
+
def draw_cuboid(self, pos: vector3d=vector3d.zero, size: vector3d=vector3d(2), rotation: vector3d=vector3d.zero, color: Color = Color.light_blue, emit: bool = False):
|
|
221
221
|
faces = [
|
|
222
222
|
[0, 1, 3, 2],
|
|
223
223
|
[4, 6, 7, 5],
|
|
@@ -252,14 +252,15 @@ class Engine:
|
|
|
252
252
|
corners[face_idx[1]],
|
|
253
253
|
corners[face_idx[2]],
|
|
254
254
|
corners[face_idx[3]],
|
|
255
|
-
color=color
|
|
255
|
+
color=color,
|
|
256
|
+
emit=emit,
|
|
256
257
|
)
|
|
257
258
|
|
|
258
|
-
def draw_sphere(self, pos: vector3d=vector3d.zero, radius: int=2, color: Color=Color.light_red, segments=32, rings=16):
|
|
259
|
-
self.renderer.render_sphere(center=pos, radius=radius, color=color, segments=segments, rings=rings)
|
|
259
|
+
def draw_sphere(self, pos: vector3d=vector3d.zero, radius: int=2, color: Color=Color.light_red, segments=32, rings=16, emit: bool = False):
|
|
260
|
+
self.renderer.render_sphere(center=pos, radius=radius, color=color, segments=segments, rings=rings, emit=emit)
|
|
260
261
|
|
|
261
|
-
def draw_cylinder(self, pos: vector3d=vector3d.zero, length: int=2, radius: int=.5, color: Color=Color.light_yellow, segments: int=32, rotation: vector3d=vector3d.zero):
|
|
262
|
-
self.renderer.render_cylinder(center=pos, height=length, radius=radius, color=color, segments=segments, rotation=rotation)
|
|
262
|
+
def draw_cylinder(self, pos: vector3d=vector3d.zero, length: int=2, radius: int=.5, color: Color=Color.light_yellow, segments: int=32, rotation: vector3d=vector3d.zero, emit: bool = False):
|
|
263
|
+
self.renderer.render_cylinder(center=pos, height=length, radius=radius, color=color, segments=segments, rotation=rotation, emit=emit)
|
|
263
264
|
|
|
264
265
|
def attach(self, path):
|
|
265
266
|
script = Script(self, path, self.context)
|
|
@@ -11,7 +11,7 @@ class Planet:
|
|
|
11
11
|
self.name = name
|
|
12
12
|
|
|
13
13
|
def draw(self):
|
|
14
|
-
self.context.functions.draw_sphere(pos=self.pos, radius=self.radius, color=self.color)
|
|
14
|
+
self.context.functions.draw_sphere(pos=self.pos, radius=self.radius, color=self.color, emit=True)
|
|
15
15
|
|
|
16
16
|
def update(self, dt, planets):
|
|
17
17
|
for planet in planets:
|
|
@@ -27,11 +27,15 @@ class Planet:
|
|
|
27
27
|
class SolarSystem:
|
|
28
28
|
def __init__(self, obj: Engine, context: Context):
|
|
29
29
|
self.engine = obj
|
|
30
|
+
mercury_distance = 30
|
|
31
|
+
mercury_mass = .001
|
|
32
|
+
mercury_orbital_speed = 20
|
|
30
33
|
self.context = context
|
|
31
|
-
self.planets = [Planet(self.context, Color.light_yellow,
|
|
32
|
-
Planet(self.context, Color.
|
|
33
|
-
Planet(self.context, Color.
|
|
34
|
-
|
|
34
|
+
self.planets = [Planet(self.context, Color.light_yellow, 25, vector3d.zero, mercury_mass * 10e6, "Sun", vector3d.zero),
|
|
35
|
+
Planet(self.context, Color.light_red, .6, vector3d(mercury_distance, 0), mercury_mass, "Mercury", vector3d(0, 0, mercury_orbital_speed)),
|
|
36
|
+
Planet(self.context, Color.orange, .9, vector3d(mercury_distance * 1.86, 0), mercury_mass * 14.8, "Venus", vector3d(0, 0, mercury_orbital_speed * .74)),
|
|
37
|
+
Planet(self.context, Color.blue, 1.4, vector3d(mercury_distance * 2.58, 0), mercury_mass * 18.1, "Earth", vector3d(0, 0, mercury_orbital_speed * .63)),
|
|
38
|
+
Planet(self.context, Color.red, 1.4, vector3d(mercury_distance * 3.93, 0), mercury_mass * 1.94, "Mars", vector3d(0, 0, mercury_orbital_speed * .51))]
|
|
35
39
|
|
|
36
40
|
def update(self, dt):
|
|
37
41
|
for planet in self.planets:
|
|
@@ -53,7 +53,7 @@ class Cuboid(GameObject):
|
|
|
53
53
|
color: Color = Color.green,
|
|
54
54
|
name: str = "Cuboid",
|
|
55
55
|
rotation: vector3d = vector3d.zero,
|
|
56
|
-
visible: bool = True):
|
|
56
|
+
visible: bool = True, emit: bool = False):
|
|
57
57
|
super().__init__(name)
|
|
58
58
|
self.name = name
|
|
59
59
|
self.pos = pos
|
|
@@ -62,6 +62,7 @@ class Cuboid(GameObject):
|
|
|
62
62
|
self.rotation = rotation
|
|
63
63
|
self.visible = visible
|
|
64
64
|
self.rigid_body = None
|
|
65
|
+
self.emit = emit
|
|
65
66
|
|
|
66
67
|
self.faces = [
|
|
67
68
|
[0, 1, 3, 2],
|
|
@@ -98,7 +99,7 @@ class Cuboid(GameObject):
|
|
|
98
99
|
half = np.array([self.size.x / 2, self.size.y / 2, self.size.z / 2])
|
|
99
100
|
|
|
100
101
|
rot = self.get_rotation_matrix()
|
|
101
|
-
inv_rot = rot.T
|
|
102
|
+
inv_rot = rot.T
|
|
102
103
|
|
|
103
104
|
local_point = inv_rot @ (p - center)
|
|
104
105
|
|
|
@@ -114,7 +115,8 @@ class Cuboid(GameObject):
|
|
|
114
115
|
corners[face_idx[1]],
|
|
115
116
|
corners[face_idx[2]],
|
|
116
117
|
corners[face_idx[3]],
|
|
117
|
-
color=self.color
|
|
118
|
+
color=self.color,
|
|
119
|
+
emit=self.emit,
|
|
118
120
|
)
|
|
119
121
|
|
|
120
122
|
def serialize(self):
|
|
@@ -126,7 +128,8 @@ class Cuboid(GameObject):
|
|
|
126
128
|
"name": self.name,
|
|
127
129
|
"rotation": self.rotation.totuple(),
|
|
128
130
|
"scripts": self.script_paths,
|
|
129
|
-
"visible": self.visible
|
|
131
|
+
"visible": self.visible,
|
|
132
|
+
"emit": self.emit,
|
|
130
133
|
}
|
|
131
134
|
|
|
132
135
|
@staticmethod
|
|
@@ -138,8 +141,9 @@ class Cuboid(GameObject):
|
|
|
138
141
|
rotation = data["rotation"]
|
|
139
142
|
scripts = data["scripts"]
|
|
140
143
|
visible = data["visible"]
|
|
144
|
+
emit = data["emit"]
|
|
141
145
|
|
|
142
|
-
obj = Cuboid(pos=vector3d.fromtuple(pos), color=Color.RGB(*color), size=vector3d.fromtuple(size), name=name, rotation=vector3d.fromtuple(rotation), visible=visible)
|
|
146
|
+
obj = Cuboid(pos=vector3d.fromtuple(pos), color=Color.RGB(*color), size=vector3d.fromtuple(size), name=name, rotation=vector3d.fromtuple(rotation), visible=visible, emit=emit)
|
|
143
147
|
obj.attach_scripts(scripts, context)
|
|
144
148
|
|
|
145
149
|
return obj
|
|
@@ -150,7 +154,8 @@ class Sphere(GameObject):
|
|
|
150
154
|
color: Color = Color.green,
|
|
151
155
|
segments: int = 32,
|
|
152
156
|
rings: int = 16,
|
|
153
|
-
name: str = "Sphere", visible=True
|
|
157
|
+
name: str = "Sphere", visible=True,
|
|
158
|
+
emit: bool = False):
|
|
154
159
|
super().__init__(name)
|
|
155
160
|
self.name = name
|
|
156
161
|
self.pos = pos
|
|
@@ -159,6 +164,7 @@ class Sphere(GameObject):
|
|
|
159
164
|
self.segments = segments
|
|
160
165
|
self.rings = rings
|
|
161
166
|
self.visible = visible
|
|
167
|
+
self.emit = emit
|
|
162
168
|
|
|
163
169
|
def is_point_in(self, point: vector3d) -> bool:
|
|
164
170
|
dx = point.x - self.pos.x
|
|
@@ -170,7 +176,7 @@ class Sphere(GameObject):
|
|
|
170
176
|
def draw(self, renderer: Renderer):
|
|
171
177
|
if not self.visible:
|
|
172
178
|
return
|
|
173
|
-
renderer.render_sphere(self.pos, self.radius, self.color, self.segments, self.rings)
|
|
179
|
+
renderer.render_sphere(self.pos, self.radius, self.color, self.segments, self.rings, emit=self.emit)
|
|
174
180
|
|
|
175
181
|
def serialize(self):
|
|
176
182
|
return {
|
|
@@ -182,7 +188,8 @@ class Sphere(GameObject):
|
|
|
182
188
|
"rings": self.rings,
|
|
183
189
|
"name": self.name,
|
|
184
190
|
"scripts": self.script_paths,
|
|
185
|
-
"visible": self.visible
|
|
191
|
+
"visible": self.visible,
|
|
192
|
+
"emit": self.emit,
|
|
186
193
|
}
|
|
187
194
|
|
|
188
195
|
@staticmethod
|
|
@@ -195,8 +202,9 @@ class Sphere(GameObject):
|
|
|
195
202
|
name = data["name"]
|
|
196
203
|
scripts = data["scripts"]
|
|
197
204
|
visible = data["visible"]
|
|
205
|
+
emit = data["emit"]
|
|
198
206
|
|
|
199
|
-
obj = Sphere(pos=vector3d.fromtuple(pos), color=Color.RGB(*color), radius=radius, segments=segments, rings=rings, name=name, visible=visible)
|
|
207
|
+
obj = Sphere(pos=vector3d.fromtuple(pos), color=Color.RGB(*color), radius=radius, segments=segments, rings=rings, name=name, visible=visible, emit=emit)
|
|
200
208
|
obj.attach_scripts(scripts, context)
|
|
201
209
|
|
|
202
210
|
return obj
|
|
@@ -208,7 +216,8 @@ class Cylinder(GameObject):
|
|
|
208
216
|
color: Color = Color.light_yellow,
|
|
209
217
|
segments: int = 32,
|
|
210
218
|
rotation: vector3d = vector3d.zero,
|
|
211
|
-
name: str = "Cylinder", visible: bool = True
|
|
219
|
+
name: str = "Cylinder", visible: bool = True,
|
|
220
|
+
emit: bool = False):
|
|
212
221
|
super().__init__(name)
|
|
213
222
|
self.name = name
|
|
214
223
|
self.pos = pos
|
|
@@ -218,6 +227,7 @@ class Cylinder(GameObject):
|
|
|
218
227
|
self.segments = segments
|
|
219
228
|
self.rotation = rotation # Euler angles in degrees
|
|
220
229
|
self.visible = visible
|
|
230
|
+
self.emit = emit
|
|
221
231
|
|
|
222
232
|
def get_rotation_matrix(self):
|
|
223
233
|
rx, ry, rz = math.radians(self.rotation.x), math.radians(self.rotation.y), math.radians(self.rotation.z)
|
|
@@ -252,7 +262,7 @@ class Cylinder(GameObject):
|
|
|
252
262
|
if not self.visible:
|
|
253
263
|
return
|
|
254
264
|
renderer.render_cylinder(center=self.pos, height=self.length, radius=self.radius,
|
|
255
|
-
color=self.color, segments=self.segments, rotation=self.rotation)
|
|
265
|
+
color=self.color, segments=self.segments, rotation=self.rotation, emit=self.emit)
|
|
256
266
|
|
|
257
267
|
def serialize(self):
|
|
258
268
|
return {
|
|
@@ -266,6 +276,7 @@ class Cylinder(GameObject):
|
|
|
266
276
|
"name": self.name,
|
|
267
277
|
"scripts": self.script_paths,
|
|
268
278
|
"visible": self.visible,
|
|
279
|
+
"emit": self.emit,
|
|
269
280
|
}
|
|
270
281
|
|
|
271
282
|
@staticmethod
|
|
@@ -279,8 +290,9 @@ class Cylinder(GameObject):
|
|
|
279
290
|
name = data["name"]
|
|
280
291
|
scripts = data["scripts"]
|
|
281
292
|
visible = data["visible"]
|
|
293
|
+
emit = data["emit"]
|
|
282
294
|
|
|
283
|
-
obj = Cylinder(pos=vector3d.fromtuple(pos), length=length, radius=radius, color=Color.RGB(*color), segments=segments, rotation=vector3d.fromtuple(rotation), name=name, visible=visible)
|
|
295
|
+
obj = Cylinder(pos=vector3d.fromtuple(pos), length=length, radius=radius, color=Color.RGB(*color), segments=segments, rotation=vector3d.fromtuple(rotation), name=name, visible=visible, emit=emit)
|
|
284
296
|
obj.attach_scripts(scripts, context)
|
|
285
297
|
|
|
286
298
|
return obj
|
|
@@ -291,7 +303,7 @@ class ObjModel(GameObject):
|
|
|
291
303
|
name: str = "ObjModel",
|
|
292
304
|
scale: vector3d = vector3d(1.0),
|
|
293
305
|
rotation: vector3d = vector3d.zero,
|
|
294
|
-
file_path: str = "", visible: bool = True):
|
|
306
|
+
file_path: str = "", visible: bool = True, emit: bool = False):
|
|
295
307
|
super().__init__(name)
|
|
296
308
|
self.name = name
|
|
297
309
|
self.pos = pos
|
|
@@ -300,6 +312,7 @@ class ObjModel(GameObject):
|
|
|
300
312
|
self.visible = visible
|
|
301
313
|
self.scale = scale
|
|
302
314
|
self.rotation = rotation
|
|
315
|
+
self.emit = emit
|
|
303
316
|
|
|
304
317
|
self.vertices = []
|
|
305
318
|
self.faces = []
|
|
@@ -334,12 +347,11 @@ class ObjModel(GameObject):
|
|
|
334
347
|
return
|
|
335
348
|
|
|
336
349
|
for face in self.faces:
|
|
337
|
-
# Rotate, scale, then translate each vertex
|
|
338
350
|
p1 = self.rotate_vertex(self.vertices[face[0]]) * self.scale + self.pos
|
|
339
351
|
p2 = self.rotate_vertex(self.vertices[face[1]]) * self.scale + self.pos
|
|
340
352
|
p3 = self.rotate_vertex(self.vertices[face[2]]) * self.scale + self.pos
|
|
341
353
|
|
|
342
|
-
renderer.render_plane(p1=p1, p2=p2, p3=p3, color=self.color)
|
|
354
|
+
renderer.render_plane(p1=p1, p2=p2, p3=p3, color=self.color, emit=self.emit)
|
|
343
355
|
|
|
344
356
|
def get_size(self):
|
|
345
357
|
"""Compute axis-aligned bounding box after rotation and scaling."""
|
|
@@ -373,6 +385,7 @@ class ObjModel(GameObject):
|
|
|
373
385
|
"rotation": self.rotation.totuple(), # Serialize rotation
|
|
374
386
|
"file_path": self.file_path,
|
|
375
387
|
"visible": self.visible,
|
|
388
|
+
"emit": self.emit,
|
|
376
389
|
}
|
|
377
390
|
|
|
378
391
|
@staticmethod
|
|
@@ -385,8 +398,9 @@ class ObjModel(GameObject):
|
|
|
385
398
|
rotation = vector3d.fromtuple(data.get("rotation", (0,0,0)))
|
|
386
399
|
visible = data["visible"]
|
|
387
400
|
file_path = data["file_path"]
|
|
401
|
+
emit = data["emit"]
|
|
388
402
|
|
|
389
|
-
obj = ObjModel(pos=pos, name=name, color=color, scale=scale, rotation=rotation, visible=visible, file_path=file_path)
|
|
403
|
+
obj = ObjModel(pos=pos, name=name, color=color, scale=scale, rotation=rotation, visible=visible, file_path=file_path, emit=emit)
|
|
390
404
|
obj.attach_scripts(scripts, context)
|
|
391
405
|
return obj
|
|
392
406
|
|
|
@@ -402,7 +416,7 @@ class Text(GameObject):
|
|
|
402
416
|
visible: bool = True,
|
|
403
417
|
spacing: float = .2,
|
|
404
418
|
rotation: vector3d = vector3d.zero,
|
|
405
|
-
center: bool = False):
|
|
419
|
+
center: bool = False, emit: bool = False):
|
|
406
420
|
super().__init__(name)
|
|
407
421
|
self.name = name
|
|
408
422
|
self.pos = pos
|
|
@@ -414,6 +428,7 @@ class Text(GameObject):
|
|
|
414
428
|
self.rotation = rotation
|
|
415
429
|
self.center = center
|
|
416
430
|
self.script_paths = []
|
|
431
|
+
self.emit = emit
|
|
417
432
|
|
|
418
433
|
self.symbol_map = {
|
|
419
434
|
'!': "exclamation",
|
|
@@ -502,7 +517,8 @@ class Text(GameObject):
|
|
|
502
517
|
scale=self.scale,
|
|
503
518
|
rotation=self.rotation,
|
|
504
519
|
file_path=str(file_path),
|
|
505
|
-
visible=self.visible
|
|
520
|
+
visible=self.visible,
|
|
521
|
+
emit=self.emit,
|
|
506
522
|
)
|
|
507
523
|
digits.append(digit_model)
|
|
508
524
|
x_offset += width + self.spacing
|
|
@@ -528,7 +544,8 @@ class Text(GameObject):
|
|
|
528
544
|
"name": self.name,
|
|
529
545
|
"scripts": self.script_paths,
|
|
530
546
|
"visible": self.visible,
|
|
531
|
-
"center": self.center
|
|
547
|
+
"center": self.center,
|
|
548
|
+
"emit": self.emit,
|
|
532
549
|
}
|
|
533
550
|
|
|
534
551
|
@staticmethod
|
|
@@ -543,10 +560,11 @@ class Text(GameObject):
|
|
|
543
560
|
scripts = data["scripts"]
|
|
544
561
|
visible = data["visible"]
|
|
545
562
|
center = data.get("center", False)
|
|
563
|
+
emit = data["emit"]
|
|
546
564
|
|
|
547
565
|
obj = Text(pos=pos, text=text, color=color, scale=scale,
|
|
548
566
|
rotation=rotation, spacing=spacing, name=name, visible=visible,
|
|
549
|
-
center=center)
|
|
567
|
+
center=center, emit=emit)
|
|
550
568
|
obj.attach_scripts(scripts, context)
|
|
551
569
|
|
|
552
570
|
return obj
|
|
@@ -421,3 +421,105 @@ def get_forward(rotation):
|
|
|
421
421
|
fy = 0
|
|
422
422
|
fz = math.cos(yaw)
|
|
423
423
|
return vector3d(fx, fy, fz)
|
|
424
|
+
|
|
425
|
+
class AreaLight:
|
|
426
|
+
def __init__(self, shape: str, params: dict, color: Color, intensity: float = 1.0, samples: int = 4, name: str = "AreaLight"):
|
|
427
|
+
self.shape = shape
|
|
428
|
+
self.params = params
|
|
429
|
+
self.color = color
|
|
430
|
+
self.intensity = intensity
|
|
431
|
+
self.samples = max(1, int(samples))
|
|
432
|
+
self.name = name
|
|
433
|
+
self.is_area = True
|
|
434
|
+
|
|
435
|
+
@staticmethod
|
|
436
|
+
def _lerp(a: vector3d, b: vector3d, t: float) -> vector3d:
|
|
437
|
+
return a * (1.0 - t) + b * t
|
|
438
|
+
|
|
439
|
+
def sample_points(self):
|
|
440
|
+
"""Return a list of vector3d sample positions on the surface."""
|
|
441
|
+
if self.shape == 'plane':
|
|
442
|
+
corners = self.params.get('corners')
|
|
443
|
+
if not corners or len(corners) < 4:
|
|
444
|
+
raise ValueError("AreaLight plane requires 'corners' list of 4 vector3d")
|
|
445
|
+
p1, p2, p3, p4 = corners
|
|
446
|
+
n = int(math.sqrt(self.samples))
|
|
447
|
+
if n * n < self.samples:
|
|
448
|
+
n += 1
|
|
449
|
+
points = []
|
|
450
|
+
count = 0
|
|
451
|
+
for i in range(n):
|
|
452
|
+
for j in range(n):
|
|
453
|
+
if count >= self.samples:
|
|
454
|
+
break
|
|
455
|
+
u = (i + 0.5) / n
|
|
456
|
+
v = (j + 0.5) / n
|
|
457
|
+
a = self._lerp(p1, p2, u)
|
|
458
|
+
b = self._lerp(p4, p3, u)
|
|
459
|
+
pos = self._lerp(a, b, v)
|
|
460
|
+
points.append(pos)
|
|
461
|
+
count += 1
|
|
462
|
+
if count >= self.samples:
|
|
463
|
+
break
|
|
464
|
+
return points
|
|
465
|
+
|
|
466
|
+
elif self.shape == 'sphere':
|
|
467
|
+
center = self.params.get('center')
|
|
468
|
+
radius = self.params.get('radius')
|
|
469
|
+
if center is None or radius is None:
|
|
470
|
+
raise ValueError("AreaLight sphere requires 'center' and 'radius'")
|
|
471
|
+
pts = []
|
|
472
|
+
n = self.samples
|
|
473
|
+
for i in range(n):
|
|
474
|
+
z = 1.0 - 2.0 * (i + 0.5) / n
|
|
475
|
+
r = math.sqrt(max(0.0, 1.0 - z * z))
|
|
476
|
+
phi = 2.0 * math.pi * ((i * 0.618033988749895) % 1.0)
|
|
477
|
+
x = r * math.cos(phi)
|
|
478
|
+
y = r * math.sin(phi)
|
|
479
|
+
pos = vector3d(center.x + radius * x, center.y + radius * z, center.z + radius * y)
|
|
480
|
+
pts.append(pos)
|
|
481
|
+
return pts
|
|
482
|
+
|
|
483
|
+
elif self.shape == 'cylinder':
|
|
484
|
+
center = self.params.get('center')
|
|
485
|
+
height = self.params.get('height')
|
|
486
|
+
radius = self.params.get('radius')
|
|
487
|
+
rotation = self.params.get('rotation', vector3d.zero)
|
|
488
|
+
if center is None or height is None or radius is None:
|
|
489
|
+
raise ValueError("AreaLight cylinder requires 'center', 'height', and 'radius'")
|
|
490
|
+
pts = []
|
|
491
|
+
n_axial = max(1, int(math.sqrt(self.samples)))
|
|
492
|
+
n_angular = max(1, int(math.ceil(self.samples / n_axial)))
|
|
493
|
+
count = 0
|
|
494
|
+
for i in range(n_axial):
|
|
495
|
+
y = -height / 2.0 + (i + 0.5) * (height / n_axial)
|
|
496
|
+
for j in range(n_angular):
|
|
497
|
+
if count >= self.samples:
|
|
498
|
+
break
|
|
499
|
+
theta = 2.0 * math.pi * (j + 0.5) / n_angular
|
|
500
|
+
x = radius * math.cos(theta)
|
|
501
|
+
z = radius * math.sin(theta)
|
|
502
|
+
local = vector3d(x, y, z)
|
|
503
|
+
# apply rotation (Euler degrees) if provided
|
|
504
|
+
rx, ry, rz = math.radians(rotation.x), math.radians(rotation.y), math.radians(rotation.z)
|
|
505
|
+
cx, sx = math.cos(rx), math.sin(rx)
|
|
506
|
+
cy, sy = math.cos(ry), math.sin(ry)
|
|
507
|
+
cz, sz = math.cos(rz), math.sin(rz)
|
|
508
|
+
Rx = [[1,0,0],[0,cx,-sx],[0,sx,cx]]
|
|
509
|
+
Ry = [[cy,0,sy],[0,1,0],[-sy,0,cy]]
|
|
510
|
+
Rz = [[cz,-sz,0],[sz,cz,0],[0,0,1]]
|
|
511
|
+
def mat_mult(A, B):
|
|
512
|
+
return [[sum(A[i][k]*B[k][j] for k in range(3)) for j in range(3)] for i in range(3)]
|
|
513
|
+
R = mat_mult(mat_mult(Rz, Ry), Rx)
|
|
514
|
+
lx = R[0][0]*local.x + R[0][1]*local.y + R[0][2]*local.z
|
|
515
|
+
ly = R[1][0]*local.x + R[1][1]*local.y + R[1][2]*local.z
|
|
516
|
+
lz = R[2][0]*local.x + R[2][1]*local.y + R[2][2]*local.z
|
|
517
|
+
pos = vector3d(center.x + lx, center.y + ly, center.z + lz)
|
|
518
|
+
pts.append(pos)
|
|
519
|
+
count += 1
|
|
520
|
+
if count >= self.samples:
|
|
521
|
+
break
|
|
522
|
+
return pts
|
|
523
|
+
|
|
524
|
+
else:
|
|
525
|
+
raise ValueError(f"Unsupported area light shape: {self.shape}")
|