Example #1
0
    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)
Example #2
0
    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)


        # Show loading screen
        self.loadingScreen = PipelineLoadingScreen(self)
        self.loadingScreen.render()
        self.loadingScreen.setStatus("Creating pipeline", 10)

        # Create the render pipeline
        self.debug("Creating pipeline")
        self.renderPipeline = RenderingPipeline(self)

        # Uncomment to use temp directory
        # writeDirectory = tempfile.mkdtemp(prefix='Shader-tmp')
        writeDirectory = "Temp/"

        # Set the pipeline base path
        self.renderPipeline.getMountManager().setBasePath(".")
        
        # Load pipeline settings
        self.renderPipeline.loadSettings("Config/pipeline.ini")

        self.loadingScreen.setStatus("Compiling shaders", 20)

        # Create the pipeline, and enable scattering
        self.renderPipeline.create()

        ####### END OF RENDER PIPELINE SETUP #######

        # Select demo scene here:

        # This sources are not included in the repo, for size reasons
        # self.sceneSource = "Demoscene.ignore/MasterSword/Scene.egg"
        # self.sceneSource = "Demoscene.ignore/MasterSword/Scene2.egg.bam"
        # self.sceneSource = "Demoscene.ignore/Couch2/Scene.egg"
        # self.sceneSource = "Demoscene.ignore/Couch/couch.egg.bam"
        # self.sceneSource = "Demoscene.ignore/LivingRoom/LivingRoom.egg"
        # self.sceneSource = "Demoscene.ignore/LivingRoom2/LivingRoom.egg"
        # self.sceneSource = "Demoscene.ignore/LostEmpire/Model.egg"
        # self.sceneSource = "Demoscene.ignore/SSLRTest/scene.egg"
        # self.sceneSource = "Demoscene.ignore/BMW/Bmw.egg"
        # self.sceneSource = "Demoscene.ignore/Tuscany/Tuscany.egg"
        # self.sceneSource = "Demoscene.ignore/EiffelTower/Scene.bam"
        # self.sceneSource = "Demoscene.ignore/HarvesterModel/Model.egg"
        # self.sceneSource = "Demoscene.ignore/OldHouse/Scene.egg"
        # self.sceneSource = "Demoscene.ignore/DemoTerrain/Scene.egg"
        # self.sceneSource = "Demoscene.ignore/TransparencyTest/Scene.egg"
        # self.sceneSource = "Demoscene.ignore/SanMiguel/Scene.bam"
        # self.sceneSource = "Demoscene.ignore/DabrovicSponza/Scene.egg"
        # self.sceneSource = "Demoscene.ignore/Avolition/level5.bam"
        # self.sceneSource = "Demoscene.ignore/Sphere/Scene.bam"
        # self.sceneSource = "Demoscene.ignore/Alphatest/alphatest.egg"
        # self.sceneSource = "Demoscene.ignore/TestScene/Test.bam"

        # This sources are included in the repo
        # self.sceneSource = "Models/CornelBox/Model.egg"
        # self.sceneSource = "Models/HouseSet/Model.egg"
        # self.sceneSource = "Models/PSSMTest/Model.egg.bam"
        # self.sceneSource = "Models/PBSTest/Scene.egg.bam"
        # self.sceneSource = "Models/HDRTest/Scene.egg"
        # self.sceneSource = "Models/GITestScene/Scene.egg"
        # self.sceneSource = "Models/VertexPerformanceTest/Scene.egg"
        # self.sceneSource = "Toolkit/Blender Material Library/MaterialLibrary.egg"
        self.sceneSource = "panda"

        # Select surrounding scene here
        self.sceneSourceSurround = None
        # self.sceneSourceSurround = "Demoscene.ignore/Couch/Surrounding.egg"
        # self.sceneSourceSurround = "Demoscene.ignore/LivingRoom/LivingRoom.egg"
        # self.sceneSourceSurround = "Models/LittleHouse/couch.bam"

        # Store a list of transparent objects
        self.transparentObjects = []

        # Create a sun light
        dPos = Vec3(60, 30, 100)

        if True:
            dirLight = DirectionalLight()
            dirLight.setPos(dPos * 100000.0)
            dirLight.setShadowMapResolution(2048)
            dirLight.setColor(Vec3(1.1, 1.05, 0.9) * 3.0)
            dirLight.setCastsShadows(True)
            dirLight.setPssmDistance(140)
            self.renderPipeline.addLight(dirLight)
            self.dirLight = dirLight

            # Tell the GI which light casts the GI
            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"] = 50

            self.lastSliderValue = 0.5

        self.movingLights = []

        self.demoLights = []

        # Create some lights
        for i in xrange(0):
            pointLight = PointLight()

            radius = float(i) / 3.0 * 6.28 + 1.52
            xoffs = i * 3.0
            yoffs = math.cos(radius) * 0.0
            pointLight.setPos(0, 0, 15)
            pointLight.setColor(Vec3(0.2,0.6,1.0)*6)
            pointLight.setShadowMapResolution(512)
            pointLight.setRadius(18)
            pointLight.setCastsShadows(True)
            self.renderPipeline.addLight(pointLight)
            # pointLight.attachDebugNode(render)
            # self.movingLights.append(pointLight)

        # Create more lights
        for i in xrange(0):
            pointLight = PointLight()
            radius = float(i) / 12.0 * 6.28 + 5.22
            xoffs = math.sin(radius) * 50.0
            yoffs = math.cos(radius) * 50.0
            pointLight.setPos(Vec3( xoffs, yoffs, 12))
            # pointLight.setColor(Vec3(0.2,0.6,1.0) * 0.05)
            pointLight.setColor(random(), random(), random())
            pointLight.setRadius(90)
            self.renderPipeline.addLight(pointLight)
            # pointLight.attachDebugNode(render)


        for x in xrange(0):
            spotLight = SpotLight()
            spotLight.setColor(Vec3(0.5, 0.8, 1.0) * 0.3)

            lightPos = Vec3(math.sin(x/10.0 * 6.28) * 16.0, math.cos(x/10.0 * 6.28) * 16.0, 29.0)

            spotLight.setPos(lightPos)
            spotLight.lookAt(lightPos - Vec3(0, 0, 1))
            spotLight.setFov(90)
            spotLight.setShadowMapResolution(1024)
            spotLight.setCastsShadows(True)
            spotLight.setNearFar(2.0, 60.0)
            spotLight.setIESProfile("AreaLight")
            self.renderPipeline.addLight(spotLight)
            # spotLight.attachDebugNode(render)
            # self.movingLights.append(spotLight)

        # Attach update task
        self.addTask(self.update, "update")

        # Update loading screen status
        self.loadingScreen.setStatus("Loading scene", 55)
       

        # Show loading screen a bit
        if True:
            self.doMethodLater(0.5, self.loadScene, "Load Scene")
        else:
            self.loadScene()
Example #3
0
    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("XArrow")
            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)
Example #4
0
 def addDemoLight(self):
     """ Spawns a new light at a random position with a random color """
     randomRadius = 40.0
     light = SpotLight()
     spot = Vec3( (random()-0.5) * randomRadius, (random()-0.5) * randomRadius, 22)
     # spot = self.cam.getPos(self.render)
     light.setPos(spot)
     light.lookAt(Vec3(spot.x,spot.y,0))
     # print "pos is", spot,"look at",Vec3(spot.x,spot.y,0)
     light.setColor(Vec3( random(), random(), random()) * 0.2)
     # light.setColor(Vec3( 1.0, 0.5, 0.3) * 0.05)
     light.setNearFar(1.0, 50)
     light.setFov(140)
     light.setIESProfile("SoftArrow")
     # light.setIESProfileIndex(randint(0, 30))
     light.setShadowMapResolution(2048)
     # light.attachDebugNode(render)
     light.setCastsShadows(True)
     self.renderPipeline.addLight(light)
     self.demoLights.append(light)
Example #5
0
    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)

        # Show loading screen
        self.loadingScreen = PipelineLoadingScreen(self)
        self.loadingScreen.render()
        self.loadingScreen.setStatus("Creating pipeline", 10)

        # Create the render pipeline
        self.debug("Creating pipeline")
        self.renderPipeline = RenderingPipeline(self)

        # Uncomment to use temp directory
        # writeDirectory = tempfile.mkdtemp(prefix='Shader-tmp')
        writeDirectory = "Temp/"

        # Set the pipeline base path
        self.renderPipeline.getMountManager().setBasePath(".")

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

        self.loadingScreen.setStatus("Compiling shaders", 20)

        # Create the pipeline, and enable scattering
        self.renderPipeline.create()

        ####### END OF RENDER PIPELINE SETUP #######

        # Select demo scene here:

        # This sources are not included in the repo, for size reasons
        # self.sceneSource = "Demoscene.ignore/MasterSword/Scene.egg"
        # self.sceneSource = "Demoscene.ignore/MasterSword/Scene2.egg.bam"
        # self.sceneSource = "Demoscene.ignore/Couch2/Scene.egg"
        # self.sceneSource = "Demoscene.ignore/Couch/couch.egg.bam"
        # self.sceneSource = "Demoscene.ignore/LittleHouse/Scene.bam"
        # self.sceneSource = "Demoscene.ignore/LivingRoom/LivingRoom.egg"
        # self.sceneSource = "Demoscene.ignore/LivingRoom2/LivingRoom.egg"
        # self.sceneSource = "Demoscene.ignore/LostEmpire/Model.egg"
        # self.sceneSource = "Demoscene.ignore/SSLRTest/scene.egg"
        # self.sceneSource = "Demoscene.ignore/BMW/Bmw.egg"
        # self.sceneSource = "Demoscene.ignore/Tuscany/Tuscany.egg"
        # self.sceneSource = "Demoscene.ignore/EiffelTower/Scene.bam"
        # self.sceneSource = "Demoscene.ignore/HarvesterModel/Model.egg"
        # self.sceneSource = "Demoscene.ignore/AudiR8/Scene.bam"
        # self.sceneSource = "Demoscene.ignore/OldHouse/Scene.egg"
        # self.sceneSource = "Demoscene.ignore/DemoTerrain/Scene.egg"
        # self.sceneSource = "Demoscene.ignore/TransparencyTest/Scene.egg"
        # self.sceneSource = "Demoscene.ignore/SanMiguel/Scene.bam"
        self.sceneSource = "Demoscene.ignore/DabrovicSponza/Scene.egg"
        # self.sceneSource = "Demoscene.ignore/Sponza/sponza.egg.bam"
        # self.sceneSource = "Demoscene.ignore/Avolition/level5.bam"
        # self.sceneSource = "Demoscene.ignore/Sphere/Scene.bam"
        # self.sceneSource = "Demoscene.ignore/Alphatest/Scene.bam"
        # self.sceneSource = "Demoscene.ignore/TestScene/Test.bam"
        # self.sceneSource = "Demoscene.ignore/BokehTest/Scene.egg"

        # This sources are included in the repo
        # self.sceneSource = "Models/CornelBox/Model.egg"
        # self.sceneSource = "Models/HouseSet/Model.egg"
        # self.sceneSource = "Models/PSSMTest/Model.egg.bam"
        # self.sceneSource = "Models/PBSTest/Scene.egg.bam"
        # self.sceneSource = "Models/HDRTest/Scene.egg"
        # self.sceneSource = "Models/GITestScene/Scene.egg"
        # self.sceneSource = "Toolkit/Blender Material Library/MaterialLibrary.bam"
        # self.sceneSource = "panda"

        # Select surrounding scene here
        self.sceneSourceSurround = None
        # self.sceneSourceSurround = "Demoscene.ignore/Couch/Surrounding.egg"
        # self.sceneSourceSurround = "Demoscene.ignore/LivingRoom/LivingRoom.egg"

        # Wheter to create the default ground plane
        self.usePlane = False

        # Store a list of transparent objects
        self.transparentObjects = []

        # Create a sun light
        dPos = Vec3(60, 30, 100)

        if True:
            dirLight = DirectionalLight()
            dirLight.setPos(dPos * 100000.0)
            dirLight.setShadowMapResolution(2048)
            dirLight.setColor(Vec3(1.0, 1.0, 1.0) * 5.0)
            dirLight.setCastsShadows(True)
            dirLight.setPssmDistance(140)
            self.renderPipeline.addLight(dirLight)
            self.dirLight = dirLight

            # Tell the GI which light casts the GI
            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"] = 89

            self.lastSliderValue = 0.5

        self.movingLights = []

        self.demoLights = []

        # Create some lights
        for i in xrange(5):
            continue
            pointLight = PointLight()

            radius = float(i) / 3.0 * 6.28 + 1.52
            xoffs = (i - 3) * 10.0
            yoffs = math.cos(radius) * 0.0
            pointLight.setPos(xoffs, 0, 8)
            # pointLight.setColor(Vec3(0.2,0.6,1.0)*6)
            pointLight.setColor(Vec3(random(), random(), random()) * 3)
            pointLight.setShadowMapResolution(512)
            pointLight.setRadius(18)
            pointLight.setCastsShadows(True)
            self.renderPipeline.addLight(pointLight)
            pointLight.attachDebugNode()
            # self.movingLights.append(pointLight)

        # Create more lights
        for i in xrange(0):
            pointLight = PointLight()
            radius = float(i) / 12.0 * 6.28 + 5.22
            xoffs = math.sin(radius) * 50.0
            yoffs = math.cos(radius) * 50.0
            pointLight.setPos(Vec3(xoffs, yoffs, 12))
            # pointLight.setColor(Vec3(0.2,0.6,1.0) * 0.05)
            pointLight.setColor(random(), random(), random())
            pointLight.setRadius(90)
            self.renderPipeline.addLight(pointLight)
            # pointLight.attachDebugNode(render)

        for x in xrange(0):
            spotLight = SpotLight()
            spotLight.setColor(Vec3(0.5, 0.8, 1.0) * 0.3)

            lightPos = Vec3(
                math.sin(x / 10.0 * 6.28) * 16.0,
                math.cos(x / 10.0 * 6.28) * 16.0, 29.0)

            spotLight.setPos(lightPos)
            spotLight.lookAt(lightPos - Vec3(0, 0, 1))
            spotLight.setFov(90)
            spotLight.setShadowMapResolution(1024)
            spotLight.setCastsShadows(True)
            spotLight.setNearFar(2.0, 60.0)
            spotLight.setIESProfile("AreaLight")
            self.renderPipeline.addLight(spotLight)
            # spotLight.attachDebugNode(render)
            # self.movingLights.append(spotLight)

        # Attach update task
        self.addTask(self.update, "update")

        # Update loading screen status
        self.loadingScreen.setStatus("Loading scene", 55)

        # Show loading screen a bit
        if False:
            self.doMethodLater(0.5, self.loadScene, "Load Scene")
        else:
            self.loadScene()