Esempio n. 1
0
    def load_scene(self):
        self.terrain = GeoMipTerrain("worldTerrain")  # create a terrain
        self.terrain.setHeightfield("goe-height-merged.jpg")  # set the height map
        self.terrain.setColorMap("moss-2.png")  # set the colour map
        # self.terrain.setBruteforce(True)  # level of detail
        self.terrain.setBlockSize(16)
        self.terrain.setAutoFlatten(GeoMipTerrain.AFMStrong)
        self.terrain.setNear(40)
        self.terrain.setFar(100)
        self.root = self.terrain.getRoot()  # capture root
        self.root.reparentTo(self.render)
        self.root.setSz(80)
        self.terrain.generate()

        self.sphere = self.loader.loadModel("skysphere-1.egg")
        self.tex = self.loader.loadTexture("TexturesCom_Skies0282_L.jpg")
        self.sphere.reparentTo(self.render)
        self.sphere.setTexture(self.tex, 1)
        self.sphere.setScale(1207)
        self.sphere.setSz(1207)
        self.sphere.setPos(858, 500, 0)

        self.scene = None
        self.camera.setPos(0, 0, 3)
        self.setupLight(VBase4(self._sun_red, self._sun_green, self._sun_blue, self._sun_alpha),
                        (self._light_yaw, self._light_pitch, self._light_roll))
        self.render.setShaderAuto()
        if self.gui:
            self.disable()

        self.taskMgr.add(self.updateTerrainTask)
Esempio n. 2
0
    def __init__(self):
        ShowBase.__init__(self)
        self.camera.setPos(0, 0, 3)
        self.fm = FlyMove(self)

        self.scene = self.loader.loadModel('models/environment')
        self.disable_mouse()

        self.scene.reparentTo(self.render)

        self.scene.setScale(0.25, 0.25, 0.25)
        self.scene.setPos(-8, 42, 0)

        pandaMat = Material()
        pandaMat.setEmission((1, 0.4, 0, 1))
        colour = (0.5, 0.8, 0.8)
        expfog = Fog("Scene-wide exponential Fog object")
        expfog.setColor(*colour)
        expfog.setExpDensity(0.005)
        self.render.setFog(expfog)

        self.pandaActor = Actor('models/panda-model',
                                {'walk': 'models/panda-walk4'})
        self.pandaActor.set_material(pandaMat)
        self.pandaActor.setScale(0.005, 0.005, 0.005)
        self.pandaActor.loop('walk')
        line = NodePath('pandaline')
        for i in range(50):
            placeholder = line.attachNewNode('line-panda')
            placeholder.setPos(i * 2, 0, 0)
            self.pandaActor.instanceTo(placeholder)
        line.reparentTo(self.render)

        pandaPosIntervalInterval1 = self.pandaActor.posInterval(
            13, Point3(0, -10, 0), startPos=Point3(0, 10, 0))

        pandaPosIntervalInterval2 = self.pandaActor.posInterval(
            13, Point3(0, 10, 0), startPos=Point3(0, -10, 0))
        pandaHprIntervalInterval1 = self.pandaActor.hprInterval(
            2, Point3(180, 0, 0), startHpr=Point3(0, 0, 0))
        pandaHprIntervalInterval2 = self.pandaActor.hprInterval(
            2, Point3(0, 0, 0), startHpr=Point3(180, 0, 0))
        self.pandaPace = Sequence(pandaPosIntervalInterval1,
                                  pandaHprIntervalInterval1,
                                  pandaPosIntervalInterval2,
                                  pandaHprIntervalInterval2)

        self.pandaPace.loop()

        light = DirectionalLight('pl')
        light.set_color_temperature(2000)
        np = self.render.attachNewNode(light)
        np.set_pos(0, 0, 5)
        light.set_shadow_caster(True, 512, 512)
        self.render.setLight(np)
        # np.place()
        alight = AmbientLight('alight')
        alight.setColor(VBase4(0.3, 0.1, 0.1, 1))
        alnp = self.render.attachNewNode(alight)
        self.render.setLight(alnp)
Esempio n. 3
0
 def load_scene(self):
     self.scene = self.loader.loadModel("environment")
     self.scene.reparentTo(self.render)
     self.scene.setScale(0.25, 0.25, 0.25)
     self.scene.setPos(-8, 42, 0)
     self.camera.setPos(0, 0, 0)
     self.setupLight(VBase4(self._sun_red, self._sun_green, self._sun_blue, self._sun_alpha),
                     (self._light_yaw, self._light_pitch, self._light_roll))
     self.render.setShaderAuto()
     self.disable()
Esempio n. 4
0
 def setupLight(self, red, green, blue, alpha):
     sunlight = DirectionalLight("sun")
     sunlight.setColor(VBase4(red, green, blue, alpha))
     self.sunlight = self.render.attachNewNode(sunlight)
     self.sunlight.setHpr(45, -60, 0)
     self.render.setLight(self.sunlight)
Esempio n. 5
0
 def sun_roll(self, sun_roll):
     self._light_roll = sun_roll
     self.updateLight(VBase4(self._sun_red, self._sun_green, self._sun_blue, self._sun_alpha),
                      (self._light_yaw, self._light_pitch, self._light_roll))