本文整理汇总了Python中vehicle.Vehicle.setLayout方法的典型用法代码示例。如果您正苦于以下问题:Python Vehicle.setLayout方法的具体用法?Python Vehicle.setLayout怎么用?Python Vehicle.setLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vehicle.Vehicle
的用法示例。
在下文中一共展示了Vehicle.setLayout方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: World
# 需要导入模块: from vehicle import Vehicle [as 别名]
# 或者: from vehicle.Vehicle import setLayout [as 别名]
class World(DirectObject):
instance = None
def __init__(self):
render.setAntialias(AntialiasAttrib.MAuto)
# Enable physics - perhaps this should go someplace else, but it must
# be done before the Vehicle is initialized.
base.enableParticles()
aei = AngularEulerIntegrator()
base.physicsMgr.attachAngularIntegrator(aei)
SelectionEngine.getDefault().enable()
SelectionManager.getDefault().enable()
# Make the environment and the vehicle model.
makeEnvironment()
self.vehicle = Vehicle(render)
MissionElement.loadElementConfig('mission_elements.plist')
#layoutName = AppPreferences.get('last_layout', 'defaultLayout.plist')
if len(sys.argv) == 2:
layoutName = sys.argv[1]
print "Using command line argument %s for layout" %layoutName
else:
print "Using default layout file"
print "Use ./sim2.py [layout file] to use a different layout"
print "Or press Ctrl+O to open a new layout in the simulator"
layoutName = 'defaultLayout.plist'
self.layout = MissionLayout.loadLayout(layoutName)
render.attachNewNode(self.layout)
self.vehicle.setLayout(self.layout) #Link the layout
# Set up render buffer viewer, to aide debugging.
self.accept("v", base.bufferViewer.toggleEnable)
self.accept("V", base.bufferViewer.toggleEnable)
base.bufferViewer.setPosition("llcorner")
# Set up file saver
self.accept('s', self._saveLayout)
self.accept('o', self._openLayout)
self.accept('f', self._setFreq)
root = Tk()
root.withdraw()
self.modButtons = ModifierButtons()
self.modButtons.addButton(KeyboardButton.control())
self.accept('control', self.modButtons.buttonDown,
[KeyboardButton.control()])
self.accept('control-up', self.modButtons.buttonUp,
[KeyboardButton.control()])
# Add GUI Controls
'''
buttonReady = makeGeom('button_ready.png')
b = DirectButton(geom = (buttonReady,
makeGeom('button_click.png'),
makeGeom('button_rollover.png'),
buttonReady),
relief = None)
b.reparentTo(pixel2d)
b.hide()
b.setPos(base.win.getXSize()/2, 0, -base.win.getYSize()/2)
b.setScale(1, 1, 1)
b.bind(DirectGuiGlobals.ACCEPT, eventHandler, ['accept'])
b.bind(DirectGuiGlobals.ACCEPTFAILED, eventHandler, ['accept failed'])
b.bind(DirectGuiGlobals.ADJUST, eventHandler, ['adjust'])
b.bind(DirectGuiGlobals.B1CLICK, eventHandler, ['b1click'])
b.bind(DirectGuiGlobals.B1PRESS, eventHandler, ['b1press'])
b.bind(DirectGuiGlobals.B1RELEASE, eventHandler, ['b1release'])
b.bind(DirectGuiGlobals.B2CLICK, eventHandler, ['b2click'])
b.bind(DirectGuiGlobals.B2PRESS, eventHandler, ['b2press'])
b.bind(DirectGuiGlobals.B2RELEASE, eventHandler, ['b2release'])
b.bind(DirectGuiGlobals.B3CLICK, eventHandler, ['b3click'])
b.bind(DirectGuiGlobals.B3PRESS, eventHandler, ['b3press'])
b.bind(DirectGuiGlobals.B3RELEASE, eventHandler, ['b3release'])
b.bind(DirectGuiGlobals.ENTER, eventHandler, ['enter'])
b.bind(DirectGuiGlobals.EXIT, eventHandler, ['exit'])
b.bind(DirectGuiGlobals.WITHIN, eventHandler, ['within'])
b.bind(DirectGuiGlobals.WITHOUT, eventHandler, ['without'])
b.bind(DirectGuiGlobals.CURSORMOVE, eventHandler, ['cursormove'])
# b['frameSize'] = (3, 3, 3, 3)
'''
@classmethod
def getInstance(cls):
if cls.instance == None:
cls.instance = World()
return cls.instance
def _saveLayout(self):
if self.modButtons.isDown(KeyboardButton.control()):
self.modButtons.buttonUp(KeyboardButton.control())
self.modButtons.buttonUp(KeyboardButton.asciiKey('s'))
filename = asksaveasfilename(filetypes=[('plist files', '*.plist')])
if filename:
self.layout.save(filename)
AppPreferences.set('last_layout', filename)
#.........这里部分代码省略.........