本文整理汇总了Python中Code.RenderingPipeline.RenderingPipeline.enableDefaultEarthScattering方法的典型用法代码示例。如果您正苦于以下问题:Python RenderingPipeline.enableDefaultEarthScattering方法的具体用法?Python RenderingPipeline.enableDefaultEarthScattering怎么用?Python RenderingPipeline.enableDefaultEarthScattering使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Code.RenderingPipeline.RenderingPipeline
的用法示例。
在下文中一共展示了RenderingPipeline.enableDefaultEarthScattering方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Main
# 需要导入模块: from Code.RenderingPipeline import RenderingPipeline [as 别名]
# 或者: from Code.RenderingPipeline.RenderingPipeline import enableDefaultEarthScattering [as 别名]
class Main(ShowBase, DebugObject):
""" This is the render pipeline testing showbase """
def __init__(self):
DebugObject.__init__(self, "Main")
self.debug("Bit System =", 8 * struct.calcsize("P"))
# Load engine configuration
self.debug("Loading panda3d configuration from configuration.prc ..")
loadPrcFile("Config/configuration.prc")
# Init the showbase
ShowBase.__init__(self)
# Create the render pipeline
self.debug("Creating pipeline")
self.renderPipeline = RenderingPipeline(self)
self.renderPipeline.loadSettings("Config/pipeline.ini")
# Uncomment to use temp directory
# writeDirectory = tempfile.mkdtemp(prefix='Shader-tmp')
# writeDirectory = "Temp/"
# Clear write directory when app exits
# atexit.register(os.remove, writeDirectory)
# Set a write directory, where the shader cache and so on is stored
# self.renderPipeline.getMountManager().setWritePath(writeDirectory)
self.renderPipeline.getMountManager().setBasePath(".")
####### END OF RENDER PIPELINE SETUP #######
# Load some demo source
# self.sceneSource = "Demoscene.ignore/sponza.egg.bam"
# self.sceneSource = "Demoscene.ignore/occlusionTest/Model.egg"
# self.sceneSource = "Demoscene.ignore/lost-empire/Model.egg"
# self.sceneSource = "Models/PSSMTest/Model.egg.bam"
# self.sceneSource = "Scene.ignore/Car.bam"
# self.sceneSource = "Demoscene.ignore/GITest/Model.egg"
# self.sceneSource = "Demoscene.ignore/PSSMTest/Model.egg.bam"
# self.sceneSource = "Models/Raventon/Model.egg"
# self.sceneSource = "Demoscene.ignore/Room/LivingRoom.egg.bam"
self.sceneSource = "Toolkit/Blender Material Library/MaterialLibrary.egg"
# If global illumination is enabled, load the voxel grid
GlobalIllumination.setSceneRoot(
"Toolkit/Blender Material Library/voxelized/")
# Create the pipeline, and enable scattering
self.renderPipeline.create()
self.renderPipeline.enableDefaultEarthScattering()
# Load scene from disk
self.debug("Loading Scene '" + self.sceneSource + "'")
self.scene = self.loader.loadModel(self.sceneSource)
# Wheter to use a ground floor
self.usePlane = False
self.sceneWireframe = False
# Flatten scene?
self.scene.flattenStrong()
# Load ground plane if configured
if self.usePlane:
self.groundPlane = self.loader.loadModel(
"Models/Plane/Model.egg.bam")
self.groundPlane.setPos(0, 0, -0.01)
self.groundPlane.setScale(2.0)
self.groundPlane.setTwoSided(True)
self.groundPlane.flattenStrong()
self.groundPlane.reparentTo(self.scene)
# Some artists really don't know about backface culling
# self.scene.setTwoSided(True)
# Required for tesselation
# self.convertToPatches(self.scene)
self.scene.reparentTo(self.render)
# Prepare textures with SRGB format
self.prepareSRGB(self.scene)
# Create movement controller (Freecam)
self.controller = MovementController(self)
self.controller.setInitialPosition(
Vec3(0.422895, -6.49557, 4.72692), Vec3(0, 0, 3))
self.controller.setup()
# Hotkey for wireframe
self.accept("f3", self.toggleSceneWireframe)
# Hotkey to reload all shaders
self.accept("r", self.setShaders)
# Create a sun light
dPos = Vec3(60, 30, 100)
#.........这里部分代码省略.........
示例2: World
# 需要导入模块: from Code.RenderingPipeline import RenderingPipeline [as 别名]
# 或者: from Code.RenderingPipeline.RenderingPipeline import enableDefaultEarthScattering [as 别名]
#.........这里部分代码省略.........
self.cTrav = CollisionTraverser()
self.ralphGroundRay = CollisionRay()
self.ralphGroundRay.setOrigin(0, 0, 1000)
self.ralphGroundRay.setDirection(0, 0, -1)
self.ralphGroundCol = CollisionNode('ralphRay')
self.ralphGroundCol.addSolid(self.ralphGroundRay)
self.ralphGroundCol.setFromCollideMask(BitMask32.bit(0))
self.ralphGroundCol.setIntoCollideMask(BitMask32.allOff())
self.ralphGroundColNp = self.ralph.attachNewNode(self.ralphGroundCol)
self.ralphGroundHandler = CollisionHandlerQueue()
self.cTrav.addCollider(self.ralphGroundColNp, self.ralphGroundHandler)
self.camGroundRay = CollisionRay()
self.camGroundRay.setOrigin(0, 0, 1000)
self.camGroundRay.setDirection(0, 0, -1)
self.camGroundCol = CollisionNode('camRay')
self.camGroundCol.addSolid(self.camGroundRay)
self.camGroundCol.setFromCollideMask(BitMask32.bit(0))
self.camGroundCol.setIntoCollideMask(BitMask32.allOff())
self.camGroundColNp = base.camera.attachNewNode(self.camGroundCol)
self.camGroundHandler = CollisionHandlerQueue()
self.cTrav.addCollider(self.camGroundColNp, self.camGroundHandler)
# Uncomment this line to see the collision rays
# self.ralphGroundColNp.show()
# self.camGroundColNp.show()
# Uncomment this line to show a visual representation of the
# collisions occuring
# self.cTrav.showCollisions(render)
# Add earth scattering
self.renderPipeline.enableDefaultEarthScattering()
self.prepareSRGB(render)
self.loadSkybox()
self.reloadShader()
def loadSkybox(self):
""" Loads the sample skybox. Will get replaced later """
self.skybox = self.loader.loadModel(
"../../Models/Skybox/Model.egg.bam")
self.skybox.setScale(40000)
self.skybox.reparentTo(self.render)
def reloadShader(self):
self.renderPipeline.reloadShaders()
render.setShader(self.renderPipeline.getDefaultObjectShader())
self.skybox.setShader(BetterShader.load(
"Shader/DefaultObjectShader/vertex.glsl", "Shader/Skybox/fragment.glsl"))
# Records the state of the arrow keys
def setKey(self, key, value):
self.keyMap[key] = value
def prepareSRGB(self, np):
""" Sets the correct texture format for all textures found in <np> """
for tex in np.findAllTextures():
baseFormat = tex.getFormat()
if baseFormat == Texture.FRgb:
tex.setFormat(Texture.FSrgb)
elif baseFormat == Texture.FRgba:
示例3: Main
# 需要导入模块: from Code.RenderingPipeline import RenderingPipeline [as 别名]
# 或者: from Code.RenderingPipeline.RenderingPipeline import enableDefaultEarthScattering [as 别名]
class Main(ShowBase, DebugObject):
""" This is the material explorer. You can try different materials"""
def __init__(self):
DebugObject.__init__(self, "Main")
self.debug("Bit System =", 8 * struct.calcsize("P"))
# Load engine configuration
self.debug("Loading panda3d configuration from configuration.prc ..")
loadPrcFile("../../Config/configuration.prc")
# Init the showbase
ShowBase.__init__(self)
# Create the render pipeline
self.debug("Creating pipeline")
self.renderPipeline = RenderingPipeline(self)
# Set a write directory, where the shader cache and so on is stored
# self.renderPipeline.getMountManager().setWritePath(writeDirectory)
self.renderPipeline.getMountManager().setBasePath("../../")
self.renderPipeline.loadSettings("../../Config/pipeline.ini")
# Create the pipeline, and enable scattering
self.renderPipeline.create()
self.renderPipeline.enableDefaultEarthScattering()
# Load some demo source
self.sceneSource = "Models/SmoothCube/Cube.bam"
# Load scene from disk
self.debug("Loading Scene '" + self.sceneSource + "'")
self.model = self.loader.loadModel(self.sceneSource)
self.scene = render.attachNewNode("Scene")
self.model.reparentTo(self.scene)
self.model.setZ(1.0)
# Wheter to use a ground floor
self.usePlane = True
self.sceneWireframe = False
# Flatten scene
self.scene.flattenStrong()
# Load ground plane if configured
if self.usePlane:
self.groundPlane = self.loader.loadModel(
"Models/Plane/Model.egg.bam")
self.groundPlane.setPos(0, 0, 0)
self.groundPlane.setScale(2.0)
self.groundPlane.setTwoSided(True)
self.groundPlane.flattenStrong()
self.groundPlane.reparentTo(self.scene)
# Prepare textures with SRGB format
self.prepareSRGB(self.scene)
# Create movement controller (Freecam)
self.controller = MovementController(self)
self.controller.setInitialPosition(
Vec3(0, -5, 5.0), Vec3(0, 0, 5))
self.controller.setup()
# Hotkey for wireframe
self.accept("f3", self.toggleSceneWireframe)
# Hotkey to reload all shaders
self.accept("r", self.setShaders)
# Create a sun light
dPos = Vec3(60, 30, 100)
dirLight = DirectionalLight()
dirLight.setDirection(dPos)
dirLight.setShadowMapResolution(2048)
dirLight.setAmbientColor(Vec3(0.0, 0.0, 0.0))
dirLight.setPos(dPos)
dirLight.setColor(Vec3(3))
dirLight.setPssmTarget(base.cam, base.camLens)
dirLight.setPssmDistance(50.0)
dirLight.setCastsShadows(True)
self.renderPipeline.addLight(dirLight)
self.dirLight = dirLight
sunPos = Vec3(56.7587, -31.3601, 189.196)
self.dirLight.setPos(sunPos)
self.dirLight.setDirection(sunPos)
# Tell the GI which light casts the GI
self.renderPipeline.setGILightSource(dirLight)
# Slider to move the sun
if self.renderPipeline.settings.displayOnscreenDebugger:
self.renderPipeline.guiManager.demoSlider.node[
"command"] = self.setSunPos
self.renderPipeline.guiManager.demoSlider.node[
"value"] = 20
#.........这里部分代码省略.........