移除qt依赖

This commit is contained in:
Rowland 2026-01-28 10:06:36 +08:00
parent f07a394d9f
commit 33e62bd1e4
15 changed files with 2467 additions and 2473 deletions

View File

@ -1,271 +0,0 @@
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

View File

@ -1,2 +0,0 @@
name="QMeta3D"
__all__ = ["Env_Grid_Maker"]

View File

@ -1,188 +0,0 @@
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)
from RenderPipelineFile.rpcore import RenderPipeline
_global_render_pipeline = None
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from panda3d.core import *
from panda3d.core import GraphicsOutput, Texture, ConfigVariableManager, WindowProperties
from direct.showbase.ShowBase import ShowBase
import platform
from QMeta3D.QMouseWatcherNode import QMouseWatcherNode
from RenderPipelineFile.rpcore.render_target import RenderTarget
__all__ = ["Meta3DWorld"]
_global_world_instance=None
import builtins
class Meta3DWorld(ShowBase):
def __init__(self, width=1380, height=750, is_fullscreen=False, size=1.0, clear_color=LVecBase4f(0, 0.5, 0, 1),
name="qMeta3D"):
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 onscreen") # 改为正常窗口渲染
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")
# loadPrcFileData("", "gl-debug true")
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
# 正常窗口渲染不需要额外的输出纹理
# 注释掉离屏渲染相关的纹理创建
# 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.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 3DWorld instance first.")
return _global_render_pipeline
def resize_buffer(self, width: int, height: int):
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()

View File

@ -1,236 +0,0 @@
from PyQt5 import QtWidgets, QtGui
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from direct.task.TaskManagerGlobal import taskMgr
from QMeta3D.QMeta3D_Buttons_Translation import QMeta3D_Button_translation
from QMeta3D.QMeta3D_Keys_Translation import QMeta3D_Key_translation
from QMeta3D.QMeta3D_Modifiers_Translation import QMeta3D_Modifier_translation
__all__ = ["QMeta3DWidget"]
class QMeta3DSynchronizer(QTimer):
def __init__(self, qMeta3DWidget, FPS=60):
QTimer.__init__(self)
self.qMeta3DWidget = qMeta3DWidget
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.qMeta3DWidget.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.qMeta3DWidget.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 QMeta3D_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 QMeta3DWidget(QWidget):
def __init__(self, Meta3DWorld, parent=None, FPS=60, debug=False):
QWidget.__init__(self, parent)
self.rp_sync_requested = False
# set fixed geometry
self.Meta3DWorld = Meta3DWorld
self.Meta3DWorld.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.Meta3DWorld.cam.node().get_lens().get_film_size()
self.initial_film_size = QSizeF(size.x, size.y)
self.initial_size = self.size()
self.synchronizer = QMeta3DSynchronizer(self, FPS)
self.synchronizer.start()
self.debug = debug
def mousePressEvent(self, evt):
button = evt.button()
try:
b = "{}{}".format(get_panda_key_modifiers_prefix(evt), QMeta3D_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), QMeta3D_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), QMeta3D_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), QMeta3D_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 Meta3DWorld import resize_buffer
lens = self.Meta3DWorld.cam.node().get_lens()
def minimumSizeHint(self):
return QSize(400, 300)
def paintEvent(self, event):
# 正常窗口渲染模式下Panda3D 会直接渲染到窗口
# 不需要从纹理复制数据
# 只需要确保渲染循环继续运行
# 触发一次渲染更新
if hasattr(self.Meta3DWorld, 'win') and self.Meta3DWorld.win:
# 确保窗口大小匹配
width = self.width()
height = self.height()
# 如果窗口大小不匹配,更新窗口属性
if (self.Meta3DWorld.win.get_x_size() != width or
self.Meta3DWorld.win.get_y_size() != height):
from panda3d.core import WindowProperties
props = WindowProperties()
props.setSize(width, height)
self.Meta3DWorld.win.request_properties(props)
# 继续下一次更新
self.update()
def sync_Meta3d_window_size(self, width, height):
try:
from panda3d.core import WindowProperties
# 更新窗口属性
props = WindowProperties()
props.setSize(width, height)
# 对于正常窗口渲染,直接更新窗口属性
if self.Meta3DWorld.win:
self.Meta3DWorld.win.request_properties(props)
# 如果使用 RenderPipeline更新相关设置
if hasattr(self.Meta3DWorld, 'render_pipeline'):
try:
from RenderPipelineFile.rpcore.globals import Globals
from panda3d.core import LVecBase2i
# 更新全局分辨率
Globals.native_resolution = LVecBase2i(width, height)
# 重新计算渲染分辨率
self.Meta3DWorld.render_pipeline._compute_render_resolution()
# 通知各个管理器处理尺寸变化
self.Meta3DWorld.render_pipeline.light_mgr.compute_tile_size()
self.Meta3DWorld.render_pipeline.stage_mgr.handle_window_resize()
if hasattr(self.Meta3DWorld.render_pipeline, 'debugger'):
self.Meta3DWorld.render_pipeline.debugger.handle_window_resize()
# 触发插件的窗口尺寸变化钩子
self.Meta3DWorld.render_pipeline.plugin_mgr.trigger_hook("window_resized")
except Exception as rp_e:
print(f"RenderPipeline 尺寸更新失败: {rp_e}")
except Exception as e:
print(f"同步 Meta3D 窗口尺寸失败: {str(e)}")

View File

@ -1,43 +0,0 @@
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import sys
__all__ = ["QMeta3D_Keys_Translation.py"]
QMeta3D_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',
}

View File

@ -1,477 +0,0 @@
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import sys
__all__ = ["QMeta3D_Keys_Translation.py"]
QMeta3D_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',
}

View File

@ -1,15 +0,0 @@
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import sys
__all__ = ["QMeta3D_Modifiers_Translation.py"]
QMeta3D_Modifier_translation ={
Qt.NoModifier:None,
Qt.ShiftModifier:'shift',
Qt.ControlModifier:'control',
Qt.AltModifier:'alt',
Qt.MetaModifier:'unknown',
Qt.KeypadModifier:'unknown',
Qt.GroupSwitchModifier:'unknown',
}

View File

@ -1,27 +0,0 @@
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from panda3d.core import *
__all__ = ["QMouseWatcherNode"]
class QMouseWatcherNode(MouseWatcher):
def __init__(self, parent):
super().__init__()
self.parent = parent
def getMouse(self, *args, **kwargs):
pos = self.parent.mapFromGlobal(QCursor.pos())
rel_x = -1 + 2 * pos.x() / self.parent.width()
rel_y = -1 + 2 * pos.y() / self.parent.height()
rel_y = -rel_y
return LPoint2(rel_x, rel_y)
def hasMouse(self):
return isinstance(self.parent, QWidget)

View File

@ -1,2 +0,0 @@
name="QMeta3D"
__all__ = ["generate_qt_to_pd3d_translator"]

View File

@ -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_")]
QMeta3D_Key_translation = "QMeta3D_Key_translation ={"
for i in range(len(lst)):
QMeta3D_Key_translation += "Qt.{}:'unknown',\n".format(lst[i])
QMeta3D_Key_translation += "}"
print(QMeta3D_Key_translation)

View File

@ -1,2 +0,0 @@
name="QMeta3D"
__all__ = ["QMeta3DWidget.py", "Meta3DWorld.py", "QMeta3D_Keys_Translation.py"]

View File

@ -0,0 +1,20 @@
"""
渲染管线工具模块
提供全局渲染管线实例的访问功能
"""
# 全局渲染管线实例
_global_render_pipeline = None
def get_render_pipeline():
"""获取全局 RenderPipeline 单例"""
global _global_render_pipeline
if _global_render_pipeline is None:
raise RuntimeError(
"RenderPipeline has not been initialized yet. Please create a CoreWorld instance first.")
return _global_render_pipeline
def set_render_pipeline(pipeline):
"""设置全局渲染管线实例"""
global _global_render_pipeline
_global_render_pipeline = pipeline

File diff suppressed because it is too large Load Diff

1192
core/world.py.backup Normal file

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,7 @@ import inspect
from pathlib import Path from pathlib import Path
from panda3d.egg import EggData, EggVertexPool from panda3d.egg import EggData, EggVertexPool
from direct.actor.Actor import Actor from direct.actor.Actor import Actor
from QMeta3D.Meta3DWorld import get_render_pipeline from core.render_pipeline_utils import get_render_pipeline
from RenderPipelineFile.rpplugins.smaa.jitters import halton_seq from RenderPipelineFile.rpplugins.smaa.jitters import halton_seq
from scene import util from scene import util
@ -2540,7 +2540,7 @@ class SceneManager:
"""重新创建点光源""" """重新创建点光源"""
try: try:
from RenderPipelineFile.rpcore import PointLight from RenderPipelineFile.rpcore import PointLight
from QMeta3D.Meta3DWorld import get_render_pipeline from core.render_pipeline_utils import get_render_pipeline
# 创建点光源对象 # 创建点光源对象
light = PointLight() light = PointLight()
@ -2711,7 +2711,7 @@ class SceneManager:
"""创建聚光灯 - 支持多选创建,优化版本""" """创建聚光灯 - 支持多选创建,优化版本"""
try: try:
from RenderPipelineFile.rpcore import SpotLight from RenderPipelineFile.rpcore import SpotLight
from QMeta3D.Meta3DWorld import get_render_pipeline from core.render_pipeline_utils import get_render_pipeline
from panda3d.core import Vec3, NodePath from panda3d.core import Vec3, NodePath
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
@ -2820,7 +2820,7 @@ class SceneManager:
"""创建点光源 - 支持多选创建,优化版本""" """创建点光源 - 支持多选创建,优化版本"""
try: try:
from RenderPipelineFile.rpcore import PointLight from RenderPipelineFile.rpcore import PointLight
from QMeta3D.Meta3DWorld import get_render_pipeline from core.render_pipeline_utils import get_render_pipeline
from panda3d.core import Vec3, NodePath from panda3d.core import Vec3, NodePath
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
@ -2975,7 +2975,7 @@ class SceneManager:
return return
# 获取RenderPipeline实例 # 获取RenderPipeline实例
from QMeta3D.Meta3DWorld import get_render_pipeline from core.render_pipeline_utils import get_render_pipeline
render_pipeline = get_render_pipeline() render_pipeline = get_render_pipeline()
if not render_pipeline: if not render_pipeline:
@ -4537,7 +4537,7 @@ except Exception as e:
# 检查是否使用RenderPipeline # 检查是否使用RenderPipeline
if hasattr(self.world, 'render_pipeline') and self.world.render_pipeline: if hasattr(self.world, 'render_pipeline') and self.world.render_pipeline:
from RenderPipelineFile.rpcore import SpotLight from RenderPipelineFile.rpcore import SpotLight
from QMeta3D.Meta3DWorld import get_render_pipeline from core.render_pipeline_utils import get_render_pipeline
# 创建RenderPipeline聚光灯 # 创建RenderPipeline聚光灯
from panda3d.core import Vec3 from panda3d.core import Vec3
@ -4615,7 +4615,7 @@ except Exception as e:
# 检查是否使用RenderPipeline # 检查是否使用RenderPipeline
if hasattr(self.world, 'render_pipeline') and self.world.render_pipeline: if hasattr(self.world, 'render_pipeline') and self.world.render_pipeline:
from RenderPipelineFile.rpcore import PointLight from RenderPipelineFile.rpcore import PointLight
from QMeta3D.Meta3DWorld import get_render_pipeline from core.render_pipeline_utils import get_render_pipeline
# 创建RenderPipeline点光源 # 创建RenderPipeline点光源
pointlight = PointLight() pointlight = PointLight()