在Jupyter Notebook的Panda3D中加载鸡蛋文件



我正在尝试在Jupyter Notebook中使用Panda3D,但是在加载模型(即.egg文件(时遇到问题。

以下代码片段在命令行运行,但不在 Jupyter 笔记本中运行:

from direct.showbase.ShowBase import ShowBase    
from panda3d.core import Filename
class MyApp(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)
    def load_a_model(self):
        panda_file = Filename.fromOsSpecific('models\myModel')
        obj_model = self.loader.loadModel(panda_file)
anApp = MyApp()
anApp.load_a_model()
anApp.run()

Jupyter Notebook给出的错误是:

---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-1-c9c9444b3a7f> in <module>()
     11 
     12 anApp = MyApp()
---> 13 anApp.load_a_model()
     14 anApp.run()
<ipython-input-1-c9c9444b3a7f> in load_a_model(self)
      8     def load_a_model(self):
      9         panda_file = Filename.fromOsSpecific('models\myModel')
---> 10         obj_model = self.loader.loadModel(panda_file)
     11 
     12 anApp = MyApp()
C:Panda3D-1.9.3-x64directshowbaseLoader.pyc in loadModel(self, modelPath, loaderOptions, noCache, allowInstance, okMissing, callback, extraArgs, priority)
    168             if not okMissing and None in result:
    169                 message = 'Could not load model file(s): %s' % (modelList,)
--> 170                 raise IOError, message
    171 
    172             if gotList:
IOError: Could not load model file(s): [Filename('models/myModel')]

知道问题是什么吗?

Panda3D 使用与平台无关的路径,因此您应该使用正斜杠而不是反斜杠。 因此,请指定models/myModel .

相关内容

  • 没有找到相关文章

最新更新