I used to move the train by mopath .
It‘s my code:
#!/usr/bin/pythonfrom panda3d.bullet import BulletTriangleMesh
#coding:utf8
from pandac.PandaModules import loadPrcFileData
loadPrcFileData('', 'bullet-additional-damping 1')
loadPrcFileData('', 'egg-load-old-curves 1')
from direct.showbase.ShowBase import ShowBase
from direct.task import Task
from direct.directutil import Mopath
from direct.interval.MopathInterval import *
from panda3d.core import Vec3
from panda3d.core import TransformState
from panda3d.core import Point3
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
g = loader.loadModel('rail')
g.reparentTo(render)
#移动摄像机
self.disableMouse()
taskMgr.add(self.task, 'mainTask')
train = loader.loadModel('train')
train.reparentTo(render)
#########################################################
rail = Mopath.Mopath()
rail.loadFile('path')
railInterval = MopathInterval(rail, train, name='train', duration=100)
railInterval.loop()
#########################################################
camera.reparentTo(train)
camera.setPos(0,-120,40)
camera.setHpr(0,-15,0)
def task(self, task):
return task.again
app = MyApp()
app.run()
and this is full file:
ubuntuone.com/0ps4SWdJgXFxQFBGY1J9g7
It’s my blender file:
video:
tudou.com/programs/view/4ARZY-eLq5I/
But the train Neither turn nor travel along the rails.