self._set_input()
self._set_mouse_plane()
Background()
- self.items = [Box(world)]
+ self.items = [Box(world, self._mouse_plane_node, 3, self.cb_inst)]
taskMgr.add(self.on_frame, 'on_frame')
def _set_camera(self):
self.accept('mouse3-up', self.on_release)
def _set_mouse_plane(self):
- shape = BulletPlaneShape((0, -1, 0), 1)
+ shape = BulletPlaneShape((0, -1, 0), 0)
#self._mouse_plane_node = BulletRigidBodyNode('mouse plane')
self._mouse_plane_node = BulletGhostNode('mouse plane')
self._mouse_plane_node.addShape(shape)
def _get_hits(self):
if not base.mouseWatcherNode.has_mouse(): return []
- p_from = Point3() # in camera coordinates
- p_to = Point3() # in camera coordinates
+ p_from, p_to = Point3(), Point3() # in camera coordinates
base.camLens.extrude(base.mouseWatcherNode.get_mouse(), p_from, p_to)
p_from = render.get_relative_point(base.cam, p_from) # global coords
p_to = render.get_relative_point(base.cam, p_to) # global coords
[item.on_release() for item in self.items]
self._cursor.set_image('assets/buttons/arrowUpLeft.png')
+ def on_aspect_ratio_changed(self):
+ [item.on_aspect_ratio_changed() for item in self.items]
+
def on_frame(self, task):
hits = self._get_hits()
pos = None
[itm.on_mouse_move(pos) for itm in self.items]
return task.cont
+ def cb_inst(self, item):
+ self.items += [item]
+
def on_play(self):
[itm.play() for itm in self.items]