diff --git a/QPanda3D/Helpers/Env_Grid_Maker.py b/QPanda3D/Helpers/Env_Grid_Maker.py deleted file mode 100644 index 7f0fd0ec..00000000 --- a/QPanda3D/Helpers/Env_Grid_Maker.py +++ /dev/null @@ -1,279 +0,0 @@ -# -*- 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 deleted file mode 100644 index 376e08da..00000000 --- a/QPanda3D/Helpers/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -name="QPanda3D" -__all__ = ["Env_Grid_Maker"] \ No newline at end of file diff --git a/QPanda3D/Panda3DWorld.py b/QPanda3D/Panda3DWorld.py deleted file mode 100644 index e717b68c..00000000 --- a/QPanda3D/Panda3DWorld.py +++ /dev/null @@ -1,214 +0,0 @@ -# -*- coding: utf-8-*- -""" -Module : Panda3DWorld -Author : Saifeddine ALOUI -Description : - Inherit this object to create your custom world -""" -import sys -import os - -from core.CustomMouseController import CustomMouseController - -# 获取 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 RenderPipelineFile.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=1380, height=750, 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 - - # 设置基本配置 - loadPrcFileData("", "show-frame-rate-meter 0") - loadPrcFileData("", "window-type offscreen") # 设置为离屏渲染 - loadPrcFileData("", f"win-size {width} {height}") - loadPrcFileData("", "win-fixed-size #f") # 允许窗口调整大小 - - # 🚀 VR性能优化配置 - loadPrcFileData("", "prefer-single-buffer true") # 减少缓冲区交换开销 - loadPrcFileData("", "gl-force-flush false") # 避免强制glFlush导致的性能损失 - loadPrcFileData("", "sync-video false") # 禁用默认VSync,让OpenVR控制 - loadPrcFileData("", "support-stencil false") # 禁用不必要的模板缓冲区 - loadPrcFileData("", "clock-mode non-real-time") # 禁用Panda3D帧率控制,让OpenVR控制 - # loadPrcFileData("", "gl-debug true") # 调试时可启用OpenGL调试 - - if (is_fullscreen): - loadPrcFileData("", "fullscreen #t") - - self.render_pipeline = RenderPipeline() - self.render_pipeline.pre_showbase_init() - - ShowBase.__init__(self) - - # 初始化渲染管线并设置可调整大小的标志 - self.render_pipeline.create(self) - _global_render_pipeline = self.render_pipeline - - # 创建 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) - - # # 获取图形管线对象 - # gsg = self.win.getGsg() - # host = gsg.getEngine().getHost() - - 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() - self.mouse_controller = CustomMouseController(self) - self.mouse_controller.setUp() - - # 添加错误处理钩子 - self.accept("transform_state_error", self._handle_transform_error) - - def _handle_transform_error(self): - """处理TransformState相关的错误""" - try: - from panda3d.core import TransformState, RenderState - TransformState.clear_cache() - RenderState.clear_cache() - print("已清理TransformState和RenderState缓存") - except Exception as e: - print(f"清理缓存时出错: {e}") - - 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 - -def resize_buffer(self, width: int, height: int): - """根据新窗口尺寸调整 Panda3D 渲染输出尺寸""" - # 设置 Panda3D 的窗口尺寸(offscreen 模式下对应输出区域) - props = WindowProperties() - props.set_size(width, height) - self.win.request_properties(props) - - # 重新分配输出贴图的大小 - self.qt_output_tex.set_x_size(width) - self.qt_output_tex.set_y_size(height) - - # 更新 lens 的 aspect ratio - if self.camLens: - self.camLens.set_film_size(width, height) # 或 set_aspect_ratio(width / height) - - # 强制更新窗口(有时在 Qt 内嵌时需要) - self.graphicsEngine.open_windows() \ No newline at end of file diff --git a/QPanda3D/QMouseWatcherNode.py b/QPanda3D/QMouseWatcherNode.py deleted file mode 100644 index c810df66..00000000 --- a/QPanda3D/QMouseWatcherNode.py +++ /dev/null @@ -1,41 +0,0 @@ -# -*- 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 deleted file mode 100644 index 672ad897..00000000 --- a/QPanda3D/QPanda3DWidget.py +++ /dev/null @@ -1,355 +0,0 @@ -# -*- 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 * -from direct.task.TaskManagerGlobal import taskMgr - -# 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): - try: - # 在渲染前清理可能损坏的TransformState对象 - from panda3d.core import TransformState - TransformState.clear_cache() - - taskMgr.step() - self.qPanda3DWidget.update() - except AssertionError as e: - # 专门处理 TransformState has_mat() 断言错误 - if "has_mat" in str(e): - print(f"警告: 检测到TransformState断言错误,已静默处理: {e}") - # 尝试恢复渲染状态 - try: - # 强制清理缓存并重试 - from panda3d.core import TransformState, RenderState - TransformState.clear_cache() - RenderState.clear_cache() - taskMgr.step() - self.qPanda3DWidget.update() - except: - pass - else: - # 重新抛出其他断言错误 - raise - except Exception as e: - # 静默处理其他所有异常 - print(f"警告: 检测到异常,已静默处理: {e}") - - -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): - width = evt.size().width() - height = evt.size().height() - #print(f"width:{width}") - #print(f"height:{height}") - - from Panda3DWorld import resize_buffer - #resize_buffer(width, height) - - 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.sync_panda3d_window_size(width, 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() - - def paintEvent(self, event): - tex = self.panda3DWorld.qt_output_tex - gsg = base.win.getGsg() - - if not gsg: - self.update() - return - - if not tex.hasRamImage(): - base.graphicsEngine.extractTextureData(tex, gsg) - self.update() - return - - data = tex.getRamImage().getData() - tex_width = tex.getXSize() - tex_height = tex.getYSize() - expected_len = tex_width * tex_height * 4 - - if len(data) != expected_len: - print(f"⚠️ 像素数据长度异常({len(data)} != {expected_len}),跳过绘制") - self.update() - return - - img = QImage(data, tex_width, tex_height, QImage.Format_ARGB32).mirrored() - - widget_width = self.width() - widget_height = self.height() - - painter = QPainter(self) - - # 【保持宽高比的缩放】 - scaled_img = img.scaled(widget_width, widget_height, Qt.KeepAspectRatio, Qt.SmoothTransformation) - - # 居中绘制 - x_offset = (widget_width - scaled_img.width()) // 2 - y_offset = (widget_height - scaled_img.height()) // 2 - - painter.drawImage(x_offset, y_offset, scaled_img) - painter.end() - - def sync_panda3d_window_size(self, width, height): - """同步 Panda3D 窗口尺寸到 Qt 窗口尺寸""" - try: - from panda3d.core import WindowProperties, LVecBase2i - - # 确保尺寸是4的倍数(RenderPipeline 要求) - adjusted_width = width - width % 4 - adjusted_height = height - height % 4 - - # 更新窗口属性 - props = WindowProperties() - props.setSize(adjusted_width, adjusted_height) - - # 对于 offscreen 渲染,直接更新窗口属性 - if self.panda3DWorld.win: - self.panda3DWorld.win.request_properties(props) - - # 手动触发 RenderPipeline 的尺寸更新逻辑 - if hasattr(self.panda3DWorld, 'render_pipeline'): - # 更新全局分辨率 - from RenderPipelineFile.rpcore.globals import Globals - Globals.native_resolution = LVecBase2i(adjusted_width, adjusted_height) - - # 重新计算渲染分辨率 - self.panda3DWorld.render_pipeline._compute_render_resolution() - - # 通知各个管理器处理尺寸变化 - self.panda3DWorld.render_pipeline.light_mgr.compute_tile_size() - self.panda3DWorld.render_pipeline.stage_mgr.handle_window_resize() - if hasattr(self.panda3DWorld.render_pipeline, 'debugger'): - self.panda3DWorld.render_pipeline.debugger.handle_window_resize() - - # 触发插件的窗口尺寸变化钩子 - self.panda3DWorld.render_pipeline.plugin_mgr.trigger_hook("window_resized") - - print(f"Panda3D 窗口尺寸已同步为: {adjusted_width} x {adjusted_height}") - - except Exception as e: - print(f"同步 Panda3D 窗口尺寸失败: {str(e)}") \ No newline at end of file diff --git a/QPanda3D/QPanda3D_Buttons_Translation.py b/QPanda3D/QPanda3D_Buttons_Translation.py deleted file mode 100644 index db011c66..00000000 --- a/QPanda3D/QPanda3D_Buttons_Translation.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- 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 deleted file mode 100644 index 97d510b7..00000000 --- a/QPanda3D/QPanda3D_Keys_Translation.py +++ /dev/null @@ -1,486 +0,0 @@ -# -*- 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 deleted file mode 100644 index ce32160b..00000000 --- a/QPanda3D/QPanda3D_Modifiers_Translation.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- 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 deleted file mode 100644 index 03b1010f..00000000 --- a/QPanda3D/Tools/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -name="QPanda3D" -__all__ = ["generate_qt_to_pd3d_translator"] \ No newline at end of file diff --git a/QPanda3D/Tools/generate_qt_to_pd3d_translator.py b/QPanda3D/Tools/generate_qt_to_pd3d_translator.py deleted file mode 100644 index 9b4b6c69..00000000 --- a/QPanda3D/Tools/generate_qt_to_pd3d_translator.py +++ /dev/null @@ -1,11 +0,0 @@ -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 deleted file mode 100644 index 5cf0b25b..00000000 --- a/QPanda3D/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -name="QPanda3D" -__all__ = ["QPanda3DWidget", "Panda3DWorld", "QPanda3D_Keys_Translation"] \ No newline at end of file diff --git a/Resources/models/DancingTwerk.glb b/Resources/models/DancingTwerk.glb deleted file mode 100644 index 1567bf93..00000000 Binary files a/Resources/models/DancingTwerk.glb and /dev/null differ diff --git a/Resources/models/Haqijingzhu.glb b/Resources/models/Haqijingzhu.glb deleted file mode 100644 index 0b5e1df0..00000000 Binary files a/Resources/models/Haqijingzhu.glb and /dev/null differ diff --git a/Resources/models/JQB_auto_converted.glb b/Resources/models/JQB_auto_converted.glb deleted file mode 100644 index 89df9e5b..00000000 Binary files a/Resources/models/JQB_auto_converted.glb and /dev/null differ diff --git a/Resources/models/Women_1.glb b/Resources/models/Women_1.glb deleted file mode 100644 index 79ebe8d2..00000000 Binary files a/Resources/models/Women_1.glb and /dev/null differ diff --git a/Resources/models/Women_2.glb b/Resources/models/Women_2.glb deleted file mode 100644 index efba7b02..00000000 Binary files a/Resources/models/Women_2.glb and /dev/null differ diff --git a/Resources/models/women_1.glb b/Resources/models/women_1.glb deleted file mode 100644 index f634ea92..00000000 Binary files a/Resources/models/women_1.glb and /dev/null differ diff --git a/core/world.py b/core/world.py index 696161c2..4eab375e 100644 --- a/core/world.py +++ b/core/world.py @@ -6,7 +6,7 @@ from direct.actor.Actor import Actor warnings.filterwarnings("ignore", category=DeprecationWarning) -from QPanda3D.Panda3DWorld import Panda3DWorld +from QMeta3D.Meta3DWorld import Panda3DWorld from panda3d.core import (CardMaker, Vec4, Vec3, AmbientLight, DirectionalLight, Point3, WindowProperties,Material,LColor) from direct.showbase.ShowBaseGlobal import globalClock diff --git a/demo/test_gizmo_drag.py b/demo/test_gizmo_drag.py index 4a1b39d2..c70d101c 100644 --- a/demo/test_gizmo_drag.py +++ b/demo/test_gizmo_drag.py @@ -11,8 +11,8 @@ warnings.filterwarnings("ignore", category=DeprecationWarning) import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget, QLabel, QPushButton, QHBoxLayout from PyQt5.QtCore import Qt -from QPanda3D.QPanda3DWidget import QPanda3DWidget -from QPanda3D.Panda3DWorld import Panda3DWorld +from QMeta3D.QMeta3DWidget import QPanda3DWidget +from QMeta3D.Meta3DWorld import Panda3DWorld from panda3d.core import * from direct.task import Task diff --git a/demo/test_gui_complete.py b/demo/test_gui_complete.py index 46a73aac..155d2c6b 100644 --- a/demo/test_gui_complete.py +++ b/demo/test_gui_complete.py @@ -16,8 +16,8 @@ from PyQt5.QtWidgets import (QApplication, QMainWindow, QMenuBar, QMenu, QAction QLabel, QLineEdit, QFormLayout, QDoubleSpinBox, QScrollArea, QTreeView, QInputDialog, QFileDialog, QMessageBox, QDialog, QGroupBox, QHBoxLayout, QPushButton, QDialogButtonBox) from PyQt5.QtCore import Qt, QDir, QUrl from PyQt5.QtGui import QDrag, QPainter, QPixmap -from QPanda3D.QPanda3DWidget import QPanda3DWidget -from QPanda3D.Panda3DWorld import Panda3DWorld +from QMeta3D.QMeta3DWidget import QPanda3DWidget +from QMeta3D.Meta3DWorld import Panda3DWorld from direct.gui.DirectGui import * from direct.gui.OnscreenText import OnscreenText from panda3d.core import * diff --git a/demo/test_qt_debug.py b/demo/test_qt_debug.py index c894c430..3884ccfc 100644 --- a/demo/test_qt_debug.py +++ b/demo/test_qt_debug.py @@ -12,8 +12,8 @@ warnings.filterwarnings("ignore", category=DeprecationWarning) import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget, QLabel from PyQt5.QtCore import Qt -from QPanda3D.QPanda3DWidget import QPanda3DWidget -from QPanda3D.Panda3DWorld import Panda3DWorld +from QMeta3D.QMeta3DWidget import QPanda3DWidget +from QMeta3D.Meta3DWorld import Panda3DWorld from direct.gui.DirectGui import * from direct.gui.OnscreenText import OnscreenText from panda3d.core import * diff --git a/demo/test_qt_fix.py b/demo/test_qt_fix.py index 38dd949f..e9c4a28c 100644 --- a/demo/test_qt_fix.py +++ b/demo/test_qt_fix.py @@ -12,8 +12,8 @@ warnings.filterwarnings("ignore", category=DeprecationWarning) import sys from PyQt5.QtWidgets import QApplication, QMainWindow from PyQt5.QtCore import Qt -from QPanda3D.QPanda3DWidget import QPanda3DWidget -from QPanda3D.Panda3DWorld import Panda3DWorld +from QMeta3D.QMeta3DWidget import QPanda3DWidget +from QMeta3D.Meta3DWorld import Panda3DWorld from direct.gui.DirectGui import * from direct.gui.OnscreenText import OnscreenText from panda3d.core import * diff --git a/demo/test_qt_gui_fix.py b/demo/test_qt_gui_fix.py index 3cdb0f43..470dfd24 100644 --- a/demo/test_qt_gui_fix.py +++ b/demo/test_qt_gui_fix.py @@ -13,8 +13,8 @@ import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget, QLabel from PyQt5.QtCore import Qt from PyQt5.QtGui import QMouseEvent -from QPanda3D.QPanda3DWidget import QPanda3DWidget -from QPanda3D.Panda3DWorld import Panda3DWorld +from QMeta3D.QMeta3DWidget import QPanda3DWidget +from QMeta3D.Meta3DWorld import Panda3DWorld from direct.gui.DirectGui import * from direct.gui.OnscreenText import OnscreenText from panda3d.core import * diff --git a/demo/test_qt_only.py b/demo/test_qt_only.py index 9aeeded6..e97b70f3 100644 --- a/demo/test_qt_only.py +++ b/demo/test_qt_only.py @@ -11,8 +11,8 @@ warnings.filterwarnings("ignore", category=DeprecationWarning) import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget, QLabel from PyQt5.QtCore import Qt -from QPanda3D.QPanda3DWidget import QPanda3DWidget -from QPanda3D.Panda3DWorld import Panda3DWorld +from QMeta3D.QMeta3DWidget import QPanda3DWidget +from QMeta3D.Meta3DWorld import Panda3DWorld from direct.gui.DirectGui import * from direct.gui.OnscreenText import OnscreenText from panda3d.core import * diff --git a/demo/test_qt_vs_showbase.py b/demo/test_qt_vs_showbase.py index 644af27d..f4d212f5 100644 --- a/demo/test_qt_vs_showbase.py +++ b/demo/test_qt_vs_showbase.py @@ -12,8 +12,8 @@ warnings.filterwarnings("ignore", category=DeprecationWarning) import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget, QLabel, QPushButton from PyQt5.QtCore import Qt -from QPanda3D.QPanda3DWidget import QPanda3DWidget -from QPanda3D.Panda3DWorld import Panda3DWorld +from QMeta3D.QMeta3DWidget import QPanda3DWidget +from QMeta3D.Meta3DWorld import Panda3DWorld from direct.showbase.ShowBase import ShowBase from direct.gui.DirectGui import * from direct.gui.OnscreenText import OnscreenText diff --git a/demo/test_simplified_gizmo.py b/demo/test_simplified_gizmo.py index a4da6642..19f74314 100644 --- a/demo/test_simplified_gizmo.py +++ b/demo/test_simplified_gizmo.py @@ -11,7 +11,7 @@ warnings.filterwarnings("ignore", category=DeprecationWarning) import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget, QLabel, QPushButton, QHBoxLayout from PyQt5.QtCore import Qt -from QPanda3D.QPanda3DWidget import QPanda3DWidget +from QMeta3D.QMeta3DWidget import QPanda3DWidget sys.path.append('..') from main import MyWorld, CustomPanda3DWidget diff --git a/demo/test_size_fix.py b/demo/test_size_fix.py index 328d8ed8..1746ea21 100644 --- a/demo/test_size_fix.py +++ b/demo/test_size_fix.py @@ -11,8 +11,8 @@ warnings.filterwarnings("ignore", category=DeprecationWarning) import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget, QLabel from PyQt5.QtCore import Qt -from QPanda3D.QPanda3DWidget import QPanda3DWidget -from QPanda3D.Panda3DWorld import Panda3DWorld +from QMeta3D.QMeta3DWidget import QPanda3DWidget +from QMeta3D.Meta3DWorld import Panda3DWorld from panda3d.core import * from direct.task import Task diff --git a/main.py b/main.py index 9e100431..84df4d4b 100644 --- a/main.py +++ b/main.py @@ -15,7 +15,7 @@ from PyQt5.QtWidgets import (QApplication, QMainWindow, QMenuBar, QMenu, QAction from PyQt5.QtCore import Qt, QDir, QUrl from PyQt5.QtGui import QDrag, QPainter, QPixmap from PyQt5.QtWidgets import QFileSystemModel -from QPanda3D.QPanda3DWidget import QPanda3DWidget +from QMeta3D.QMeta3DWidget import QPanda3DWidget from panda3d.core import loadPrcFileData loadPrcFileData("", "assertions 0") from core.world import CoreWorld diff --git a/scene/scene_manager.py b/scene/scene_manager.py index 288ac4db..274f9a36 100644 --- a/scene/scene_manager.py +++ b/scene/scene_manager.py @@ -24,7 +24,7 @@ import inspect from pathlib import Path from panda3d.egg import EggData, EggVertexPool from direct.actor.Actor import Actor -from QPanda3D.Panda3DWorld import get_render_pipeline +from QMeta3D.Meta3DWorld import get_render_pipeline from RenderPipelineFile.rpplugins.smaa.jitters import halton_seq from scene import util @@ -2304,7 +2304,7 @@ class SceneManager: """重新创建点光源""" try: from RenderPipelineFile.rpcore import PointLight - from QPanda3D.Panda3DWorld import get_render_pipeline + from QMeta3D.Meta3DWorld import get_render_pipeline # 创建点光源对象 light = PointLight() @@ -2445,7 +2445,7 @@ class SceneManager: """创建聚光灯 - 支持多选创建,优化版本""" try: from RenderPipelineFile.rpcore import SpotLight - from QPanda3D.Panda3DWorld import get_render_pipeline + from QMeta3D.Meta3DWorld import get_render_pipeline from panda3d.core import Vec3, NodePath from PyQt5.QtCore import Qt @@ -2553,7 +2553,7 @@ class SceneManager: """创建点光源 - 支持多选创建,优化版本""" try: from RenderPipelineFile.rpcore import PointLight - from QPanda3D.Panda3DWorld import get_render_pipeline + from QMeta3D.Meta3DWorld import get_render_pipeline from panda3d.core import Vec3, NodePath from PyQt5.QtCore import Qt diff --git a/ui/widgets.py b/ui/widgets.py index 6f59fc59..607eea15 100644 --- a/ui/widgets.py +++ b/ui/widgets.py @@ -20,7 +20,7 @@ from PyQt5.sip import wrapinstance from direct.showbase.ShowBaseGlobal import aspect2d from panda3d.core import ModelRoot, NodePath, CollisionNode -from QPanda3D.QPanda3DWidget import QPanda3DWidget +from QMeta3D.QMeta3DWidget import QPanda3DWidget from scene import util from ui.icon_manager import get_icon_manager @@ -4196,7 +4196,7 @@ class CustomTreeWidget(QTreeWidget): def _createSpotLightNode(self, parent_node, parent_item): """创建聚光灯节点""" from RenderPipelineFile.rpcore import SpotLight - from QPanda3D.Panda3DWorld import get_render_pipeline + from QMeta3D.Meta3DWorld import get_render_pipeline from panda3d.core import Vec3, NodePath try: @@ -4252,7 +4252,7 @@ class CustomTreeWidget(QTreeWidget): def _createPointLightNode(self, parent_node, parent_item): """创建点光源节点""" from RenderPipelineFile.rpcore import PointLight - from QPanda3D.Panda3DWorld import get_render_pipeline + from QMeta3D.Meta3DWorld import get_render_pipeline from panda3d.core import Vec3, NodePath try: