本文整理汇总了Python中panda3d.core.TextureStage.set_mode方法的典型用法代码示例。如果您正苦于以下问题:Python TextureStage.set_mode方法的具体用法?Python TextureStage.set_mode怎么用?Python TextureStage.set_mode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.TextureStage
的用法示例。
在下文中一共展示了TextureStage.set_mode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DriverPageGui
# 需要导入模块: from panda3d.core import TextureStage [as 别名]
# 或者: from panda3d.core.TextureStage import set_mode [as 别名]
class DriverPageGui(ThanksPageGui):
def __init__(self, mediator, driverpage_props, nplayers=1):
self.props = driverpage_props
self.sel_drv_img = None
self.driver = None
nplayers = list(range(nplayers))
ThanksPageGui.__init__(self, mediator, driverpage_props.gameprops.menu_props, nplayers)
def build(self, exit_behav):
self.drv_info = self.props.gameprops.drivers_info
menu_props = self.menu_props
widgets = [Text(_('Select the driver'), pos=(0, .8),
**menu_props.text_args)]
t_a = self.menu_props.text_args.copy()
del t_a['scale']
self.name = Text(_('Write your name:'), pos=(-.1, .6), scale=.06,
align='right', wordwrap=128, **t_a)
self.drivers = []
for row, col in product(range(2), range(4)):
idx = col + row * 4
drv_btn = ImgBtn(
scale=(.24, .24), pos=(-.75 + col * .5, .3 - row * .64),
frame_col=(0, 0, 0, 0),
img=self.props.gameprops.drivers_img.path % idx,
cmd=self.on_click, extra_args=[idx],
**self.menu_props.imgbtn_args)
name = Text(
'',
pos=(-.75 + col * .5, .01 - row * .64),
scale=.046, **t_a)
drv_btn._name_txt = name
widgets += [drv_btn, name]
self.drivers += [widgets[-2]]
sign = lambda pos_x: '\1green\1+\2' if pos_x > 0 else ''
psign = lambda pos_x, sgn=sign: '+' if pos_x == 0 else sgn(pos_x)
def ppcol(x):
return '\1green\1%s\2' % x if x > 0 else '\1red\1%s\2' % x
pcol = lambda x: x if x == 0 else ppcol(x)
lab_lst = [(_('adherence'), .09), (_('speed'), .21),
(_('stability'), .15)]
widgets += list(map(
lambda lab_def: self._add_lab(*(lab_def + (row, col))),
lab_lst))
txt_lst = [(self.drv_info[idx - 1].adherence, .09),
(self.drv_info[idx - 1].speed, .21),
(self.drv_info[idx - 1].stability, .15)]
widgets += list(map(
lambda txt_def: self._add_txt(
*txt_def + (psign, pcol, col, row)),
txt_lst))
self.sel_drv_img = Img(
self.props.gameprops.cars_img % self.mediator.car,
parent=base.a2dBottomLeft, pos=(.3, .4), scale=.28)
instr_txt = _(
'If you use the keyboard, press FIRE to edit the field, then '
"ENTER when you're done")
instr = Text(instr_txt, pos=(1.4, .6), scale=.042, wordwrap=16, **t_a)
widgets += [self.sel_drv_img, self.name, instr]
self.add_widgets(widgets)
ffilterpath = self.eng.curr_path + 'yyagl/assets/shaders/filter.vert'
with open(ffilterpath) as ffilter:
vert = ffilter.read()
shader = load_shader(vert, frag)
if shader:
self.sel_drv_img.set_shader(shader)
self.sel_drv_img.set_transparent()
self.t_s = TextureStage('ts')
self.t_s.set_mode(TextureStage.MDecal)
empty_img = PNMImage(1, 1)
empty_img.add_alpha()
empty_img.alpha_fill(0)
tex = Texture()
tex.load(empty_img)
self.sel_drv_img.set_texture(self.t_s, tex)
ThanksPageGui.build(self, exit_behav=exit_behav)
def _add_lab(self, txt, pos_z, row, col):
t_a = self.menu_props.text_args.copy()
del t_a['scale']
return Text(
txt + ':', pos=(-.95 + col * .5, pos_z - row * .64),
scale=.046, align='left', **t_a)
def _add_txt(self, val, pos_z, psign, pcol, col, row):
t_a = self.menu_props.text_args.copy()
del t_a['scale']
return Text(
'%s%s%%' % (psign(val), pcol(val)),
pos=(-.55 + col * .5, pos_z - row * .64), scale=.052,
align='right', **t_a)
def enable_buttons(self, enable):
[(drv.enable if enable else drv.disable)() for drv in self.drivers]
def on_click(self, i):
self.eng.log('selected driver ' + str(i))
gprops = self.props.gameprops
txt_path = gprops.drivers_img.path_sel
#.........这里部分代码省略.........