ya2 · news · projects · code · about

basketball
authorFlavio Calva <f.calva@gmail.com>
Tue, 25 Jan 2022 18:23:40 +0000 (19:23 +0100)
committerFlavio Calva <f.calva@gmail.com>
Tue, 25 Jan 2022 18:23:40 +0000 (19:23 +0100)
pmachines/items/basketball.py [new file with mode: 0644]
pmachines/items/item.py
pmachines/scene.py
prj.org

diff --git a/pmachines/items/basketball.py b/pmachines/items/basketball.py
new file mode 100644 (file)
index 0000000..1f7236d
--- /dev/null
@@ -0,0 +1,12 @@
+from panda3d.bullet import BulletSphereShape, BulletRigidBodyNode, BulletGhostNode
+from pmachines.items.item import Item
+
+
+class Basketball(Item):
+
+    def __init__(self, world, plane_node, count, cb_inst, curr_bottom, repos):
+        super().__init__(world, plane_node, count, cb_inst, curr_bottom, repos, 'assets/gltf/basketball/basketball.gltf', .4)
+
+    def _set_phys(self):
+        super()._set_phys()
+        self._shape = BulletSphereShape(1)
index b3c711db74092288bfbe2fc725f5bfdc4acfeab8..cf74edbbec924661d41ca5ecbc6712f5303d1640 100644 (file)
@@ -14,7 +14,7 @@ class Command:
 
 class Item:
 
-    def __init__(self, world, plane_node, count, cb_inst, curr_bottom, scene_repos, model_path):
+    def __init__(self, world, plane_node, count, cb_inst, curr_bottom, scene_repos, model_path, model_scale=1):
         self._world = world
         self._plane_node = plane_node
         self._count = count
@@ -25,6 +25,7 @@ class Item:
         self.repos_done = False
         self._curr_bottom = curr_bottom
         self._scene_repos = scene_repos
+        self._model_scale = model_scale
         self._model_path = model_path
         self._commands = []
         self._command_idx = -1
@@ -37,6 +38,7 @@ class Item:
         self._model.flatten_light()
         self._model.reparent_to(self._np)
         self._set_outline_model()
+        self._np.set_scale(model_scale)
         set_srgb(self._outline_model)
         self._model.hide(BitMask32(0x01))
         self._outline_model.hide(BitMask32(0x01))
@@ -153,6 +155,7 @@ class Item:
             self._model.reparent_to(self._np)
             self._np.set_pos(pos)
             self._set_outline_model()
+            self._np.set_scale(self._model_scale)
             self._model.show(BitMask32(0x01))
             self._outline_model.hide(BitMask32(0x01))
             self._instantiated = True
index da2045c36139f1d9f9f32efe8c6cf58d9c6b1562..a48bb275285d04a7e1bd934325f5926a5b8c391b 100644 (file)
@@ -10,6 +10,7 @@ from pmachines.items.background import Background
 from pmachines.items.box import Box
 from pmachines.items.shelf import Shelf
 from pmachines.items.domino import Domino
+from pmachines.items.basketball import Basketball
 from pmachines.sidepanel import SidePanel
 from lib.engine.gui.cursor import MouseCursor
 from lib.lib.p3d.gfx import P3dGfxMgr
@@ -54,6 +55,7 @@ class Scene(DirectObject):
         self.items = [Box(self._world, self._mouse_plane_node, 3, self.cb_inst, self.current_bottom, self.repos)]
         self.items += [Shelf(self._world, self._mouse_plane_node, 3, self.cb_inst, self.current_bottom, self.repos)]
         self.items += [Domino(self._world, self._mouse_plane_node, 3, self.cb_inst, self.current_bottom, self.repos)]
+        self.items += [Basketball(self._world, self._mouse_plane_node, 3, self.cb_inst, self.current_bottom, self.repos)]
         self._commands = []
         self._command_idx = 0
 
diff --git a/prj.org b/prj.org
index 0432c3c5ce18fb27f0031695ed92c1f3bf91d52d..f0ffad191ef227b36a8819a3d794e3da39a840c5 100644 (file)
--- a/prj.org
+++ b/prj.org
@@ -1,8 +1,8 @@
 * issues
 * todo
 ** implement other items
-*** basketball
 *** teeter_tooter
+** move the overlapping object a bit farther
 ** create one level per item, then levels with more items
 *** e.g. item1, item2, item1+2, item3, item1+2+3, ...
 ** refactoring