diff --git a/QPanda3D/Helpers/Env_Grid_Maker.py b/QPanda3D/Helpers/Env_Grid_Maker.py new file mode 100644 index 00000000..7f0fd0ec --- /dev/null +++ b/QPanda3D/Helpers/Env_Grid_Maker.py @@ -0,0 +1,279 @@ +# -*- coding: utf-8-*- +""" +Module : Env_Grid_Maker +Author : Saifeddine ALOUI + code from Forklift 's code snippet could be found on panda3D's website +Description : + Creates a 3D implementation of grid that shows axes in 3 possible planes + +""" +from panda3d.core import * +from direct.interval.IntervalGlobal import * + +class Env_Grid_Maker: + def __init__(self, XYPlaneShow = True, XZPlaneShow = False, YZPlaneShow = False, endCapLinesShow = True, XSize = 50, YSize = 50, ZSize = 50, gridStep = 10, subdiv = 10): + #Create line objects + self.axisLines = LineSegs() + self.gridLines = LineSegs() + self.subdivLines = LineSegs() + + #Init passed variables + self.XSize = XSize + self.YSize = YSize + self.ZSize = ZSize + self.gridStep = gridStep + self.subdiv = subdiv + + #Init default variables + + #Plane and end cap line visibility (1 is show, 0 is hide) + self.XYPlaneShow = XYPlaneShow + self.XZPlaneShow = XZPlaneShow + self.YZPlaneShow = YZPlaneShow + self.endCapLinesShow = endCapLinesShow + + #Alpha variables for each plane + #self.XYPlaneAlpha = 1 + #self.XZPlaneAlpha = 1 + #self.YZPlaneAlpha = 1 + + #Colors (RGBA passed as a VBase4 object) + self.XAxisColor = VBase4(1, 0, 0, 1) + self.YAxisColor = VBase4(0, 1, 0, 1) + self.ZAxisColor = VBase4(0, 0, 1, 1) + self.gridColor = VBase4(1, 1, 1, 1) + self.subdivColor = VBase4(.35, .35, .35, 1) + + #Line thicknesses (in pixels) + self.axisThickness = 3 + self.gridThickness = 1 + self.subdivThickness = 1 + + + def create(self): + #Set line thicknesses + self.axisLines.setThickness(self.axisThickness) + self.gridLines.setThickness(self.gridThickness) + self.subdivLines.setThickness(self.subdivThickness) + + if(self.XSize != 0): + #Draw X axis line + self.axisLines.setColor(self.XAxisColor) + self.axisLines.moveTo(-(self.XSize), 0, 0) + self.axisLines.drawTo(self.XSize, 0, 0) + + if(self.YSize != 0): + #Draw Y axis line + self.axisLines.setColor(self.YAxisColor) + self.axisLines.moveTo(0, -(self.YSize), 0) + self.axisLines.drawTo(0, self.YSize, 0) + + if(self.ZSize != 0): + #Draw Z axis line + self.axisLines.setColor(self.ZAxisColor) + self.axisLines.moveTo(0, 0, -(self.ZSize)) + self.axisLines.drawTo(0, 0, self.ZSize) + + #Check to see if primary grid lines should be drawn at all + if(self.gridStep != 0): + + #Draw primary grid lines + self.gridLines.setColor(self.gridColor) + + #Draw primary grid lines metering x axis if any x-length + if(self.XSize != 0): + if((self.YSize != 0) and (self.XYPlaneShow)): + #Draw y lines across x axis starting from center moving out + #XY Plane + for x in self.myfrange(0, self.XSize, self.gridStep): + self.gridLines.moveTo(x, -(self.YSize), 0) + self.gridLines.drawTo(x, self.YSize, 0) + self.gridLines.moveTo(-x, -(self.YSize), 0) + self.gridLines.drawTo(-x, self.YSize, 0) + + if(self.endCapLinesShow): + #Draw endcap lines + self.gridLines.moveTo(self.XSize, -(self.YSize), 0) + self.gridLines.drawTo(self.XSize, self.YSize, 0) + self.gridLines.moveTo(-(self.XSize), -(self.YSize), 0) + self.gridLines.drawTo(-(self.XSize), self.YSize, 0) + + if((self.ZSize != 0) and (self.XZPlaneShow)): + #Draw z lines across x axis starting from center moving out + #XZ Plane + for x in self.myfrange(0, self.XSize, self.gridStep): + self.gridLines.moveTo(x, 0, -(self.ZSize)) + self.gridLines.drawTo(x, 0, self.ZSize) + self.gridLines.moveTo(-x, 0, -(self.ZSize)) + self.gridLines.drawTo(-x, 0, self.ZSize) + + if(self.endCapLinesShow): + #Draw endcap lines + self.gridLines.moveTo(self.XSize, 0, -(self.ZSize)) + self.gridLines.drawTo(self.XSize, 0, self.ZSize) + self.gridLines.moveTo(-(self.XSize), 0, -(self.ZSize)) + self.gridLines.drawTo(-(self.XSize), 0, self.ZSize) + + #Draw primary grid lines metering y axis if any y-length + if(self.YSize != 0): + + if((self.YSize != 0) and (self.XYPlaneShow)): + #Draw x lines across y axis + #XY Plane + for y in self.myfrange(0, self.YSize, self.gridStep): + self.gridLines.moveTo(-(self.XSize), y, 0) + self.gridLines.drawTo(self.XSize, y, 0) + self.gridLines.moveTo(-(self.XSize), -y, 0) + self.gridLines.drawTo(self.XSize, -y, 0) + + if(self.endCapLinesShow): + #Draw endcap lines + self.gridLines.moveTo(-(self.XSize), self.YSize, 0) + self.gridLines.drawTo(self.XSize, self.YSize, 0) + self.gridLines.moveTo(-(self.XSize), -(self.YSize), 0) + self.gridLines.drawTo(self.XSize, -(self.YSize), 0) + + if((self.ZSize != 0) and (self.YZPlaneShow)): + #Draw z lines across y axis + #YZ Plane + for y in self.myfrange(0, self.YSize, self.gridStep): + self.gridLines.moveTo(0, y, -(self.ZSize)) + self.gridLines.drawTo(0, y, self.ZSize) + self.gridLines.moveTo(0, -y, -(self.ZSize)) + self.gridLines.drawTo(0, -y, self.ZSize) + + if(self.endCapLinesShow): + #Draw endcap lines + self.gridLines.moveTo(0, self.YSize, -(self.ZSize)) + self.gridLines.drawTo(0, self.YSize, self.ZSize) + self.gridLines.moveTo(0, -(self.YSize), -(self.ZSize)) + self.gridLines.drawTo(0, -(self.YSize), self.ZSize) + + #Draw primary grid lines metering z axis if any z-length + if(self.ZSize != 0): + if((self.XSize != 0) and (self.XZPlaneShow)): + #Draw x lines across z axis + #XZ Plane + for z in self.myfrange(0, self.ZSize, self.gridStep): + self.gridLines.moveTo(-(self.XSize), 0, z) + self.gridLines.drawTo(self.XSize, 0, z) + self.gridLines.moveTo(-(self.XSize), 0, -z) + self.gridLines.drawTo(self.XSize, 0, -z) + + if(self.endCapLinesShow): + #Draw endcap lines + self.gridLines.moveTo(-(self.XSize), 0, self.ZSize) + self.gridLines.drawTo(self.XSize, 0, self.ZSize) + self.gridLines.moveTo(-(self.XSize), 0, -(self.ZSize)) + self.gridLines.drawTo(self.XSize, 0, -(self.ZSize)) + + if((self.YSize != 0) and (self.YZPlaneShow)): + #Draw y lines across z axis + #YZ Plane + for z in self.myfrange(0, self.ZSize, self.gridStep): + self.gridLines.moveTo(0, -(self.YSize), z) + self.gridLines.drawTo(0, self.YSize, z) + self.gridLines.moveTo(0, -(self.YSize), -z) + self.gridLines.drawTo(0, self.YSize, -z) + + if(self.endCapLinesShow): + #Draw endcap lines + self.gridLines.moveTo(0, -(self.YSize), self.ZSize) + self.gridLines.drawTo(0, self.YSize, self.ZSize) + self.gridLines.moveTo(0, -(self.YSize), -(self.ZSize)) + self.gridLines.drawTo(0, self.YSize, -(self.ZSize)) + + #Check to see if secondary grid lines should be drawn + if(self.subdiv != 0): + + #Draw secondary grid lines + self.subdivLines.setColor(self.subdivColor) + + if(self.XSize != 0): + adjustedstep = self.gridStep / self.subdiv + if((self.YSize != 0) and (self.XYPlaneShow)): + #Draw y lines across x axis starting from center moving out + #XY + for x in self.myfrange(0, self.XSize, adjustedstep): + self.subdivLines.moveTo(x, -(self.YSize), 0) + self.subdivLines.drawTo(x, self.YSize, 0) + self.subdivLines.moveTo(-x, -(self.YSize), 0) + self.subdivLines.drawTo(-x, self.YSize, 0) + + if((self.ZSize != 0) and (self.XZPlaneShow)): + #Draw z lines across x axis starting from center moving out + #XZ + for x in self.myfrange(0, self.XSize, adjustedstep): + self.subdivLines.moveTo(x, 0, -(self.ZSize)) + self.subdivLines.drawTo(x, 0, self.ZSize) + self.subdivLines.moveTo(-x, 0, -(self.ZSize)) + self.subdivLines.drawTo(-x, 0, self.ZSize) + + if(self.YSize != 0): + if((self.YSize != 0) and (self.XYPlaneShow)): + #Draw x lines across y axis + #XY + for y in self.myfrange(0, self.YSize, adjustedstep): + self.subdivLines.moveTo(-(self.XSize), y, 0) + self.subdivLines.drawTo(self.XSize, y, 0) + self.subdivLines.moveTo(-(self.XSize), -y, 0) + self.subdivLines.drawTo(self.XSize, -y, 0) + if((self.ZSize != 0) and (self.YZPlaneShow)): + #Draw z lines across y axis + #YZ + for y in self.myfrange(0, self.YSize, adjustedstep): + self.subdivLines.moveTo(0, y, -(self.ZSize)) + self.subdivLines.drawTo(0, y, self.ZSize) + self.subdivLines.moveTo(0, -y, -(self.ZSize)) + self.subdivLines.drawTo(0, -y, self.ZSize) + + if(self.ZSize != 0): + + if((self.XSize != 0) and (self.XZPlaneShow)): + #Draw x lines across z axis + #XZ + for z in self.myfrange(0, self.ZSize, adjustedstep): + self.subdivLines.moveTo(-(self.XSize), 0, z) + self.subdivLines.drawTo(self.XSize, 0, z) + self.subdivLines.moveTo(-(self.XSize), 0, -z) + self.subdivLines.drawTo(self.XSize, 0, -z) + + if((self.YSize != 0) and (self.YZPlaneShow)): + #Draw y lines across z axis + #YZ + for z in self.myfrange(0, self.ZSize, adjustedstep): + self.subdivLines.moveTo(0, -(self.YSize), z) + self.subdivLines.drawTo(0, self.YSize, z) + self.subdivLines.moveTo(0, -(self.YSize), -z) + self.subdivLines.drawTo(0, self.YSize, -z) + + #Create ThreeAxisGrid nodes and nodepaths + #Create parent node and path + self.parentNode = PandaNode('threeaxisgrid-parentnode') + self.parentNodePath = NodePath(self.parentNode) + + #Create axis lines node and path, then reparent + self.axisLinesNode = self.axisLines.create() + self.axisLinesNodePath = NodePath(self.axisLinesNode) + self.axisLinesNodePath.reparentTo(self.parentNodePath) + + #Create grid lines node and path, then reparent + self.gridLinesNode = self.gridLines.create() + self.gridLinesNodePath = NodePath(self.gridLinesNode) + self.gridLinesNodePath.reparentTo(self.parentNodePath) + + #Create subdivision lines node and path then reparent + self.subdivLinesNode = self.subdivLines.create() + self.subdivLinesNodePath = NodePath(self.subdivLinesNode) + self.subdivLinesNodePath.reparentTo(self.parentNodePath) + + return self.parentNodePath + def myfrange(self, start, stop=None, step=None): + if stop is None: + stop = float(start) + start = 0.0 + if step is None: + step = 1.0 + cur = float(start) + while cur < stop: + yield cur + cur += step \ No newline at end of file diff --git a/QPanda3D/Helpers/__init__.py b/QPanda3D/Helpers/__init__.py new file mode 100644 index 00000000..376e08da --- /dev/null +++ b/QPanda3D/Helpers/__init__.py @@ -0,0 +1,2 @@ +name="QPanda3D" +__all__ = ["Env_Grid_Maker"] \ No newline at end of file diff --git a/QPanda3D/Helpers/__pycache__/Env_Grid_Maker.cpython-312.pyc b/QPanda3D/Helpers/__pycache__/Env_Grid_Maker.cpython-312.pyc new file mode 100644 index 00000000..23ab32d8 Binary files /dev/null and b/QPanda3D/Helpers/__pycache__/Env_Grid_Maker.cpython-312.pyc differ diff --git a/QPanda3D/Helpers/__pycache__/__init__.cpython-312.pyc b/QPanda3D/Helpers/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 00000000..f0b56cb1 Binary files /dev/null and b/QPanda3D/Helpers/__pycache__/__init__.cpython-312.pyc differ diff --git a/QPanda3D/Panda3DWorld.py b/QPanda3D/Panda3DWorld.py new file mode 100644 index 00000000..d26cdb5b --- /dev/null +++ b/QPanda3D/Panda3DWorld.py @@ -0,0 +1,180 @@ +# -*- coding: utf-8-*- +""" +Module : Panda3DWorld +Author : Saifeddine ALOUI +Description : + Inherit this object to create your custom world +""" +import sys +import os + +# 获取 RenderPipelineFile 的路径 +render_pipeline_path = './RenderPipelineFile' +# 将该路径添加到 sys.path 中,确保 Python 能够找到它 +project_root = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, project_root) +sys.path.insert(0, render_pipeline_path) + +# 现在你可以导入 RenderPipelineFile 中的模块了 +# 例如,如果你想导入 RenderPipelineFile 中的 RenderPipeline 模块 +from RenderPipelineFile.rpcore import RenderPipeline +_global_render_pipeline = None + +# PyQt imports +from PyQt5.QtCore import * +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * + +# Panda imports +from panda3d.core import * +# from panda3d.core import loadPrcFileData +# loadPrcFileData("", "window-type none") # Set Panda to draw its main window in an offscreen buffer +from direct.showbase.DirectObject import DirectObject +from panda3d.core import GraphicsOutput, Texture, ConfigVariableManager, WindowProperties + +# Set up Panda environment +from direct.showbase.ShowBase import ShowBase +import platform + +# Local imports +from QPanda3D.QMouseWatcherNode import QMouseWatcherNode + +from rpcore.render_target import RenderTarget +__all__ = ["Panda3DWorld"] + +_global_world_instance=None +import builtins + + +class Panda3DWorld(ShowBase): + """ + Panda3DWorld : A class to handle all panda3D world manipulation + """ + + def __init__(self, width=1240, height=720, is_fullscreen=False, size=1.0, clear_color=LVecBase4f(0, 0.5, 0, 1), + name="qpanda3D"): + + global _global_world_instance + global _global_render_pipeline + + _global_world_instance = self + + sort = -100 + self.parent = None + # self.width = width + # self.height = height + + + loadPrcFileData("", "win-size {} {}".format(width, height)) + loadPrcFileData("", "show-frame-rate-meter 0") + loadPrcFileData("", f"win-size {width} {height}") + #loadPrcFileData("", "sync-video #t") + #loadPrcFileData("", "force-flush #t") + + if (is_fullscreen): + loadPrcFileData("", "fullscreen #t") + else: + loadPrcFileData("", "window-type offscreen") # Set Panda to draw its main window in an offscreen buffer + #loadPrcFileData("", "show-frame-rate-meter 0") # 可选 + self.render_pipeline = RenderPipeline() + self.render_pipeline.pre_showbase_init() + + ShowBase.__init__(self) + self.render_pipeline.create(self) + _global_render_pipeline = self.render_pipeline + #from RenderPipelineFile.toolkit.material_editor.main import MaterialEditor + #self.screenTexture = self.render_pipeline._final_stage.target.color_tex + #self.screenTexture.setComponentType(Texture.T_unsigned_byte) + #self.screenTexture.setFormat(Texture.F_rgba8) + + # 创建 Qt 能读的 RGBA8 贴图 + self.qt_output_tex = Texture("qt_output_tex") + self.qt_output_tex.set_format(Texture.F_rgba8) + self.qt_output_tex.set_component_type(Texture.T_unsigned_byte) + #self.screenTexture.set_keep_ram_image(True) + + # 添加到主窗口渲染输出,并指定复制回 CPU + self.win.add_render_texture(self.qt_output_tex, GraphicsOutput.RTM_copy_ram) + + #self.screenTexture = Texture() + #self.screenTexture.setMinfilter(Texture.FTLinear) + #self.screenTexture.setFormat(Texture.FRgba32) + #self.screenTexture.set_wrap_u(Texture.WM_clamp) + #self.screenTexture.set_wrap_v(Texture.WM_clamp) + + # buff_size_x = int(self.win.get_x_size() * size) + # buff_size_y = int(self.win.get_y_size() * size) + # winprops = WindowProperties() + # winprops.set_size(buff_size_x, buff_size_y) + # + # + # props = FrameBufferProperties() + # props.set_rgb_color(True) + # props.set_rgba_bits(8, 8, 8, 8) + # props.set_depth_bits(8) + + # self.buff = self.graphicsEngine.make_output( + # self.pipe, name, sort, + # props, winprops, + # GraphicsPipe.BF_resizeable, + # self.win.get_gsg(), self.win) + + #self.screenTexture = render_pipeline._final_stage.target.color_tex + + #self.buff.addRenderTexture(self.screenTexture, GraphicsOutput.RTMCopyRam) + # self.buff.set_sort(sort) + + + + #self.cam = self.makeCamera(self.buff) + #self.render_pipeline._showbase.cam=self.makeCamera(self.buff) + + #self.render_pipeline._showbase.cam=self.makeCamera(self.buff) + + #self.render_pipeline._showbase.camera.reparentTo(self.render) + #base.camera.reparentTo(self.render) + #self.cam.reparentTo(self.render) # 可选同步 + + #render_pipeline.set_camera(self.cam) + + #添加渲染效果后 + self.cam = self.render_pipeline._showbase.cam + self.camNode = self.cam.node() + self.camLens = self.camNode.get_lens() + self.render_pipeline._showbase.camera = self.render_pipeline._showbase.cam + #self.render_pipeline.daytime_mgr.update() + + # + # if clear_color is None: + # self.buff.set_clear_active(GraphicsOutput.RTPColor, False) + # else: + # self.buff.set_clear_color(clear_color) + # self.buff.set_clear_active(GraphicsOutput.RTPColor, True) + + self.disableMouse() + + def render_pipeline(self): + """获取 RenderPipeline 实例""" + return self._render_pipeline + + + def set_parent(self, parent: QWidget): + self.parent = parent + self.mouseWatcherNode = QMouseWatcherNode(parent) + + def getAspectRatio(self, win = None): + if win is None and self.parent is not None: + return float(self.parent.width()) / float(self.parent.height()) + else: + return super().getAspectRatio(win) + +def get_render_pipeline(): + """获取全局 RenderPipeline 单例""" + if _global_render_pipeline is None: + raise RuntimeError( + "RenderPipeline has not been initialized yet. Please create a Panda3DWorld instance first.") + return _global_render_pipeline + + + + diff --git a/QPanda3D/QMouseWatcherNode.py b/QPanda3D/QMouseWatcherNode.py new file mode 100644 index 00000000..c810df66 --- /dev/null +++ b/QPanda3D/QMouseWatcherNode.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8-*- +""" +Module : QMouseWatcherNode +Author : Niklas Mevenkamp +Description : + This is a MouseWatcherNode implementation that accesses + mouse position and button states through a parent QWidget. +""" + +# PyQt imports +from PyQt5.QtCore import * +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * + +# Panda imports +from panda3d.core import * + +__all__ = ["QMouseWatcherNode"] + + +class QMouseWatcherNode(MouseWatcher): + def __init__(self, parent): + super().__init__() + + self.parent = parent + + def getMouse(self, *args, **kwargs): + # map global QCursor pixel position to parent Widget coordinates + pos = self.parent.mapFromGlobal(QCursor.pos()) + + # map absolute pixel positions to relative ones + rel_x = -1 + 2 * pos.x() / self.parent.width() + rel_y = -1 + 2 * pos.y() / self.parent.height() + + # invert y + rel_y = -rel_y + + return LPoint2(rel_x, rel_y) + + def hasMouse(self): + return isinstance(self.parent, QWidget) diff --git a/QPanda3D/QPanda3DWidget.py b/QPanda3D/QPanda3DWidget.py new file mode 100644 index 00000000..f2e5a921 --- /dev/null +++ b/QPanda3D/QPanda3DWidget.py @@ -0,0 +1,260 @@ +# -*- coding: utf-8-*- +""" +Module : QPanda3DWidget +Author : Saifeddine ALOUI +Description : + This is the QWidget to be inserted in your standard PyQt5 application. + It takes a Panda3DWorld object at init time. + You should first create the Panda3DWorkd object before creating this widget. +""" +# PyQt imports +from PyQt5 import QtWidgets, QtGui +from PyQt5.QtCore import * +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * + +# Panda imports +from panda3d.core import Texture, WindowProperties, CallbackGraphicsWindow +from panda3d.core import loadPrcFileData + +from QPanda3D.QPanda3D_Buttons_Translation import QPanda3D_Button_translation +from QPanda3D.QPanda3D_Keys_Translation import QPanda3D_Key_translation +from QPanda3D.QPanda3D_Modifiers_Translation import QPanda3D_Modifier_translation + +__all__ = ["QPanda3DWidget"] + + +class QPanda3DSynchronizer(QTimer): + def __init__(self, qPanda3DWidget, FPS=60): + QTimer.__init__(self) + self.qPanda3DWidget = qPanda3DWidget + dt = 1000 / FPS + self.setInterval(int(dt)) + self.timeout.connect(self.tick) + + def tick(self): + taskMgr.step() + self.qPanda3DWidget.update() + + +def get_panda_key_modifiers(evt): + panda_mods = [] + qt_mods = evt.modifiers() + for qt_mod, panda_mod in QPanda3D_Modifier_translation.items(): + if (qt_mods & qt_mod) == qt_mod: + panda_mods.append(panda_mod) + return panda_mods + + +def get_panda_key_modifiers_prefix(evt): + # join all modifiers (except NoModifier, which is None) with '-' + prefix = "-".join([mod for mod in get_panda_key_modifiers(evt) if mod is not None]) + + # if the prefix is not empty, append a '-' + if prefix: + prefix += '-' + + return prefix + + +class QPanda3DWidget(QWidget): + """ + An interactive panda3D QWidget + Parent : Parent QT Widget + FPS : Number of frames per socond to refresh the screen + debug: Switch printing key events to console on/off + """ + + def __init__(self, panda3DWorld, parent=None, FPS=60, debug=False): + QWidget.__init__(self, parent) + self.rp_sync_requested = False + # set fixed geometry + self.panda3DWorld = panda3DWorld + self.panda3DWorld.set_parent(self) + # Setup a timer in Qt that runs taskMgr.step() to simulate Panda's own main loop + # pandaTimer = QTimer(self) + # pandaTimer.timeout.connect() + # pandaTimer.start(0) + + self.setFocusPolicy(Qt.StrongFocus) + + # Setup another timer that redraws this widget in a specific FPS + # redrawTimer = QTimer(self) + # redrawTimer.timeout.connect(self.update) + # redrawTimer.start(1000/FPS) + + self.paintSurface = QPainter() + self.rotate = QTransform() + self.rotate.rotate(180) + self.out_image = QImage() + + size = self.panda3DWorld.cam.node().get_lens().get_film_size() + self.initial_film_size = QSizeF(size.x, size.y) + self.initial_size = self.size() + + self.synchronizer = QPanda3DSynchronizer(self, FPS) + self.synchronizer.start() + + self.debug = debug + + def mousePressEvent(self, evt): + button = evt.button() + try: + b = "{}{}".format(get_panda_key_modifiers_prefix(evt), QPanda3D_Button_translation[button]) + if self.debug: + print(b) + messenger.send(b,[{"x":evt.x(),"y":evt.y()}]) + except: + print("Unimplemented button. Please send an issue on github to fix this problem") + + def mouseMoveEvent(self, evt:QtGui.QMouseEvent): + button = evt.button() + try: + b = "mouse-move" + if self.debug: + print(b) + messenger.send(b,[{"x":evt.x(),"y":evt.y()}]) + except: + print("Unimplemented button. Please send an issue on github to fix this problem") + + + def mouseReleaseEvent(self, evt): + button = evt.button() + try: + b = "{}{}-up".format(get_panda_key_modifiers_prefix(evt), QPanda3D_Button_translation[button]) + if self.debug: + print(b) + messenger.send(b,[{"x":evt.x(),"y":evt.y()}]) + except: + print("Unimplemented button. Please send an issue on github to fix this problem") + + def wheelEvent(self, evt): + delta = evt.angleDelta().y() + try: + if self.debug: + print(f"wheel {delta}") + messenger.send('wheel',[{"delta":delta}]) + except: + print("Unimplemented button. Please send an issue on github to fix this problem") + + def keyPressEvent(self, evt): + key = evt.key() + try: + k = "{}{}".format(get_panda_key_modifiers_prefix(evt), QPanda3D_Key_translation[key]) + if self.debug: + print(k) + messenger.send(k) + except: + print("Unimplemented key. Please send an issue on github to fix this problem") + + def keyReleaseEvent(self, evt): + key = evt.key() + try: + k = "{}{}-up".format(get_panda_key_modifiers_prefix(evt), QPanda3D_Key_translation[key]) + if self.debug: + print(k) + messenger.send(k) + except: + print("Unimplemented key. Please send an issue on github to fix this problem") + + def resizeEvent(self, evt): + # new_width = evt.size().width() + # new_height = evt.size().height() + # + # # 更新 Panda3D 相机的 Film Size,保持视野正常 + # lens = self.panda3DWorld.cam.node().get_lens() + # lens.set_film_size( + # self.initial_film_size.width() * new_width / self.initial_size.width(), + # self.initial_film_size.height() * new_height / self.initial_size.height() + # ) + # + # if hasattr(self.panda3DWorld, "win"): + # winprops = WindowProperties() + # winprops.set_size(new_width, new_height) + # self.panda3DWorld.win.request_properties(winprops) + lens = self.panda3DWorld.cam.node().get_lens() + lens.set_film_size(self.initial_film_size.width() * evt.size().width() / self.initial_size.width(), + self.initial_film_size.height() * evt.size().height() / self.initial_size.height()) + #self.panda3DWorld.buff.setSize(evt.size().width(), evt.size().height()) + + def minimumSizeHint(self): + return QSize(400, 300) + + # Use the paint event to pull the contents of the panda texture to the widget + # def paintEvent(self, event): + # if self.panda3DWorld.screenTexture.mightHaveRamImage(): + # tex = self.panda3DWorld.screenTexture + # gsg = base.win.getGsg() + # #self.panda3DWorld.screenTexture.store(gsg) + # base.graphicsEngine.extractTextureData(tex, gsg) + # self.panda3DWorld.screenTexture.setFormat(Texture.FRgba32) + # data = self.panda3DWorld.screenTexture.getRamImage().getData() + # img = QImage(data, self.panda3DWorld.screenTexture.getXSize(), self.panda3DWorld.screenTexture.getYSize(), + # QImage.Format_ARGB32).mirrored() + # self.paintSurface.begin(self) + # self.paintSurface.drawImage(0, 0, img) + # self.paintSurface.end() + + # def paintEvent(self, event): + # tex = self.panda3DWorld.qt_output_tex + # + # gsg = base.win.getGsg() + # + # + # if not self.rp_sync_requested: + # base.graphicsEngine.extractTextureData(tex, gsg) + # self.rp_sync_requested = True + # self.update() + # return + # + # if tex.hasRamImage(): + # data = tex.getRamImage().getData() + # width = tex.getXSize() + # height = tex.getYSize() + # + # # ✅ 应该 data 长度 = width * height * 4 + # img = QImage(data, width, height, QImage.Format_ARGB32).mirrored() + # + # painter = QPainter(self) + # painter.drawImage(0, 0, img) + # painter.end() + # + # self.rp_sync_requested = False + # else: + # print("⚠️ Texture has no RAM image yet, retrying next frame") + # self.rp_sync_requested = False + # self.update() + + def paintEvent(self, event): + tex = self.panda3DWorld.qt_output_tex + + gsg = base.win.getGsg() + + if not tex.hasRamImage(): + base.graphicsEngine.extractTextureData(tex, gsg) + self.update() # 请求下一帧更新 + return + + data = tex.getRamImage().getData() + width = tex.getXSize() + height = tex.getYSize() + expected_len = width * height * 4 + + if len(data) != expected_len: + print(f"⚠️ 像素数据长度异常({len(data)} != {expected_len}),跳过绘制") + self.update() + return + + # 一切正常才绘制 + img = QImage(data, width, height, QImage.Format_ARGB32).mirrored() + + painter = QPainter(self) + painter.drawImage(0, 0, img) + painter.end() + + + + + + + diff --git a/QPanda3D/QPanda3D_Buttons_Translation.py b/QPanda3D/QPanda3D_Buttons_Translation.py new file mode 100644 index 00000000..db011c66 --- /dev/null +++ b/QPanda3D/QPanda3D_Buttons_Translation.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8-*- +""" +Module : QPanda3D_Translation_Buttons +Author : Niklas Mevenkamp +Description : + Contains a dictionary that translates QT mouse events to panda3d + mouse events. +""" +# PyQt imports +from PyQt5.QtCore import * +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * +import sys +__all__ = ["QPanda3D_Keys_Translation"] + +QPanda3D_Button_translation ={ +Qt.NoButton:'', +Qt.AllButtons:'unknown', +Qt.LeftButton:'mouse1', +Qt.RightButton:'mouse2', +Qt.MidButton:'mouse3', +Qt.MiddleButton:'mouse3', +Qt.BackButton:'unknown', +Qt.XButton1:'unknown', +Qt.ExtraButton1:'unknown', +Qt.ForwardButton:'unknown', +Qt.XButton2:'unknown', +Qt.ExtraButton2:'unknown', +Qt.TaskButton:'unknown', +Qt.ExtraButton3:'unknown', +Qt.ExtraButton4:'unknown', +Qt.ExtraButton5:'unknown', +Qt.ExtraButton6:'unknown', +Qt.ExtraButton7:'unknown', +Qt.ExtraButton8:'unknown', +Qt.ExtraButton9:'unknown', +Qt.ExtraButton10:'unknown', +Qt.ExtraButton11:'unknown', +Qt.ExtraButton12:'unknown', +Qt.ExtraButton13:'unknown', +Qt.ExtraButton14:'unknown', +Qt.ExtraButton15:'unknown', +Qt.ExtraButton16:'unknown', +Qt.ExtraButton17:'unknown', +Qt.ExtraButton18:'unknown', +Qt.ExtraButton19:'unknown', +Qt.ExtraButton20:'unknown', +Qt.ExtraButton21:'unknown', +Qt.ExtraButton22:'unknown', +Qt.ExtraButton23:'unknown', +Qt.ExtraButton24:'unknown', +} \ No newline at end of file diff --git a/QPanda3D/QPanda3D_Keys_Translation.py b/QPanda3D/QPanda3D_Keys_Translation.py new file mode 100644 index 00000000..97d510b7 --- /dev/null +++ b/QPanda3D/QPanda3D_Keys_Translation.py @@ -0,0 +1,486 @@ +# -*- coding: utf-8-*- +""" +Module : QPanda3D_Translation_Keys +Author : Saifeddine ALOUI +Description : + Contains a dictionary that translates QT keyboard events to panda3d + keyboard events. +""" +# PyQt imports +from PyQt5.QtCore import * +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * +import sys +__all__ = ["QPanda3D_Keys_Translation"] + +QPanda3D_Key_translation ={ +Qt.Key_0:'0', +Qt.Key_1:'1', +Qt.Key_2:'2', +Qt.Key_3:'3', +Qt.Key_4:'4', +Qt.Key_5:'5', +Qt.Key_6:'6', +Qt.Key_7:'7', +Qt.Key_8:'8', +Qt.Key_9:'9', +Qt.Key_A:'a', +Qt.Key_AE:'ae', +Qt.Key_Aacute:'unknown', +Qt.Key_Acircumflex:'unknown', +Qt.Key_AddFavorite:'unknown', +Qt.Key_Adiaeresis:'unknown', +Qt.Key_Agrave:'unknown', +Qt.Key_Alt:'lalt', +Qt.Key_AltGr:'unknown', +Qt.Key_Ampersand:'unknown', +Qt.Key_Any:'unknown', +Qt.Key_Apostrophe:'unknown', +Qt.Key_ApplicationLeft:'unknown', +Qt.Key_ApplicationRight:'unknown', +Qt.Key_Aring:'unknown', +Qt.Key_AsciiCircum:'unknown', +Qt.Key_AsciiTilde:'unknown', +Qt.Key_Asterisk:'unknown', +Qt.Key_At:'unknown', +Qt.Key_Atilde:'unknown', +Qt.Key_AudioCycleTrack:'unknown', +Qt.Key_AudioForward:'unknown', +Qt.Key_AudioRandomPlay:'unknown', +Qt.Key_AudioRepeat:'unknown', +Qt.Key_AudioRewind:'unknown', +Qt.Key_Away:'unknown', +Qt.Key_B:'b', +Qt.Key_Back:'unknown', +Qt.Key_BackForward:'unknown', +Qt.Key_Backslash:'unknown', +Qt.Key_Backspace:'unknown', +Qt.Key_Backtab:'unknown', +Qt.Key_Bar:'unknown', +Qt.Key_BassBoost:'unknown', +Qt.Key_BassDown:'unknown', +Qt.Key_BassUp:'unknown', +Qt.Key_Battery:'unknown', +Qt.Key_Blue:'unknown', +Qt.Key_Bluetooth:'unknown', +Qt.Key_Book:'unknown', +Qt.Key_BraceLeft:'unknown', +Qt.Key_BraceRight:'unknown', +Qt.Key_BracketLeft:'unknown', +Qt.Key_BracketRight:'unknown', +Qt.Key_BrightnessAdjust:'unknown', +Qt.Key_C:'c', +Qt.Key_CD:'unknown', +Qt.Key_Calculator:'unknown', +Qt.Key_Calendar:'unknown', +Qt.Key_Call:'unknown', +Qt.Key_Camera:'unknown', +Qt.Key_CameraFocus:'unknown', +Qt.Key_Cancel:'unknown', +Qt.Key_CapsLock:'unknown', +Qt.Key_Ccedilla:'unknown', +Qt.Key_ChannelDown:'unknown', +Qt.Key_ChannelUp:'unknown', +Qt.Key_Clear:'unknown', +Qt.Key_ClearGrab:'unknown', +Qt.Key_Close:'unknown', +Qt.Key_Codeinput:'unknown', +Qt.Key_Colon:'unknown', +Qt.Key_Comma:'unknown', +Qt.Key_Community:'unknown', +Qt.Key_Context1:'unknown', +Qt.Key_Context2:'unknown', +Qt.Key_Context3:'unknown', +Qt.Key_Context4:'unknown', +Qt.Key_ContrastAdjust:'unknown', +Qt.Key_Control:'control', +Qt.Key_Copy:'unknown', +Qt.Key_Cut:'unknown', +Qt.Key_D:'d', +Qt.Key_DOS:'unknown', +Qt.Key_Dead_A:'unknown', +Qt.Key_Dead_Abovecomma:'unknown', +Qt.Key_Dead_Abovedot:'unknown', +Qt.Key_Dead_Abovereversedcomma:'unknown', +Qt.Key_Dead_Abovering:'unknown', +Qt.Key_Dead_Aboveverticalline:'unknown', +Qt.Key_Dead_Acute:'unknown', +Qt.Key_Dead_Belowbreve:'unknown', +Qt.Key_Dead_Belowcircumflex:'unknown', +Qt.Key_Dead_Belowcomma:'unknown', +Qt.Key_Dead_Belowdiaeresis:'unknown', +Qt.Key_Dead_Belowdot:'unknown', +Qt.Key_Dead_Belowmacron:'unknown', +Qt.Key_Dead_Belowring:'unknown', +Qt.Key_Dead_Belowtilde:'unknown', +Qt.Key_Dead_Belowverticalline:'unknown', +Qt.Key_Dead_Breve:'unknown', +Qt.Key_Dead_Capital_Schwa:'unknown', +Qt.Key_Dead_Caron:'unknown', +Qt.Key_Dead_Cedilla:'unknown', +Qt.Key_Dead_Circumflex:'unknown', +Qt.Key_Dead_Currency:'unknown', +Qt.Key_Dead_Diaeresis:'unknown', +Qt.Key_Dead_Doubleacute:'unknown', +Qt.Key_Dead_Doublegrave:'unknown', +Qt.Key_Dead_E:'unknown', +Qt.Key_Dead_Grave:'unknown', +Qt.Key_Dead_Greek:'unknown', +Qt.Key_Dead_Hook:'unknown', +Qt.Key_Dead_Horn:'unknown', +Qt.Key_Dead_I:'unknown', +Qt.Key_Dead_Invertedbreve:'unknown', +Qt.Key_Dead_Iota:'unknown', +Qt.Key_Dead_Longsolidusoverlay:'unknown', +Qt.Key_Dead_Lowline:'unknown', +Qt.Key_Dead_Macron:'unknown', +Qt.Key_Dead_O:'unknown', +Qt.Key_Dead_Ogonek:'unknown', +Qt.Key_Dead_Semivoiced_Sound:'unknown', +Qt.Key_Dead_Small_Schwa:'unknown', +Qt.Key_Dead_Stroke:'unknown', +Qt.Key_Dead_Tilde:'unknown', +Qt.Key_Dead_U:'unknown', +Qt.Key_Dead_Voiced_Sound:'unknown', +Qt.Key_Dead_a:'unknown', +Qt.Key_Dead_e:'unknown', +Qt.Key_Dead_i:'unknown', +Qt.Key_Dead_o:'unknown', +Qt.Key_Dead_u:'unknown', +Qt.Key_Delete:'delete', +Qt.Key_Direction_L:'unknown', +Qt.Key_Direction_R:'unknown', +Qt.Key_Display:'unknown', +Qt.Key_Documents:'unknown', +Qt.Key_Dollar:'unknown', +Qt.Key_Down:'arrow_down', +Qt.Key_E:'e', +Qt.Key_ETH:'unknown', +Qt.Key_Eacute:'unknown', +Qt.Key_Ecircumflex:'unknown', +Qt.Key_Ediaeresis:'unknown', +Qt.Key_Egrave:'unknown', +Qt.Key_Eisu_Shift:'unknown', +Qt.Key_Eisu_toggle:'unknown', +Qt.Key_Eject:'unknown', +Qt.Key_End:'unknown', +Qt.Key_Enter:'unknown', +Qt.Key_Equal:'unknown', +Qt.Key_Escape:'escape', +Qt.Key_Excel:'unknown', +Qt.Key_Exclam:'unknown', +Qt.Key_Execute:'unknown', +Qt.Key_Exit:'unknown', +Qt.Key_Explorer:'unknown', +Qt.Key_F:'f', +Qt.Key_F1:'f1', +Qt.Key_F10:'f10', +Qt.Key_F11:'f11', +Qt.Key_F12:'f12', +Qt.Key_F13:'f13', +Qt.Key_F14:'f14', +Qt.Key_F15:'f15', +Qt.Key_F16:'f16', +Qt.Key_F17:'f17', +Qt.Key_F18:'f18', +Qt.Key_F19:'unknown', +Qt.Key_F2:'unknown', +Qt.Key_F20:'unknown', +Qt.Key_F21:'unknown', +Qt.Key_F22:'unknown', +Qt.Key_F23:'unknown', +Qt.Key_F24:'unknown', +Qt.Key_F25:'unknown', +Qt.Key_F26:'unknown', +Qt.Key_F27:'unknown', +Qt.Key_F28:'unknown', +Qt.Key_F29:'unknown', +Qt.Key_F3:'f3', +Qt.Key_F30:'unknown', +Qt.Key_F31:'unknown', +Qt.Key_F32:'unknown', +Qt.Key_F33:'unknown', +Qt.Key_F34:'unknown', +Qt.Key_F35:'unknown', +Qt.Key_F4:'f4', +Qt.Key_F5:'f5', +Qt.Key_F6:'f6', +Qt.Key_F7:'f7', +Qt.Key_F8:'f8', +Qt.Key_F9:'f9', +Qt.Key_Favorites:'unknown', +Qt.Key_Finance:'unknown', +Qt.Key_Find:'unknown', +Qt.Key_Flip:'unknown', +Qt.Key_Forward:'unknown', +Qt.Key_G:'g', +Qt.Key_Game:'unknown', +Qt.Key_Go:'unknown', +Qt.Key_Greater:'unknown', +Qt.Key_Green:'unknown', +Qt.Key_Guide:'unknown', +Qt.Key_H:'h', +Qt.Key_Hangul:'unknown', +Qt.Key_Hangul_Banja:'unknown', +Qt.Key_Hangul_End:'unknown', +Qt.Key_Hangul_Hanja:'unknown', +Qt.Key_Hangul_Jamo:'unknown', +Qt.Key_Hangul_Jeonja:'unknown', +Qt.Key_Hangul_PostHanja:'unknown', +Qt.Key_Hangul_PreHanja:'unknown', +Qt.Key_Hangul_Romaja:'unknown', +Qt.Key_Hangul_Special:'unknown', +Qt.Key_Hangul_Start:'unknown', +Qt.Key_Hangup:'unknown', +Qt.Key_Hankaku:'unknown', +Qt.Key_Help:'unknown', +Qt.Key_Henkan:'unknown', +Qt.Key_Hibernate:'unknown', +Qt.Key_Hiragana:'unknown', +Qt.Key_Hiragana_Katakana:'unknown', +Qt.Key_History:'unknown', +Qt.Key_Home:'home', +Qt.Key_HomePage:'unknown', +Qt.Key_HotLinks:'unknown', +Qt.Key_Hyper_L:'unknown', +Qt.Key_Hyper_R:'unknown', +Qt.Key_I:'i', +Qt.Key_Iacute:'unknown', +Qt.Key_Icircumflex:'unknown', +Qt.Key_Idiaeresis:'unknown', +Qt.Key_Igrave:'unknown', +Qt.Key_Info:'unknown', +Qt.Key_Insert:'unknown', +Qt.Key_J:'j', +Qt.Key_K:'k', +Qt.Key_Kana_Lock:'unknown', +Qt.Key_Kana_Shift:'unknown', +Qt.Key_Kanji:'unknown', +Qt.Key_Katakana:'unknown', +Qt.Key_KeyboardBrightnessDown:'unknown', +Qt.Key_KeyboardBrightnessUp:'unknown', +Qt.Key_KeyboardLightOnOff:'unknown', +Qt.Key_L:'l', +Qt.Key_LastNumberRedial:'unknown', +Qt.Key_Launch0:'unknown', +Qt.Key_Launch1:'unknown', +Qt.Key_Launch2:'unknown', +Qt.Key_Launch3:'unknown', +Qt.Key_Launch4:'unknown', +Qt.Key_Launch5:'unknown', +Qt.Key_Launch6:'unknown', +Qt.Key_Launch7:'unknown', +Qt.Key_Launch8:'unknown', +Qt.Key_Launch9:'unknown', +Qt.Key_LaunchA:'unknown', +Qt.Key_LaunchB:'unknown', +Qt.Key_LaunchC:'unknown', +Qt.Key_LaunchD:'unknown', +Qt.Key_LaunchE:'unknown', +Qt.Key_LaunchF:'unknown', +Qt.Key_LaunchG:'unknown', +Qt.Key_LaunchH:'unknown', +Qt.Key_LaunchMail:'unknown', +Qt.Key_LaunchMedia:'unknown', +Qt.Key_Left:'arrow_left', +Qt.Key_Less:'unknown', +Qt.Key_LightBulb:'unknown', +Qt.Key_LogOff:'unknown', +Qt.Key_M:'m', +Qt.Key_MailForward:'unknown', +Qt.Key_Market:'unknown', +Qt.Key_Massyo:'unknown', +Qt.Key_MediaLast:'unknown', +Qt.Key_MediaNext:'unknown', +Qt.Key_MediaPause:'unknown', +Qt.Key_MediaPlay:'unknown', +Qt.Key_MediaPrevious:'unknown', +Qt.Key_MediaRecord:'unknown', +Qt.Key_MediaStop:'unknown', +Qt.Key_MediaTogglePlayPause:'unknown', +Qt.Key_Meeting:'unknown', +Qt.Key_Memo:'unknown', +Qt.Key_Menu:'unknown', +Qt.Key_MenuKB:'unknown', +Qt.Key_MenuPB:'unknown', +Qt.Key_Messenger:'unknown', +Qt.Key_Meta:'unknown', +Qt.Key_MicMute:'unknown', +Qt.Key_MicVolumeDown:'unknown', +Qt.Key_MicVolumeUp:'unknown', +Qt.Key_Minus:'unknown', +Qt.Key_Mode_switch:'unknown', +Qt.Key_MonBrightnessDown:'unknown', +Qt.Key_MonBrightnessUp:'unknown', +Qt.Key_Muhenkan:'unknown', +Qt.Key_Multi_key:'unknown', +Qt.Key_MultipleCandidate:'unknown', +Qt.Key_Music:'unknown', +Qt.Key_MySites:'unknown', +Qt.Key_N:'n', +Qt.Key_New:'unknown', +Qt.Key_News:'unknown', +Qt.Key_No:'unknown', +Qt.Key_Ntilde:'unknown', +Qt.Key_NumLock:'unknown', +Qt.Key_NumberSign:'unknown', +Qt.Key_O:'o', +Qt.Key_Oacute:'unknown', +Qt.Key_Ocircumflex:'unknown', +Qt.Key_Odiaeresis:'unknown', +Qt.Key_OfficeHome:'unknown', +Qt.Key_Ograve:'unknown', +Qt.Key_Ooblique:'unknown', +Qt.Key_Open:'unknown', +Qt.Key_OpenUrl:'unknown', +Qt.Key_Option:'unknown', +Qt.Key_Otilde:'unknown', +Qt.Key_P:'p', +Qt.Key_PageDown:'unknown', +Qt.Key_PageUp:'unknown', +Qt.Key_ParenLeft:'unknown', +Qt.Key_ParenRight:'unknown', +Qt.Key_Paste:'unknown', +Qt.Key_Pause:'unknown', +Qt.Key_Percent:'unknown', +Qt.Key_Period:'unknown', +Qt.Key_Phone:'unknown', +Qt.Key_Pictures:'unknown', +Qt.Key_Play:'unknown', +Qt.Key_Plus:'unknown', +Qt.Key_PowerDown:'unknown', +Qt.Key_PowerOff:'unknown', +Qt.Key_PreviousCandidate:'unknown', +Qt.Key_Print:'unknown', +Qt.Key_Printer:'unknown', +Qt.Key_Q:'q', +Qt.Key_Question:'unknown', +Qt.Key_QuoteDbl:'unknown', +Qt.Key_QuoteLeft:'unknown', +Qt.Key_R:'r', +Qt.Key_Red:'unknown', +Qt.Key_Redo:'unknown', +Qt.Key_Refresh:'unknown', +Qt.Key_Reload:'unknown', +Qt.Key_Reply:'unknown', +Qt.Key_Return:'unknown', +Qt.Key_Right:'arrow_right', +Qt.Key_Romaji:'unknown', +Qt.Key_RotateWindows:'unknown', +Qt.Key_RotationKB:'unknown', +Qt.Key_RotationPB:'unknown', +Qt.Key_S:'s', +Qt.Key_Save:'unknown', +Qt.Key_ScreenSaver:'unknown', +Qt.Key_ScrollLock:'unknown', +Qt.Key_Search:'unknown', +Qt.Key_Select:'unknown', +Qt.Key_Semicolon:'unknown', +Qt.Key_Send:'unknown', +Qt.Key_Settings:'unknown', +Qt.Key_Shift:'unknown', +Qt.Key_Shop:'unknown', +Qt.Key_SingleCandidate:'unknown', +Qt.Key_Slash:'unknown', +Qt.Key_Sleep:'unknown', +Qt.Key_Space:'space', +Qt.Key_Spell:'unknown', +Qt.Key_SplitScreen:'unknown', +Qt.Key_Standby:'unknown', +Qt.Key_Stop:'unknown', +Qt.Key_Subtitle:'unknown', +Qt.Key_Super_L:'unknown', +Qt.Key_Super_R:'unknown', +Qt.Key_Support:'unknown', +Qt.Key_Suspend:'unknown', +Qt.Key_SysReq:'unknown', +Qt.Key_T:'t', +Qt.Key_THORN:'unknown', +Qt.Key_Tab:'unknown', +Qt.Key_TaskPane:'unknown', +Qt.Key_Terminal:'unknown', +Qt.Key_Time:'unknown', +Qt.Key_ToDoList:'unknown', +Qt.Key_ToggleCallHangup:'unknown', +Qt.Key_Tools:'unknown', +Qt.Key_TopMenu:'unknown', +Qt.Key_TouchpadOff:'unknown', +Qt.Key_TouchpadOn:'unknown', +Qt.Key_TouchpadToggle:'unknown', +Qt.Key_Touroku:'unknown', +Qt.Key_Travel:'unknown', +Qt.Key_TrebleDown:'unknown', +Qt.Key_TrebleUp:'unknown', +Qt.Key_U:'u', +Qt.Key_UWB:'unknown', +Qt.Key_Uacute:'unknown', +Qt.Key_Ucircumflex:'unknown', +Qt.Key_Udiaeresis:'unknown', +Qt.Key_Ugrave:'unknown', +Qt.Key_Underscore:'unknown', +Qt.Key_Undo:'unknown', +Qt.Key_Up:'arrow_up', +Qt.Key_V:'v', +Qt.Key_Video:'unknown', +Qt.Key_View:'unknown', +Qt.Key_VoiceDial:'unknown', +Qt.Key_VolumeDown:'unknown', +Qt.Key_VolumeMute:'unknown', +Qt.Key_VolumeUp:'unknown', +Qt.Key_W:'w', +Qt.Key_WLAN:'unknown', +Qt.Key_WWW:'unknown', +Qt.Key_WakeUp:'unknown', +Qt.Key_WebCam:'unknown', +Qt.Key_Word:'unknown', +Qt.Key_X:'x', +Qt.Key_Xfer:'unknown', +Qt.Key_Y:'y', +Qt.Key_Yacute:'unknown', +Qt.Key_Yellow:'unknown', +Qt.Key_Yes:'unknown', +Qt.Key_Z:'z', +Qt.Key_Zenkaku:'unknown', +Qt.Key_Zenkaku_Hankaku:'unknown', +Qt.Key_Zoom:'unknown', +Qt.Key_ZoomIn:'unknown', +Qt.Key_ZoomOut:'unknown', +Qt.Key_acute:'unknown', +Qt.Key_brokenbar:'unknown', +Qt.Key_cedilla:'unknown', +Qt.Key_cent:'unknown', +Qt.Key_copyright:'unknown', +Qt.Key_currency:'unknown', +Qt.Key_degree:'unknown', +Qt.Key_diaeresis:'unknown', +Qt.Key_division:'unknown', +Qt.Key_exclamdown:'unknown', +Qt.Key_guillemotleft:'unknown', +Qt.Key_guillemotright:'unknown', +Qt.Key_hyphen:'unknown', +Qt.Key_iTouch:'unknown', +Qt.Key_macron:'unknown', +Qt.Key_masculine:'unknown', +Qt.Key_mu:'unknown', +Qt.Key_multiply:'unknown', +Qt.Key_nobreakspace:'unknown', +Qt.Key_notsign:'unknown', +Qt.Key_onehalf:'unknown', +Qt.Key_onequarter:'unknown', +Qt.Key_onesuperior:'unknown', +Qt.Key_ordfeminine:'unknown', +Qt.Key_paragraph:'unknown', +Qt.Key_periodcentered:'unknown', +Qt.Key_plusminus:'unknown', +Qt.Key_questiondown:'unknown', +Qt.Key_registered:'unknown', +Qt.Key_section:'unknown', +Qt.Key_ssharp:'unknown', +Qt.Key_sterling:'unknown', +Qt.Key_threequarters:'unknown', +Qt.Key_threesuperior:'unknown', +Qt.Key_twosuperior:'unknown', +Qt.Key_unknown:'unknown', +Qt.Key_ydiaeresis:'unknown', +Qt.Key_yen:'unknown', +} \ No newline at end of file diff --git a/QPanda3D/QPanda3D_Modifiers_Translation.py b/QPanda3D/QPanda3D_Modifiers_Translation.py new file mode 100644 index 00000000..ce32160b --- /dev/null +++ b/QPanda3D/QPanda3D_Modifiers_Translation.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8-*- +""" +Module : QPanda3D_Translation_Modifiers +Author : Niklas Mevenkamp +Description : + Contains a dictionary that translates QT keyboard events to panda3d + keyboard events. +""" +# PyQt imports +from PyQt5.QtCore import * +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * +import sys +__all__ = ["QPanda3D_Modifiers_Translation"] + +QPanda3D_Modifier_translation ={ +Qt.NoModifier:None, +Qt.ShiftModifier:'shift', +Qt.ControlModifier:'control', +Qt.AltModifier:'alt', +Qt.MetaModifier:'unknown', +Qt.KeypadModifier:'unknown', +Qt.GroupSwitchModifier:'unknown', +} \ No newline at end of file diff --git a/QPanda3D/Tools/__init__.py b/QPanda3D/Tools/__init__.py new file mode 100644 index 00000000..03b1010f --- /dev/null +++ b/QPanda3D/Tools/__init__.py @@ -0,0 +1,2 @@ +name="QPanda3D" +__all__ = ["generate_qt_to_pd3d_translator"] \ No newline at end of file diff --git a/QPanda3D/Tools/__pycache__/__init__.cpython-312.pyc b/QPanda3D/Tools/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 00000000..3c5d492a Binary files /dev/null and b/QPanda3D/Tools/__pycache__/__init__.cpython-312.pyc differ diff --git a/QPanda3D/Tools/__pycache__/generate_qt_to_pd3d_translator.cpython-312.pyc b/QPanda3D/Tools/__pycache__/generate_qt_to_pd3d_translator.cpython-312.pyc new file mode 100644 index 00000000..e67c5397 Binary files /dev/null and b/QPanda3D/Tools/__pycache__/generate_qt_to_pd3d_translator.cpython-312.pyc differ diff --git a/QPanda3D/Tools/generate_qt_to_pd3d_translator.py b/QPanda3D/Tools/generate_qt_to_pd3d_translator.py new file mode 100644 index 00000000..9b4b6c69 --- /dev/null +++ b/QPanda3D/Tools/generate_qt_to_pd3d_translator.py @@ -0,0 +1,11 @@ +from PyQt5.QtCore import * +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * + +H=Qt.__dict__ +lst = [a for a in H if a.startswith("Key_")] +QPanda3D_Key_translation ="QPanda3D_Key_translation ={" +for i in range(len(lst)): + QPanda3D_Key_translation +="Qt.{}:'unknown',\n".format(lst[i]) +QPanda3D_Key_translation += "}" +print(QPanda3D_Key_translation) \ No newline at end of file diff --git a/QPanda3D/__init__.py b/QPanda3D/__init__.py new file mode 100644 index 00000000..5cf0b25b --- /dev/null +++ b/QPanda3D/__init__.py @@ -0,0 +1,2 @@ +name="QPanda3D" +__all__ = ["QPanda3DWidget", "Panda3DWorld", "QPanda3D_Keys_Translation"] \ No newline at end of file diff --git a/QPanda3D/__pycache__/Panda3DWorld.cpython-310.pyc b/QPanda3D/__pycache__/Panda3DWorld.cpython-310.pyc new file mode 100644 index 00000000..f05ed993 Binary files /dev/null and b/QPanda3D/__pycache__/Panda3DWorld.cpython-310.pyc differ diff --git a/QPanda3D/__pycache__/Panda3DWorld.cpython-312.pyc b/QPanda3D/__pycache__/Panda3DWorld.cpython-312.pyc new file mode 100644 index 00000000..a1de4fd5 Binary files /dev/null and b/QPanda3D/__pycache__/Panda3DWorld.cpython-312.pyc differ diff --git a/QPanda3D/__pycache__/QMouseWatcherNode.cpython-310.pyc b/QPanda3D/__pycache__/QMouseWatcherNode.cpython-310.pyc new file mode 100644 index 00000000..8c6644a9 Binary files /dev/null and b/QPanda3D/__pycache__/QMouseWatcherNode.cpython-310.pyc differ diff --git a/QPanda3D/__pycache__/QMouseWatcherNode.cpython-312.pyc b/QPanda3D/__pycache__/QMouseWatcherNode.cpython-312.pyc new file mode 100644 index 00000000..98a7ef05 Binary files /dev/null and b/QPanda3D/__pycache__/QMouseWatcherNode.cpython-312.pyc differ diff --git a/QPanda3D/__pycache__/QPanda3DWidget.cpython-310.pyc b/QPanda3D/__pycache__/QPanda3DWidget.cpython-310.pyc new file mode 100644 index 00000000..7cab2e09 Binary files /dev/null and b/QPanda3D/__pycache__/QPanda3DWidget.cpython-310.pyc differ diff --git a/QPanda3D/__pycache__/QPanda3DWidget.cpython-312.pyc b/QPanda3D/__pycache__/QPanda3DWidget.cpython-312.pyc new file mode 100644 index 00000000..fa547dbc Binary files /dev/null and b/QPanda3D/__pycache__/QPanda3DWidget.cpython-312.pyc differ diff --git a/QPanda3D/__pycache__/QPanda3D_Buttons_Translation.cpython-310.pyc b/QPanda3D/__pycache__/QPanda3D_Buttons_Translation.cpython-310.pyc new file mode 100644 index 00000000..fe6ded15 Binary files /dev/null and b/QPanda3D/__pycache__/QPanda3D_Buttons_Translation.cpython-310.pyc differ diff --git a/QPanda3D/__pycache__/QPanda3D_Buttons_Translation.cpython-312.pyc b/QPanda3D/__pycache__/QPanda3D_Buttons_Translation.cpython-312.pyc new file mode 100644 index 00000000..f2a7de8e Binary files /dev/null and b/QPanda3D/__pycache__/QPanda3D_Buttons_Translation.cpython-312.pyc differ diff --git a/QPanda3D/__pycache__/QPanda3D_Keys_Translation.cpython-310.pyc b/QPanda3D/__pycache__/QPanda3D_Keys_Translation.cpython-310.pyc new file mode 100644 index 00000000..51f2913e Binary files /dev/null and b/QPanda3D/__pycache__/QPanda3D_Keys_Translation.cpython-310.pyc differ diff --git a/QPanda3D/__pycache__/QPanda3D_Keys_Translation.cpython-312.pyc b/QPanda3D/__pycache__/QPanda3D_Keys_Translation.cpython-312.pyc new file mode 100644 index 00000000..b9db426c Binary files /dev/null and b/QPanda3D/__pycache__/QPanda3D_Keys_Translation.cpython-312.pyc differ diff --git a/QPanda3D/__pycache__/QPanda3D_Modifiers_Translation.cpython-310.pyc b/QPanda3D/__pycache__/QPanda3D_Modifiers_Translation.cpython-310.pyc new file mode 100644 index 00000000..fe0fcb08 Binary files /dev/null and b/QPanda3D/__pycache__/QPanda3D_Modifiers_Translation.cpython-310.pyc differ diff --git a/QPanda3D/__pycache__/QPanda3D_Modifiers_Translation.cpython-312.pyc b/QPanda3D/__pycache__/QPanda3D_Modifiers_Translation.cpython-312.pyc new file mode 100644 index 00000000..e177eb3d Binary files /dev/null and b/QPanda3D/__pycache__/QPanda3D_Modifiers_Translation.cpython-312.pyc differ diff --git a/QPanda3D/__pycache__/__init__.cpython-310.pyc b/QPanda3D/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 00000000..de84fbe6 Binary files /dev/null and b/QPanda3D/__pycache__/__init__.cpython-310.pyc differ diff --git a/QPanda3D/__pycache__/__init__.cpython-312.pyc b/QPanda3D/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 00000000..0593f5a3 Binary files /dev/null and b/QPanda3D/__pycache__/__init__.cpython-312.pyc differ diff --git a/__pycache__/main.cpython-310.pyc b/__pycache__/main.cpython-310.pyc index a63b5c2a..c8e668c0 100644 Binary files a/__pycache__/main.cpython-310.pyc and b/__pycache__/main.cpython-310.pyc differ diff --git a/core/__pycache__/__init__.cpython-310.pyc b/core/__pycache__/__init__.cpython-310.pyc index 965cbd26..d2fdb727 100644 Binary files a/core/__pycache__/__init__.cpython-310.pyc and b/core/__pycache__/__init__.cpython-310.pyc differ diff --git a/core/__pycache__/alvr_streamer.cpython-310.pyc b/core/__pycache__/alvr_streamer.cpython-310.pyc index 7b5e5c6e..4ef3703e 100644 Binary files a/core/__pycache__/alvr_streamer.cpython-310.pyc and b/core/__pycache__/alvr_streamer.cpython-310.pyc differ diff --git a/core/__pycache__/event_handler.cpython-310.pyc b/core/__pycache__/event_handler.cpython-310.pyc index 12ab585c..3b71ed7d 100644 Binary files a/core/__pycache__/event_handler.cpython-310.pyc and b/core/__pycache__/event_handler.cpython-310.pyc differ diff --git a/core/__pycache__/script_system.cpython-310.pyc b/core/__pycache__/script_system.cpython-310.pyc index 4cbece1d..cf6b6c40 100644 Binary files a/core/__pycache__/script_system.cpython-310.pyc and b/core/__pycache__/script_system.cpython-310.pyc differ diff --git a/core/__pycache__/selection.cpython-310.pyc b/core/__pycache__/selection.cpython-310.pyc index 088e92cd..09b0911a 100644 Binary files a/core/__pycache__/selection.cpython-310.pyc and b/core/__pycache__/selection.cpython-310.pyc differ diff --git a/core/__pycache__/tool_manager.cpython-310.pyc b/core/__pycache__/tool_manager.cpython-310.pyc index 059a8856..52317180 100644 Binary files a/core/__pycache__/tool_manager.cpython-310.pyc and b/core/__pycache__/tool_manager.cpython-310.pyc differ diff --git a/core/__pycache__/vr_input_handler.cpython-310.pyc b/core/__pycache__/vr_input_handler.cpython-310.pyc index 6c092eb2..0da2e4ca 100644 Binary files a/core/__pycache__/vr_input_handler.cpython-310.pyc and b/core/__pycache__/vr_input_handler.cpython-310.pyc differ diff --git a/core/__pycache__/vr_manager.cpython-310.pyc b/core/__pycache__/vr_manager.cpython-310.pyc index a105979b..25a3ceba 100644 Binary files a/core/__pycache__/vr_manager.cpython-310.pyc and b/core/__pycache__/vr_manager.cpython-310.pyc differ diff --git a/core/__pycache__/world.cpython-310.pyc b/core/__pycache__/world.cpython-310.pyc index 23fbf357..485744ac 100644 Binary files a/core/__pycache__/world.cpython-310.pyc and b/core/__pycache__/world.cpython-310.pyc differ diff --git a/gui/__pycache__/__init__.cpython-310.pyc b/gui/__pycache__/__init__.cpython-310.pyc index 87fdb57f..3c56f75c 100644 Binary files a/gui/__pycache__/__init__.cpython-310.pyc and b/gui/__pycache__/__init__.cpython-310.pyc differ diff --git a/gui/__pycache__/gui_manager.cpython-310.pyc b/gui/__pycache__/gui_manager.cpython-310.pyc index 0cc545c8..9f8f6429 100644 Binary files a/gui/__pycache__/gui_manager.cpython-310.pyc and b/gui/__pycache__/gui_manager.cpython-310.pyc differ diff --git a/project/__pycache__/__init__.cpython-310.pyc b/project/__pycache__/__init__.cpython-310.pyc index f1093286..d0c6797c 100644 Binary files a/project/__pycache__/__init__.cpython-310.pyc and b/project/__pycache__/__init__.cpython-310.pyc differ diff --git a/project/__pycache__/project_manager.cpython-310.pyc b/project/__pycache__/project_manager.cpython-310.pyc index f3b01555..6a8c3cbe 100644 Binary files a/project/__pycache__/project_manager.cpython-310.pyc and b/project/__pycache__/project_manager.cpython-310.pyc differ diff --git a/requirements/environment.yml b/requirements/environment.yml index c2b00ab0..8f4ae727 100644 --- a/requirements/environment.yml +++ b/requirements/environment.yml @@ -12,3 +12,4 @@ dependencies: - Pillow>=9.0.1 - python-dotenv>=1.0.1 - pyassimp>=5.2.5 + - six diff --git a/scene/__pycache__/__init__.cpython-310.pyc b/scene/__pycache__/__init__.cpython-310.pyc index cc8d1f69..4484bdae 100644 Binary files a/scene/__pycache__/__init__.cpython-310.pyc and b/scene/__pycache__/__init__.cpython-310.pyc differ diff --git a/scene/__pycache__/scene_manager.cpython-310.pyc b/scene/__pycache__/scene_manager.cpython-310.pyc index d0569060..bf71ed3d 100644 Binary files a/scene/__pycache__/scene_manager.cpython-310.pyc and b/scene/__pycache__/scene_manager.cpython-310.pyc differ diff --git a/ui/__pycache__/__init__.cpython-310.pyc b/ui/__pycache__/__init__.cpython-310.pyc index 44807446..c9f021c7 100644 Binary files a/ui/__pycache__/__init__.cpython-310.pyc and b/ui/__pycache__/__init__.cpython-310.pyc differ diff --git a/ui/__pycache__/interface_manager.cpython-310.pyc b/ui/__pycache__/interface_manager.cpython-310.pyc index ee60e0bc..cd768475 100644 Binary files a/ui/__pycache__/interface_manager.cpython-310.pyc and b/ui/__pycache__/interface_manager.cpython-310.pyc differ diff --git a/ui/__pycache__/main_window.cpython-310.pyc b/ui/__pycache__/main_window.cpython-310.pyc index 1369cee6..25a653cc 100644 Binary files a/ui/__pycache__/main_window.cpython-310.pyc and b/ui/__pycache__/main_window.cpython-310.pyc differ diff --git a/ui/__pycache__/property_panel.cpython-310.pyc b/ui/__pycache__/property_panel.cpython-310.pyc index 1c16026d..53ee7961 100644 Binary files a/ui/__pycache__/property_panel.cpython-310.pyc and b/ui/__pycache__/property_panel.cpython-310.pyc differ diff --git a/ui/__pycache__/widgets.cpython-310.pyc b/ui/__pycache__/widgets.cpython-310.pyc index 19bed79e..eb6846b3 100644 Binary files a/ui/__pycache__/widgets.cpython-310.pyc and b/ui/__pycache__/widgets.cpython-310.pyc differ