0

我试图用 Python 场景创建 Panda3D,当我尝试运行我的 Python 代码时,我得到了这个:

http://tinypic.com/r/15duueg/8

这是我的代码:

from direct.actor.Actor import Actor
from pandac.PandaModules import *
from direct.task import Task
import math
from math import pi, sin, cos
from direct.showbase.ShowBase import ShowBase
from direct.task import Task
from direct.interval.IntervalGlobal import Sequence
from pandac.PandaModules import Point3
from pandac.PandaModules import *

import direct.directbase.DirectStart
from panda3d.core import CollisionTraverser,CollisionNode
from panda3d.core import CollisionHandlerQueue,CollisionRay
from panda3d.core import Filename,AmbientLight,DirectionalLight
from panda3d.core import PandaNode,NodePath,Camera,TextNode
from panda3d.core import Vec3,Vec4,BitMask32
from direct.gui.OnscreenText import OnscreenText
from direct.actor.Actor import Actor
from direct.showbase.DirectObject import DirectObject

#Base Toontown Central
terrain = loader.loadModel('phase_4/models/neighborhoods/toontown_central.bam')
terrain.setPos(9.15527e-005, -1.90735e-006, 2.6226e-006)
terrain.setHpr(-90, 0, -0)
terrain.reparentTo(render)
terrain.setTransparency(TransparencyAttrib.MBinary, 1)

#Sky
sky = loader.loadModel('phase_3.5/models/props/TT_sky.bam')
sky.reparentTo(render)

#Pier
pier = loader.loadModel('phase_4/models/props/piers_tt.bam')
pier.setPos(-63.5335, 41.648, -3.36708)
pier.setHpr(120, 0, 0)
pier.reparentTo(render)

#Tunnel MM

tunnelthree = loader.loadModel('phase_4/models/modules/safe_zone_tunnel_TT.bam')
tunnelthree.reparentTo(render)
tunnelthree.setPos(-239.67,64.08,-6.18)
tunnelthree.setHpr(-90,0,0)
sign = loader.loadModel('phase_3.5/models/props/tunnel_sign_orange.bam')
sign.setScale(1.5, 1, 1.5)
sign.setPos(0, 0, -.18)
sign.reparentTo(tunnelthree.find('**/sign_origin'))
mickey = loader.loadModel('phase_3.5/models/props/mickeySZ.bam')
mickey.setScale(5, 5, 5)
mickey.setY(-0.15)
mickey.reparentTo(tunnelthree.find('**/sign_origin'))

#Gag Shop
gshop = loader.loadModel('phase_4/models/modules/gagShop_TT.bam')
gshop.setPos(-86.6848, -90.5693, 0.500015)
gshop.setHpr(-15, 0, 0)
gshop.reparentTo(render)
door = loader.loadModel('phase_3.5/models/modules/doors_practical.bam').find('**/door_double_square_ur')
door.setColor(1, 0.63, 0.38, 1)
door.reparentTo(gshop.find('**/door_origin'))

#Lightposts
light1 = loader.loadModel('phase_3.5/models/props/streetlight_TT.bam').find('**/prop_post_one_light')
light1.setPos(3.84337, 118.504, 3)
light1.setHpr(-110, 0, 0)
light1.reparentTo(render)

#Trees
tree1 = loader.loadModel('phase_3.5/models/props/trees.bam').find('**/prop_tree_large_ur')
brick = tree1.find('**/prop_tree_large_brickbox_ur')
wood = tree1.find('**/prop_tree_large_woodbox_ur')
brick.removeNode()
wood.removeNode()
tree1.setPos(-128.16, -24.0245, 0.000663757)
tree1.setHpr(135, 0, 0)
tree1.reparentTo(render)

lib = loader.loadModel('phase_4/models/modules/library.bam')
lib.reparentTo(render)
lib.setPos(91.4475,-44.9255,4)
lib.setHpr(180,0,0)
doorlib = loader.loadModel('phase_3.5/models/modules/doors_practical.bam').find('**/door_double_round_ur')
doorlib.setColor(0.88, 0.45, 0.38, 1)
doorlib.reparentTo(lib.find('**/library_door_origin'))

Bank = loader.loadModel('phase_4/models/modules/bank.bam')
Bank.reparentTo(render)
Bank.setPos(57.1796,38.6656,4)
Bank.setHpr(0,0,0)
doorbank = loader.loadModel('phase_3.5/models/modules/doors_practical.bam').find('**/door_double_round_ur')
doorbank.setColor(0.88, 0.45, 0.38, 1)
doorbank.reparentTo(Bank.find('**/bank_door_origin'))
textbank = OnscreenText(text = 'Bank')
#textbank.setPos(0, 0, -1.58)
#textbank.setScale(2.9, 1, 3.4)
#textbank.setKern(0.092795)
textbank.reparentTo(Bank.find('**/sign_origin'))

thall = loader.loadModel('phase_4/models/modules/toonhall.bam')
thall.reparentTo(render)
thall.setPos(116.66,24.29,4)
thall.setHpr(-90,0,-0)
doorthall = loader.loadModel('phase_3.5/models/modules/doors_practical.bam').find('**/door_double_round_ur')
doorthall.setColor(0.88, 0.45, 0.38, 1)
doorthall.reparentTo(thall.find('**/toonhall_door_origin'))

cshop = loader.loadModel('phase_4/models/modules/clothshopTT.bam')
cshop.reparentTo(render)
cshop.setPos(106.265,160.831,3)
cshop.setHpr(-30,0,0)
doorcshop = loader.loadModel('phase_3.5/models/modules/doors_practical.bam').find('**/door_double_clothshop')
doorcshop.setColor(0.88, 0.45, 0.38, 1)
doorcshop.reparentTo(cshop.find('**/door_origin'))

base.useDrive()
run()

所以现在你知道了错误和我的代码,但是我该如何解决这个错误呢?我的 Python 文件夹中有 panda.pth,因此它启用了它,而不是 Panda3D 附带的 python 副本,并且我的 Python副本与 Panda3D 附带的注册副本的版本相同。那么,有人可以帮忙吗?

Python 2.7.3 版 Panda3D 1.8.1 版

4

1 回答 1

0

很简单;您的代码引用了相对位置的模型,例如phase_4/models/modules/gagShop_TT.bam,而这些文件不存在于它们各自的位置。将尝试加载的模型放置在正确的位置,或者更正相对路径以指向模型文件的正确位置。

如果这些模型存在于.mf多文件中(我假设它们是因为这些看起来来自迪士尼的卡通城),您必须使用虚拟文件系统安装多文件(请参阅 Panda3D 手册),或使用multify实用程序将它们解压缩到磁盘。

于 2014-07-11T12:59:37.097 回答