本文整理汇总了Python中pandac.PandaModules.TextureStage.get_default方法的典型用法代码示例。如果您正苦于以下问题:Python TextureStage.get_default方法的具体用法?Python TextureStage.get_default怎么用?Python TextureStage.get_default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandac.PandaModules.TextureStage
的用法示例。
在下文中一共展示了TextureStage.get_default方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: construct_scene
# 需要导入模块: from pandac.PandaModules import TextureStage [as 别名]
# 或者: from pandac.PandaModules.TextureStage import get_default [as 别名]
def construct_scene(lbase, modelpath, bgpath, scale, pos, hpr,
bgscale, bghp,
texture=None,
internal_canonical=False,
check_penetration=False,
light_spec=None,
use_envmap=False):
""" Constructs the scene per the parameters. """
# Default scene is lbase's rootnode
if bgpath is not None:
bgpath = mt.resolve_bg_path(bgpath)
rootnode = lbase.rootnode
# Modelpath points to the model .egg/.bam file
if isinstance(modelpath, str):
modelpaths = [modelpath]
scales = [scale]
poses = [pos]
hprs = [hpr]
textures = [texture]
else:
modelpaths = modelpath
scales = scale
poses = pos
hprs = hpr
textures = texture
texmodes = []
for _i, _t in enumerate(textures):
if isinstance(_t, tuple):
texfile, texmode = _t
texmodes.append(texmode)
textures[_i] = texfile
else:
texmodes.append(TexGenAttrib.MWorldNormal)
assert hasattr(modelpaths, '__iter__')
assert hasattr(scales, '__iter__')
assert hasattr(poses, '__iter__')
assert hasattr(hprs, '__iter__')
assert hasattr(textures, '__iter__')
assert len(modelpaths) == len(scales) == len(hprs) == len(poses) == len(textures), (len(modelpaths), len(scales), len(hprs), len(poses), len(textures))
modelpaths = map(mt.resolve_model_path, modelpaths)
modelpaths = map(cm.autogen_egg, modelpaths)
textures = map(mt.resolve_texture_path, textures)
objnodes = []
for mpth, scale, hpr, pos, t, tm in zip(modelpaths, scales, hprs, poses, textures, texmodes):
objnode = tools.read_file(lbase.loader.loadModel, mpth)
if t is not None:
#ts = TextureStage('ts')
ts = TextureStage.get_default()
ts.setMode(TextureStage.MReplace)
tex = tools.read_file(lbase.loader.loadTexture, t)
objnode.setTexGen(ts, tm)
objnode.setTexture(tex, 6)
robjnode = rootnode.attachNewNode('root_' + objnode.get_name())
objnode.reparentTo(robjnode)
if internal_canonical:
vertices = np.array(objnode.getTightBounds())
initial_scale_factor = max(abs(vertices[0]-vertices[1]))
cscale = 1.2/initial_scale_factor
ppos = vertices.mean(0) * cscale
objnode.setPos(-ppos[0], -ppos[1], -ppos[2])
objnode.setScale(cscale, cscale, cscale)
robjnode.setScale(scale[0], scale[0], scale[0])
robjnode.setPos(pos[0], -pos[2], pos[1])
robjnode.setHpr(hpr[2], hpr[1], hpr[0])
robjnode.setTwoSided(1)
objnodes.append(robjnode)
if check_penetration:
for (i, n1) in enumerate(objnodes):
for j, n2 in enumerate(objnodes[i+1:]):
p = is_penetrating(n1, n2)
if p:
for onode in objnodes:
onode.removeNode()
raise PenetrationError(i, j, n1, n2)
# Environment map
if bgpath and use_envmap:
envtex = tools.read_file(lbase.loader.loadTexture, bgpath)
# Map onto object
ts = TextureStage('env')
ts.setMode(TextureStage.MBlendColorScale)
if not isinstance(use_envmap, list):
use_envmap = [use_envmap] * len(objnodes)
for _objnode, ue in zip(objnodes, use_envmap):
if ue:
if isinstance(ue, str):
envtex0 = tools.read_file(lbase.loader.loadTexture, mt.resolve_texture_path(ue))
else:
envtex0 = envtex
_objnode.setTexGen(ts, TexGenAttrib.MEyeSphereMap)
_objnode.setTexture(ts, envtex0)
#.........这里部分代码省略.........