+from os.path import exists
from panda3d.core import AmbientLight, DirectionalLight, Point3, Texture, \
TextPropertiesManager, TextNode, Spotlight, PerspectiveLens, BitMask32
from panda3d.bullet import BulletPlaneShape, BulletGhostNode
class Scene(DirectObject):
- def __init__(self, world, exit_cb, auto_close_instr):
+ def __init__(self, world, exit_cb, auto_close_instr, dbg_items):
super().__init__()
self._world = world
self._exit_cb = exit_cb
+ self._dbg_items = dbg_items
self._set_camera()
self._cursor = MouseCursor(
'assets/buttons/arrowUpLeft.png', (.04, 1, .04), (.5, .5, .5, 1),
btns += [btn]
self.__home_btn, self.__info_btn, self.__right_btn, self.__next_btn, \
self.__prev_btn, self.__rewind_btn = btns
+ if self._dbg_items:
+ self._info_txt = OnscreenText(
+ '', parent=base.a2dTopRight, scale=0.04,
+ pos=(-.03, -.06), fg=(.9, .9, .9, 1), align=TextNode.A_right)
def _unset_gui(self):
btns = [
self.__home_btn, self.__info_btn, self.__right_btn,
self.__next_btn, self.__prev_btn, self.__rewind_btn]
[btn.destroy() for btn in btns]
+ if self._dbg_items:
+ self._info_txt.destroy()
def _set_spotlight(self, name, pos, look_at, color, shadows=False):
light = Spotlight(name)
p_from, p_to = P3dGfxMgr.world_from_to(base.mouseWatcherNode.get_mouse())
return self._world.ray_test_all(p_from, p_to).get_hits()
+ def _update_info(self, item):
+ txt = ''
+ if item:
+ txt = '%.3f %.3f\n%.3f°' % (
+ item._np.get_x(), item._np.get_z(), item._np.get_r())
+ self._info_txt['text'] = txt
+
def _on_click(self, method):
if self._paused:
return
[itm.on_mouse_off() for itm in items_no_hit]
if pos and self._item_active:
self._item_active.on_mouse_move(pos)
+ if self._dbg_items:
+ self._update_info(items_hit[0] if items_hit else None)
return task.cont
def cb_inst(self, item):