当前位置: 首页>>代码示例>>Python>>正文


Python RenderingPipeline.getDefaultSkybox方法代码示例

本文整理汇总了Python中Code.RenderingPipeline.RenderingPipeline.getDefaultSkybox方法的典型用法代码示例。如果您正苦于以下问题:Python RenderingPipeline.getDefaultSkybox方法的具体用法?Python RenderingPipeline.getDefaultSkybox怎么用?Python RenderingPipeline.getDefaultSkybox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Code.RenderingPipeline.RenderingPipeline的用法示例。


在下文中一共展示了RenderingPipeline.getDefaultSkybox方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: App

# 需要导入模块: from Code.RenderingPipeline import RenderingPipeline [as 别名]
# 或者: from Code.RenderingPipeline.RenderingPipeline import getDefaultSkybox [as 别名]
class App(ShowBase):
    def __init__(self):

        # Load the default configuration.prc. This is recommended, as it
        # contains some important panda options
        loadPrcFile("../../Config/configuration.prc")

        # Init the showbase
        ShowBase.__init__(self)

        # Create a new pipeline instance
        self.renderPipeline = RenderingPipeline(self)

        # Set the base path for the pipeline. This is required as we are in
        # a subdirectory
        self.renderPipeline.getMountManager().setBasePath("../../")

        # Also set the write path
        self.renderPipeline.getMountManager().setWritePath("../../Temp/")

        # Load the default settings
        self.renderPipeline.loadSettings("../../Config/pipeline.ini")

        # Now create the pipeline
        self.renderPipeline.create()

        # Load the skybox
        self.skybox = self.renderPipeline.getDefaultSkybox()
        self.skybox.reparentTo(render)

        # At this point we are done with the initialization. Now you want to
        # load your scene, and create the game logic.

        # Call this to tell the pipeline that the scene is done loading
        self.renderPipeline.onSceneInitialized()
开发者ID:derkreature,项目名称:RenderPipeline,代码行数:37,代码来源:main.py

示例2: Main

# 需要导入模块: from Code.RenderingPipeline import RenderingPipeline [as 别名]
# 或者: from Code.RenderingPipeline.RenderingPipeline import getDefaultSkybox [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()

        # 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)


        # Create a sun light
        dPos = Vec3(60, 30, 100)
        dirLight = DirectionalLight()
        dirLight.setShadowMapResolution(1024)
        dirLight.setPos(dPos)
        dirLight.setColor(Vec3(1))
        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)

        # Tell the GI which light casts the GI
        self.renderPipeline.setGILightSource(dirLight)
        self.renderPipeline.setScatteringSource(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

            self.lastSliderValue = 0.0

        # Load skyboxn
        self.skybox = self.renderPipeline.getDefaultSkybox()
#.........这里部分代码省略.........
开发者ID:rimij405,项目名称:RenderPipeline,代码行数:103,代码来源:main.py

示例3: App

# 需要导入模块: from Code.RenderingPipeline import RenderingPipeline [as 别名]
# 或者: from Code.RenderingPipeline.RenderingPipeline import getDefaultSkybox [as 别名]
class App(ShowBase):

    def __init__(self):

        # Load the default configuration.prc. This is recommended, as it
        # contains some important panda options
        loadPrcFile("../../Config/configuration.prc")

        # Init the showbase
        ShowBase.__init__(self)

        # Create a new pipeline instance
        self.renderPipeline = RenderingPipeline(self)

        # Set the base path for the pipeline. This is required as we are in
        # a subdirectory
        self.renderPipeline.getMountManager().setBasePath("../../")

        # Also set the write path
        self.renderPipeline.getMountManager().setWritePath("../../Temp/")

        # Load the default settings
        self.renderPipeline.loadSettings("../../Config/pipeline.ini")

        # Disable scattering
        self.renderPipeline.settings.enableScattering = False

        # Now create the pipeline
        self.renderPipeline.create()

        # Load skybox
        self.skybox = self.renderPipeline.getDefaultSkybox()
        self.skybox.reparentTo(render)


        base.disableMouse()

        self.scene = loader.loadModel("models/level_a1.bam")
        self.scene.reparentTo(render)

        base.cam.setPos(0, 0, 15)
        base.cam.lookAt(0,5,5)

        self.actor = render.attachNewNode("actor")

        self.actorModel = Actor('models/male.egg', {
          'walk':'models/male2_walk.egg',
        })
        self.actorModel.setScale(0.03)
        self.actorModel.setH(-90)
        self.actorModel.reparentTo(self.actor)
        self.actorModel.loop("walk")
        self.actorModel.setBlend(frameBlend = True)

        self.renderPipeline.setEffect(self.actorModel, "Effects/Default/Default.effect", {
            "dynamic": True
            })

        self.accept("w", self.setMovementX, [1])
        self.accept("w-repeat", self.setMovementX, [1])
        self.accept("w-up", self.setMovementX, [0])

        self.accept("a", self.setMovementY, [1])
        self.accept("a-repeat", self.setMovementY, [1])
        self.accept("a-up", self.setMovementY, [0])
        self.accept("d", self.setMovementY, [-1])
        self.accept("d-repeat", self.setMovementY, [-1])
        self.accept("d-up", self.setMovementY, [0])


        lightPositions = [
            (Vec3(0, 0, 20), Vec3(1.0,0.5,0.3)),
            (Vec3(50, 5, 20), Vec3(1.0,0.5,0.3)),
            (Vec3(10, 70, 20), Vec3(1.0,0.5,0.3)),
        ]

        for pos, col in lightPositions:
            light = SpotLight()
            light.setPos(pos)
            light.lookAt(Vec3(0,0,0))
            light.setColor(col * 0.2)
            light.setNearFar(1.0, 50)
            light.setFov(140)
            light.setIESProfile("XSplit")
            light.setShadowMapResolution(1024)
            light.setCastsShadows(True)
            self.renderPipeline.addLight(light)

        self.movement = [0, 0]
        self.addTask(self.update, "update")

        # Call this to tell the pipeline that the scene is done loading
        self.renderPipeline.onSceneInitialized()

        self.accept("r", self.renderPipeline.reloadShaders)


    def setMovementX(self, directionX):
        self.movement[0] = directionX

#.........这里部分代码省略.........
开发者ID:wuyz145,项目名称:RenderPipeline,代码行数:103,代码来源:main.py

示例4: World

# 需要导入模块: from Code.RenderingPipeline import RenderingPipeline [as 别名]
# 或者: from Code.RenderingPipeline.RenderingPipeline import getDefaultSkybox [as 别名]

#.........这里部分代码省略.........
        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)


        # Create some ocean
        self.water = ProjectedWaterGrid(self.renderPipeline)
        self.water.setWaterLevel(-4.0)

        # Create the skybox
        self.skybox = self.renderPipeline.getDefaultSkybox()
        self.skybox.reparentTo(render)

        self.prepareSRGB(render)
        self.reloadShader()
        self.renderPipeline.onSceneInitialized()

        # Add demo slider to move the sun position
        if self.renderPipeline.settings.displayOnscreenDebugger:
            self.renderPipeline.guiManager.demoSlider.node[
                "command"] = self.setSunPos
            self.renderPipeline.guiManager.demoSlider.node[
                "value"] = 50

    def setSunPos(self):
        rawValue = self.renderPipeline.guiManager.demoSlider.node["value"]
        dPos = Vec3(100, 100, rawValue - 20)
        self.dirLight.setPos(dPos * 100000000.0)

        
    def reloadShader(self):
        self.renderPipeline.reloadShaders()

    # 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()
开发者ID:quiettus,项目名称:RenderPipeline,代码行数:69,代码来源:Tut-Roaming-Ralph.py

示例5: Main

# 需要导入模块: from Code.RenderingPipeline import RenderingPipeline [as 别名]
# 或者: from Code.RenderingPipeline.RenderingPipeline import getDefaultSkybox [as 别名]

#.........这里部分代码省略.........



        # Required for tesselation
        # self.convertToPatches(self.scene)

        # Hotkey for wireframe
        self.accept("f3", self.toggleSceneWireframe)

        # Hotkey to reload all shaders
        self.accept("r", self.setShaders)

        # For rdb
        self.accept("f12", self.screenshot)

        # Hotkeys to spawn / remove lights
        self.accept("u", self.addDemoLight)
        self.accept("i", self.removeDemoLight)

        # Create movement controller (Freecam)
        self.controller = MovementController(self)

        camPos = Vec3(-4.92549, -7.57746, 7.20246)
        camHpr = Vec3(-42.3281, -1.38704, 0)

        self.controller.setInitialPositionHpr(
            camPos, camHpr)
        self.controller.setup()

        # self.fpCamera = FirstPersonCamera(self, self.cam, self.render)
        # self.fpCamera.start()

        # Load skybox
        self.skybox = self.renderPipeline.getDefaultSkybox()
        self.skybox.reparentTo(render)

        # Set default object shaders
        self.setShaders(refreshPipeline=False)

        # 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) * 30.0, math.cos(rawValue) * 30.0, 20.0)
            # dPos = Vec3(100, 100, self.lastSliderValue*2 10)
        else:
            dPos = Vec3(30, (rawValue - 50) * 1.5, 0)

        # dPos = Vec3(-2, 0, 40)

        if abs(diff) > 0.0001:
            if hasattr(self, "dirLight"):
                self.dirLight.setPos(dPos * 100000000.0)
开发者ID:Solecist,项目名称:RenderPipeline,代码行数:70,代码来源:main.py

示例6: World

# 需要导入模块: from Code.RenderingPipeline import RenderingPipeline [as 别名]
# 或者: from Code.RenderingPipeline.RenderingPipeline import getDefaultSkybox [as 别名]

#.........这里部分代码省略.........
    #Create an list (self.pandas) with filled with 4 dummy nodes attached to
    #the carousel.
    #This uses a python concept called "Array Comprehensions." Check the Python
    #manual for more information on how they work
    self.pandas = [self.carousel.attachNewNode("panda"+str(i))
                   for i in range(4)]
    self.models = [loader.loadModel("models/carousel_panda")
                   for i in range(4)]
    self.moves = [0 for i in range(4)]

    for i in range(4):
      #set the position and orientation of the ith panda node we just created
      #The Z value of the position will be the base height of the pandas.
      #The headings are multiplied by i to put each panda in its own position
      #around the carousel
      self.pandas[i].setPosHpr(0, 0, 1.3, i*90, 0, 0)

      #Load the actual panda model, and parent it to its dummy node
      self.models[i].reparentTo(self.pandas[i])
      #Set the distance from the center. This distance is based on the way the
      #carousel was modeled in Maya
      self.models[i].setY(.85)       

    #Load the environment (Sky sphere and ground plane)
    self.env = loader.loadModel("models/env")

    # print self.env.ls()
    self.env.find("**/polySurface1").node().removeGeom(0)
    self.env.reparentTo(render)
    self.env.setScale(7)


    # Load skybox
    self.skybox = self.renderPipeline.getDefaultSkybox()
    self.skybox.reparentTo(render)


    self.reloadShader()

  def reloadShader(self):
      self.renderPipeline.reloadShaders()

  #Panda Lighting
  def setupLights(self):
    # Add a directional light
    dPos = Vec3(40, 40, 40)
    dirLight = DirectionalLight()
    dirLight.setShadowMapResolution(2048)
    dirLight.setPssmTarget(self.cam, self.camLens)
    dirLight.setCastsShadows(True)
    dirLight.setPos(dPos * 10000.0)
    dirLight.setColor(6, 6, 6)
    self.renderPipeline.addLight(dirLight)

    self.sun = dirLight
    
  def startCarousel(self):
    #Here's where we actually create the intervals to move the carousel
    #The first type of interval we use is one created directly from a NodePath
    #This interval tells the NodePath to vary its orientation (hpr) from its
    #current value (0,0,0) to (360,0,0) over 20 seconds. Intervals created from
    #NodePaths also exist for position, scale, color, and shear
  
    self.carouselSpin = self.carousel.hprInterval(20, Vec3(360, 0, 0))
    #Once an interval is created, we need to tell it to actually move.
    #start() will cause an interval to play once. loop() will tell an interval
开发者ID:cesarmarinhorj,项目名称:RenderPipeline,代码行数:70,代码来源:Tut-Carousel.py


注:本文中的Code.RenderingPipeline.RenderingPipeline.getDefaultSkybox方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。