本文整理汇总了Python中Code.RenderingPipeline.RenderingPipeline.getDefaultTransparencyShader方法的典型用法代码示例。如果您正苦于以下问题:Python RenderingPipeline.getDefaultTransparencyShader方法的具体用法?Python RenderingPipeline.getDefaultTransparencyShader怎么用?Python RenderingPipeline.getDefaultTransparencyShader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Code.RenderingPipeline.RenderingPipeline
的用法示例。
在下文中一共展示了RenderingPipeline.getDefaultTransparencyShader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Main
# 需要导入模块: from Code.RenderingPipeline import RenderingPipeline [as 别名]
# 或者: from Code.RenderingPipeline.RenderingPipeline import getDefaultTransparencyShader [as 别名]
#.........这里部分代码省略.........
# Hide loading screen
self.loadingScreen.hide()
# self.toggleSceneWireframe()
self.renderPipeline.onSceneInitialized()
def setSunPos(self):
""" Sets the sun position based on the debug slider """
radial = True
rawValue = self.renderPipeline.guiManager.demoSlider.node["value"]
diff = self.lastSliderValue - rawValue
self.lastSliderValue = rawValue
if radial:
rawValue = rawValue / 100.0 * 2.0 * math.pi
dPos = Vec3(
math.sin(rawValue) * 100.0, math.cos(rawValue) * 100.0, 50)
# dPos = Vec3(100, 100, (rawValue - 50) * 10.0)
else:
dPos = Vec3(30, (rawValue - 50) * 1.5, 30)
if abs(diff) > 0.0001:
self.dirLight.setPos(dPos)
self.dirLight.setDirection(dPos)
def toggleSceneWireframe(self):
""" Toggles the scene rendermode """
self.sceneWireframe = not self.sceneWireframe
if self.sceneWireframe:
render.setAttrib(RenderModeAttrib.make(RenderModeAttrib.MWireframe), 10)
else:
render.setAttrib(RenderModeAttrib.make(RenderModeAttrib.MFilled), 10)
self.skybox.setAttrib(RenderModeAttrib.make(RenderModeAttrib.MFilled), 20)
def prepareSRGB(self, np):
""" Sets the correct texture format for all textures found in <np> """
for tex in np.findAllTextures():
baseFormat = tex.getFormat()
# Only diffuse textures should be SRGB
if "diffuse" in tex.getName().lower():
if baseFormat == Texture.FRgb:
tex.setFormat(Texture.FSrgb)
elif baseFormat == Texture.FRgba:
tex.setFormat(Texture.FSrgbAlpha)
elif baseFormat == Texture.FSrgb or baseFormat == Texture.FSrgbAlpha:
# Format is okay already
pass
else:
print "Unkown texture format:", baseFormat
print "\tTexture:", tex
# All textures should have the correct filter modes
tex.setMinfilter(Texture.FTLinearMipmapLinear)
tex.setMagfilter(Texture.FTLinear)
tex.setAnisotropicDegree(16)
def loadLights(self, scene):
""" Loads lights from a .egg. Lights should be empty objects (blender) """
model = self.loader.loadModel(scene)
lights = model.findAllMatches("**/PointLight*")
for prefab in lights:
light = PointLight()
light.setRadius(prefab.getScale().x)
light.setColor(Vec3(2))
light.setPos(prefab.getPos())
light.setShadowMapResolution(2048)
light.setCastsShadows(False)
self.renderPipeline.addLight(light)
print "Adding Light:", prefab.getPos(), prefab.getScale()
self.lights.append(light)
self.initialLightPos.append(prefab.getPos())
self.test = light
def setShaders(self, refreshPipeline=True):
""" Sets all shaders """
self.debug("Reloading Shaders ..")
if self.renderPipeline:
for obj in self.transparentObjects:
obj.setShader(
self.renderPipeline.getDefaultTransparencyShader(), 30)
if refreshPipeline:
self.renderPipeline.reloadShaders()
def convertToPatches(self, model):
""" Converts a model to patches. This is required before being able
to use it with tesselation shaders """
self.debug("Converting model to patches ..")
for node in model.find_all_matches("**/+GeomNode"):
geom_node = node.node()
num_geoms = geom_node.get_num_geoms()
for i in range(num_geoms):
geom_node.modify_geom(i).make_patches_in_place()