本文整理汇总了Python中panda3d.core.Fog.setColor方法的典型用法代码示例。如果您正苦于以下问题:Python Fog.setColor方法的具体用法?Python Fog.setColor怎么用?Python Fog.setColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.Fog
的用法示例。
在下文中一共展示了Fog.setColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadPrisonCrater
# 需要导入模块: from panda3d.core import Fog [as 别名]
# 或者: from panda3d.core.Fog import setColor [as 别名]
def loadPrisonCrater():
## Sky color
base.win.setClearColor(Vec4(.46,.824,.904,1))
## Load Ground
sand = loader.loadModel("data/models/sand.bam")
sand.reparentTo(render)
sand.setTexScale(TextureStage.getDefault(),5000,5000)
craterwalls = loader.loadModel("data/models/craterwalls.bam")
craterwalls.reparentTo(render)
craterwalls.setTexScale(TextureStage.getDefault(),500,50)
## World Effects
fog = Fog("Fog")
fog.setColor(255,215,143)
fog.setExpDensity(.0000001)
render.setFog(fog)
alight = render.attachNewNode(AmbientLight("Abient"))
alight.node().setColor(Vec4(.9,.9,.9,1))
render.setLight(alight)
sun = DirectionalLight('Sun')
sun.setColor(Vec4(1,1,1,1))
sunNP = render.attachNewNode(sun)
sunNP.setPos(0,0,4000)
sunNP.setHpr(0,-90,0)
render.setLight(sunNP)
示例2: BRHood
# 需要导入模块: from panda3d.core import Fog [as 别名]
# 或者: from panda3d.core.Fog import setColor [as 别名]
class BRHood(ToonHood):
notify = directNotify.newCategory("BRHood")
ID = ToontownGlobals.TheBrrrgh
TOWNLOADER_CLASS = BRTownLoader
SAFEZONELOADER_CLASS = BRSafeZoneLoader
STORAGE_DNA = "phase_8/dna/storage_BR.pdna"
SKY_FILE = "phase_3.5/models/props/BR_sky"
SPOOKY_SKY_FILE = "phase_3.5/models/props/BR_sky"
TITLE_COLOR = (0.3, 0.6, 1.0, 1.0)
HOLIDAY_DNA = {
ToontownGlobals.WINTER_DECORATIONS: ["phase_8/dna/winter_storage_BR.pdna"],
ToontownGlobals.WACKY_WINTER_DECORATIONS: ["phase_8/dna/winter_storage_BR.pdna"],
ToontownGlobals.HALLOWEEN_PROPS: ["phase_8/dna/halloween_props_storage_BR.pdna"],
ToontownGlobals.SPOOKY_PROPS: ["phase_8/dna/halloween_props_storage_BR.pdna"],
}
def load(self):
ToonHood.load(self)
self.fog = Fog("BRFog")
def setFog(self):
if base.wantFog:
self.fog.setColor(0.9, 0.9, 0.9)
self.fog.setExpDensity(0.004)
render.clearFog()
render.setFog(self.fog)
self.sky.clearFog()
self.sky.setFog(self.fog)
示例3: begin
# 需要导入模块: from panda3d.core import Fog [as 别名]
# 或者: from panda3d.core.Fog import setColor [as 别名]
def begin(self):
base.setBackgroundColor( self.environment['colourBackground'] )
alight = AmbientLight('AmbientLight')
alight.setColor(self.environment['colourAmbient'] )
alnp = self.sceneNode.attachNewNode(alight)
self.sceneNode.setLight(alnp)
if self.environment['fog']:
fog = Fog( 'sceneName' )
fog.setColor( self.environment['fog']['color'] )
if self.environment['fog']['mode'] == "linear":
fog.setLinearRange(self.environment['fog']['linearStart']*1000,self.environment['fog']['linearEnd']*1000)
else:
fog.setExpDensity( self.environment['fog']['expDensity'] )
self.sceneNode.setFog(fog)
[self.createNode(props) for props in self.nodes]
[self.createLight(props) for props in self.lights]
[self.createCamera(props) for props in self.cameras]
[self.createEntity(props) for props in self.entities]
# [self.createStaticGeoms(props) for props in self.staticGeoms]
self.sceneNode.clearModelNodes()
self.sceneNode.flattenStrong()
self.sceneNode.setShaderAuto()
示例4: init
# 需要导入模块: from panda3d.core import Fog [as 别名]
# 或者: from panda3d.core.Fog import setColor [as 别名]
def init(self):
"""setup calls that can be repeated on code reload"""
self.resetNodes()
self.base.setBackgroundColor(0, 0, 0)
self.base.render.setShaderAuto() # pp shading
self.base.render.setAttrib(
AntialiasAttrib.make(AntialiasAttrib.MMultisample))
if 1:
cam = self.base.render.find("camera")
# I don't know how to set cam position
f = Fog("fog")
f.setColor(0,0,0)
f.setLinearRange(18, 25)
self.base.render.setFog(f)
import videowall
reload(videowall)
self.videoWall = videowall.VideoWall(self.base.loader, self.base.render)
self.cubes = self.base.render.attachNewNode(ModelNode("cubes"))
self.cubes.setPos(-4.3, 18, -3)
ground = self.makeGround(self.cubes)
lights = self.base.render.attachNewNode("lights")
self.makeLights(lights)
self.centerMessageNode, self.cornerMessageNode = self.makeMessages()
self.setLighting(self.currentLighting)
self.base.render.ls()
示例5: __init__
# 需要导入模块: from panda3d.core import Fog [as 别名]
# 或者: from panda3d.core.Fog import setColor [as 别名]
class CogdoFlyingLevelFog:
def __init__(self, level, color = Globals.Level.FogColor):
self._level = level
self.color = color
fogDistance = self._level.quadLengthUnits * max(1, self._level.quadVisibiltyAhead * 0.2)
self.fog = Fog('RenderFog')
self.fog.setColor(self.color)
self.fog.setLinearRange(fogDistance * Globals.Level.RenderFogStartFactor, fogDistance)
self._visible = False
self._clearColor = Vec4(base.win.getClearColor())
self._clearColor.setW(1.0)
def destroy(self):
self.setVisible(False)
if hasattr(self, 'fog'):
del self.fog
def isVisible(self):
return self._visible
def setVisible(self, visible):
self._visible = visible
if self._visible:
base.win.setClearColor(self.color)
render.setFog(self.fog)
else:
base.win.setClearColor(self._clearColor)
render.clearFog()
示例6: toggle_smoke
# 需要导入模块: from panda3d.core import Fog [as 别名]
# 或者: from panda3d.core.Fog import setColor [as 别名]
def toggle_smoke(self):
from panda3d.core import Fog
if self.render.getFog():
self.render.clearFog()
else:
smoke = Fog("smoke")
smoke.setColor(config.smoke_color)
smoke.setExpDensity(config.smoke_exp_density)
render.setFog(smoke)
示例7: setFogOn
# 需要导入模块: from panda3d.core import Fog [as 别名]
# 或者: from panda3d.core.Fog import setColor [as 别名]
def setFogOn(self, fog):
self.fogOn = fog
if self.fogOn:
myFog = Fog('Fog Rendering Fog of Rendering')
myFog.setColor(1.0, 0.0, 0.0)
myFog.setExpDensity(0.5)
self.setFog(myFog)
else:
self.clearFog()
示例8: __init__
# 需要导入模块: from panda3d.core import Fog [as 别名]
# 或者: from panda3d.core.Fog import setColor [as 别名]
def __init__(self, *args, **kwargs):
template.Panda.__init__(self, *args, **kwargs)
print "Hurray!"
self.cube = self.loader.loadModel("models/low-cube")
self.cube.reparentTo(self.render)
self.cube2 = self.loader.loadModel("models/low-cube")
self.cube2.reparentTo(self.render)
self.cube2.setPos(self.cube, 10,20,30)
self.cube2.setHpr(175,3,45)
self.taskMgr.add(self.update, "update")
self.taskMgr.add(self.move, "move")
self._dir = 1
colour = (0.5,0.8,0.8)
linfog = Fog("A linear-mode Fog node")
linfog.setColor(*colour)
linfog.setLinearRange(0,320)
linfog.setLinearFallback(45,160,320)
render.attachNewNode(linfog)
render.setFog(linfog)
示例9: createEnvironment
# 需要导入模块: from panda3d.core import Fog [as 别名]
# 或者: from panda3d.core.Fog import setColor [as 别名]
def createEnvironment(self):
# Fog
expfog = Fog("scene-wide-fog")
expfog.setColor(0.5, 0.5, 0.5)
expfog.setExpDensity(0.002)
self.render.setFog(expfog)
# Sky
skysphere = self.loader.loadModel("assets/blue-sky-sphere")
skysphere.setEffect(CompassEffect.make(self.render))
skysphere.setScale(0.08)
skysphere.reparentTo(self.camera)
# Lights
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor(Vec4(0.6, 0.6, 0.6, 1))
self.render.setLight(self.render.attachNewNode(ambientLight))
directionalLight = DirectionalLight("directionalLight")
directionalLight.setColor(VBase4(0.8, 0.8, 0.5, 1))
dlnp = self.render.attachNewNode(directionalLight)
dlnp.setPos(0, 0, 260)
dlnp.lookAt(self.player)
self.render.setLight(dlnp)
# Water
self.water = self.loader.loadModel("assets/square.egg")
self.water.setSx(self.worldsize * 2)
self.water.setSy(self.worldsize * 2)
self.water.setPos(self.worldsize / 2, self.worldsize / 2, 25)
self.water.setTransparency(TransparencyAttrib.MAlpha)
newTS = TextureStage("1")
self.water.setTexture(newTS, self.loader.loadTexture("assets/water.png"))
self.water.setTexScale(newTS, 4)
self.water.reparentTo(self.render)
LerpTexOffsetInterval(self.water, 200, (1, 0), (0, 0), textureStage=newTS).loop()
示例10: BossbotHQ
# 需要导入模块: from panda3d.core import Fog [as 别名]
# 或者: from panda3d.core.Fog import setColor [as 别名]
class BossbotHQ(CogHood):
notify = directNotify.newCategory("BossbotHQ")
ID = ToontownGlobals.BossbotHQ
LOADER_CLASS = BossbotCogHQLoader
def load(self):
CogHood.load(self)
self.fog = Fog("BossbotHQFog")
self.sky.hide()
def enter(self, requestStatus):
CogHood.enter(self, requestStatus)
base.localAvatar.setCameraFov(ToontownGlobals.CogHQCameraFov)
base.camLens.setNearFar(ToontownGlobals.BossbotHQCameraNear, ToontownGlobals.BossbotHQCameraFar)
self.setFog()
def spawnTitleText(self, zoneId, floorNum=None):
if ZoneUtil.isMintInteriorZone(zoneId):
text = "%s\n%s" % (ToontownGlobals.StreetNames[zoneId][-1], TTLocalizer.MintFloorTitle % (floorNum + 1))
self.doSpawnTitleText(text)
else:
CogHood.spawnTitleText(self, zoneId)
def setFog(self):
if base.wantFog:
self.fog.setColor(0.1, 0.1, 0.1)
self.fog.setExpDensity(0.004)
render.clearFog()
render.setFog(self.fog)
self.sky.clearFog()
self.sky.setFog(self.fog)
示例11: FogDemo
# 需要导入模块: from panda3d.core import Fog [as 别名]
# 或者: from panda3d.core.Fog import setColor [as 别名]
class FogDemo(ShowBase):
# Macro-like function used to reduce the amount to code needed to create the
# on screen instructions
def genLabelText(self, i, text):
return OnscreenText(text=text, parent=base.a2dTopLeft, scale=.05,
pos=(0.06, -.065 * i), fg=(1, 1, 1, 1),
align=TextNode.ALeft)
def __init__(self):
# Initialize the ShowBase class from which we inherit, which will
# create a window and set up everything we need for rendering into it.
ShowBase.__init__(self)
# Standard initialization stuff
# Standard title that's on screen in every tutorial
self.title = OnscreenText(text="Panda3D: Tutorial - Fog", style=1,
fg=(1, 1, 1, 1), shadow=(0, 0, 0, .5), parent=base.a2dBottomRight,
align=TextNode.ARight, pos=(-0.1, 0.1), scale=.08)
# Code to generate the on screen instructions
self.escapeEventText = self.genLabelText(1, "ESC: Quit")
self.pkeyEventText = self.genLabelText(2, "[P]: Pause")
self.tkeyEventText = self.genLabelText(3, "[T]: Toggle Fog")
self.dkeyEventText = self.genLabelText(4, "[D]: Make fog color black")
self.sdkeyEventText = self.genLabelText(5, "[SHIFT+D]: Make background color black")
self.rkeyEventText = self.genLabelText(6, "[R]: Make fog color red")
self.srkeyEventText = self.genLabelText(7, "[SHIFT+R]: Make background color red")
self.bkeyEventText = self.genLabelText(8, "[B]: Make fog color blue")
self.sbkeyEventText = self.genLabelText(9, "[SHIFT+B]: Make background color blue")
self.gkeyEventText = self.genLabelText(10, "[G]: Make fog color green")
self.sgkeyEventText = self.genLabelText(11, "[SHIFT+G]: Make background color green")
self.lkeyEventText = self.genLabelText(12, "[L]: Make fog color light grey")
self.slkeyEventText = self.genLabelText(13, "[SHIFT+L]: Make background color light grey")
self.pluskeyEventText = self.genLabelText(14, "[+]: Increase fog density")
self.minuskeyEventText = self.genLabelText(15, "[-]: Decrease fog density")
# disable mouse control so that we can place the camera
base.disableMouse()
camera.setPosHpr(0, 0, 10, 0, -90, 0)
base.setBackgroundColor(0, 0, 0) # set the background color to black
# World specific-code
# Create an instance of fog called 'distanceFog'.
#'distanceFog' is just a name for our fog, not a specific type of fog.
self.fog = Fog('distanceFog')
# Set the initial color of our fog to black.
self.fog.setColor(0, 0, 0)
# Set the density/falloff of the fog. The range is 0-1.
# The higher the numer, the "bigger" the fog effect.
self.fog.setExpDensity(.08)
# We will set fog on render which means that everything in our scene will
# be affected by fog. Alternatively, you could only set fog on a specific
# object/node and only it and the nodes below it would be affected by
# the fog.
render.setFog(self.fog)
# Define the keyboard input
# Escape closes the demo
self.accept('escape', sys.exit)
# Handle pausing the tunnel
self.accept('p', self.handlePause)
# Handle turning the fog on and off
self.accept('t', toggleFog, [render, self.fog])
# Sets keys to set the fog to various colors
self.accept('r', self.fog.setColor, [1, 0, 0])
self.accept('g', self.fog.setColor, [0, 1, 0])
self.accept('b', self.fog.setColor, [0, 0, 1])
self.accept('l', self.fog.setColor, [.7, .7, .7])
self.accept('d', self.fog.setColor, [0, 0, 0])
# Sets keys to change the background colors
self.accept('shift-r', base.setBackgroundColor, [1, 0, 0])
self.accept('shift-g', base.setBackgroundColor, [0, 1, 0])
self.accept('shift-b', base.setBackgroundColor, [0, 0, 1])
self.accept('shift-l', base.setBackgroundColor, [.7, .7, .7])
self.accept('shift-d', base.setBackgroundColor, [0, 0, 0])
# Increases the fog density when "+" key is pressed
self.accept('+', self.addFogDensity, [.01])
# This is to handle the other "+" key (it's over = on the keyboard)
self.accept('=', self.addFogDensity, [.01])
self.accept('shift-=', self.addFogDensity, [.01])
# Decreases the fog density when the "-" key is pressed
self.accept('-', self.addFogDensity, [-.01])
# Load the tunel and start the tunnel
self.initTunnel()
self.contTunnel()
# This function will change the fog density by the amount passed into it
# This function is needed so that it can look up the current value and
# change it when the key is pressed. If you wanted to bind a key to set it
# at a given value you could call self.fog.setExpDensity directly
def addFogDensity(self, change):
# The min() statement makes sure the density is never over 1
# The max() statement makes sure the density is never below 0
self.fog.setExpDensity(
min(1, max(0, self.fog.getExpDensity() + change)))
# Code to initialize the tunnel
#.........这里部分代码省略.........
示例12: __init__
# 需要导入模块: from panda3d.core import Fog [as 别名]
# 或者: from panda3d.core.Fog import setColor [as 别名]
class CogdoBarrelRoom:
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedCogdoBarrelRoom')
def __init__(self):
self.timer = None
self.model = None
self._isLoaded = False
self.dummyElevInNode = None
self.cogdoBarrelsNode = None
self.entranceNode = None
self.nearBattleNode = None
self.rewardUi = None
self.rewardUiTaskName = 'CogdoBarrelRoom-RewardUI'
self.rewardCameraTaskName = 'CogdoBarrelRoom-RewardCamera'
self.fog = None
self.defaultFar = None
self.stomperSfx = None
return
def destroy(self):
self.unload()
def load(self):
if self._isLoaded:
return
self.timer = ToontownTimer.ToontownTimer()
self.timer.stash()
self.model = loader.loadModel(CogdoBarrelRoomConsts.BarrelRoomModel)
self.model.setPos(*CogdoBarrelRoomConsts.BarrelRoomModelPos)
self.model.reparentTo(render)
self.model.stash()
self.dummyElevInNode = self.model.attachNewNode('elevator-in')
self.dummyElevInNode.hide()
self.entranceNode = self.model.attachNewNode('door-entrance')
self.entranceNode.setPos(0, -65, 0)
self.nearBattleNode = self.model.attachNewNode('near-battle')
self.nearBattleNode.setPos(0, -25, 0)
self.rewardUi = CogdoBarrelRoomRewardPanel.CogdoBarrelRoomRewardPanel()
self.hideRewardUi()
self.stomperSfx = base.loadSfx(CogdoBarrelRoomConsts.StomperSound)
self.fog = Fog('barrel-room-fog')
self.fog.setColor(CogdoBarrelRoomConsts.BarrelRoomFogColor)
self.fog.setLinearRange(*CogdoBarrelRoomConsts.BarrelRoomFogLinearRange)
self._isLoaded = True
def unload(self):
if self.model:
self.model.removeNode()
self.model = None
if self.timer:
self.timer.destroy()
self.timer = None
if self.rewardUi:
self.rewardUi.destroy()
self.rewardUi = None
if self.fog:
render.setFogOff()
del self.fog
taskMgr.remove(self.rewardUiTaskName)
taskMgr.remove(self.rewardCameraTaskName)
self._isLoaded = False
return
def isLoaded(self):
return self._isLoaded
def show(self):
if not self.cogdoBarrelsNode:
self.cogdoBarrelsNode = render.find('**/@@CogdoBarrels')
self.cogdoBarrelsNode.reparentTo(self.model)
self.cogdoBarrelsNode.unstash()
self.defaultFar = base.camLens.getFar()
base.camLens.setFar(CogdoBarrelRoomConsts.BarrelRoomCameraFar)
self.showBattleAreaLight(True)
render.setFog(self.fog)
self.model.unstash()
def hide(self):
self.model.stash()
render.setFogOff()
if self.defaultFar is not None:
base.camLens.setFar(self.defaultFar)
return
def activate(self):
self.notify.info('Activating barrel room: %d sec timer.' % CogdoBarrelRoomConsts.CollectionTime)
self.timer.unstash()
self.timer.posAboveShtikerBook()
self.timer.countdown(CogdoBarrelRoomConsts.CollectionTime)
base.cr.playGame.getPlace().fsm.request('walk')
def deactivate(self):
self.notify.info('Deactivating barrel room.')
self.timer.stop()
self.timer.stash()
def placeToonsAtEntrance(self, toons):
for i in xrange(len(toons)):
toons[i].setPosHpr(self.entranceNode, *CogdoBarrelRoomConsts.BarrelRoomPlayerSpawnPoints[i])
#.........这里部分代码省略.........
示例13: DistributedRace
# 需要导入模块: from panda3d.core import Fog [as 别名]
# 或者: from panda3d.core.Fog import setColor [as 别名]
#.........这里部分代码省略.........
bldgGroup = self.townGeom.find('**/Buildings_' + side + '-' + barricade + '_' + str(i))
if bldgGroup.isEmpty():
continue
l = bldgGroup.findAllMatches('**/+ModelNode')
for n in l:
n2 = n.getParent().attachNewNode(n.getName())
n.getChildren().reparentTo(n2)
n.removeNode()
self.buildingGroups[side].append(bldgGroup)
treeNodes = self.townGeom.findAllMatches('**/prop_tree_*')
for tree in treeNodes:
tree.flattenStrong()
snowTreeNodes = self.townGeom.findAllMatches('**/prop_snow_tree_*')
for snowTree in snowTreeNodes:
snowTree.flattenStrong()
for side in ['inner', 'outer', 'innersidest', 'outersidest']:
for grp in self.buildingGroups[side]:
grp.stash()
self.showBuildings(0)
def unloadUrbanTrack(self):
del self.buildingGroups
self.townGeom.removeNode()
def loadFog(self):
self.hasFog = True
if self.isUrbanTrack:
base.camLens.setFar(650)
else:
base.camLens.setFar(650)
self.dummyNode = render.attachNewNode('dummyNode')
if base.wantFog:
self.fog = Fog('TrackFog')
self.fog.setColor(Vec4(0.6, 0.7, 0.8, 1.0))
if self.isUrbanTrack:
self.fog.setLinearRange(200.0, 650.0)
else:
self.fog.setLinearRange(200.0, 800.0)
render.setFog(self.fog)
self.sky.setScale(1.725)
self.sky.reparentTo(self.dummyNode)
def showBuildings(self, t, forceRecompute = False):
firstTimeCalled = 0
if self.curve:
t = t / self.curve.getMaxT()
else:
firstTimeCalled = 1
if self.reversed:
t = 1.0 - t
numGroupsShown = 5
for side in ['inner', 'outer']:
numBldgGroups = len(self.buildingGroups[side])
bldgInd = int(t * numBldgGroups)
bldgInd = bldgInd % numBldgGroups
if self.trackId in (RaceGlobals.RT_Urban_2, RaceGlobals.RT_Urban_2_rev):
oldBldgInd = int(self.oldT * numBldgGroups)
newBldgInd = int(t * numBldgGroups)
kartPoint = self.startPos
kart = base.cr.doId2do.get(self.kartMap.get(localAvatar.doId, None), None)
if kart:
kartPoint = self.localKart.getPos()
if not self.currBldgInd[side]:
self.currBldgInd[side] = 0
curInd = self.currBldgInd[side]
myCurGroup = self.buildingGroups[side][curInd]
示例14: __init__
# 需要导入模块: from panda3d.core import Fog [as 别名]
# 或者: from panda3d.core.Fog import setColor [as 别名]
def __init__(self):
ShowBase.__init__(self)
#Setup
scene = BulletWorld()
scene.setGravity(Vec3(0, 0, -9.81))
base.setBackgroundColor(0.6,0.9,0.9)
fog = Fog("The Fog")
fog.setColor(0.9,0.9,1.0)
fog.setExpDensity(0.003)
render.setFog(fog)
#Lighting
#Sun light
sun = DirectionalLight("The Sun")
sun_np = render.attachNewNode(sun)
sun_np.setHpr(0,-60,0)
render.setLight(sun_np)
#Ambient light
amb = AmbientLight("The Ambient Light")
amb.setColor(VBase4(0.39,0.39,0.39, 1))
amb_np = render.attachNewNode(amb)
render.setLight(amb_np)
#Variables
self.gear = 0
self.start = 0
self.Pbrake = 0
self.terrain_var = 1
self.time = 0
self.headlight_var = 0
self.RPM = 0
self.clutch = 0
self.carmaxspeed = 100 #KPH
self.carmaxreversespeed = -40 #KPH
self.steering = 0
#Functions
def V1():
camera.setPos(0.25,-1.2,0.5)
camera.setHpr(0,-13,0)
def V2():
camera.setPos(0,-15,3)
camera.setHpr(0,-10,0)
def V3():
camera.setPos(0,0,9)
camera.setHpr(0,-90,0)
def up():
self.gear = self.gear -1
if self.gear < -1:
self.gear = -1
def down():
self.gear = self.gear +1
if self.gear > 1:
self.gear = 1
def start_function():
self.start = 1
self.start_sound.play()
self.engine_idle_sound.play()
self.RPM = 1000
def stop_function():
self.start = 0
self.engine_idle_sound.stop()
def parkingbrake():
self.Pbrake = (self.Pbrake + 1) % 2
def rotate():
Car_np.setHpr(0, 0, 0)
def horn():
self.horn_sound.play()
def set_time():
if self.time == -1:
sun.setColor(VBase4(0.4, 0.3, 0.3, 1))
base.setBackgroundColor(0.8,0.7,0.7)
if self.time == 0:
sun.setColor(VBase4(0.7, 0.7, 0.7, 1))
base.setBackgroundColor(0.6,0.9,0.9)
if self.time == 1:
sun.setColor(VBase4(0.2, 0.2, 0.2, 1))
#.........这里部分代码省略.........
示例15: __init__
# 需要导入模块: from panda3d.core import Fog [as 别名]
# 或者: from panda3d.core.Fog import setColor [as 别名]
class Arena:
def __init__(self, arenaNr):
arenaPath = "levels/arena%d/" % arenaNr
self.arena = loader.loadModel(arenaPath + "arena")
self.arena.setScale(2)
self.arena.reparentTo(render)
self.arena.hide()
ambientLight = AmbientLight("ambient_light")
ambientLight.setColor((0.2, 0.2, 0.2, 1))
self.alnp = render.attachNewNode(ambientLight)
sunLens = PerspectiveLens()
sunLens.setFilmSize(50)
sun = DirectionalLight("sun")
sun.setColor((1, 1, 1, 1))
sun.setShadowCaster(True, 2048, 2048)
sun.setScene(render)
#sun.showFrustum()
self.ambientSound = None
self.levelParticles = None
if arenaNr == 1:
sunLens.setNearFar(25,45)
sun.setLens(sunLens)
self.sunNp = render.attachNewNode(sun)
self.sunNp.setPos(-10, -10, 30)
self.sunNp.lookAt(0,0,0)
self.ambientSound = loader.loadSfx("assets/audio/ambientLevel1.ogg")
self.ambientSound.setLoop(True)
self.fog = Fog("Outside Fog")
self.fog.setColor(0.3,0.3,0.5)
self.fog.setExpDensity(0.025)
self.levelParticles = ParticleEffect()
self.levelParticles.loadConfig("assets/fx/Leafs.ptf")
self.levelParticles.start(parent = render2d, renderParent = render2d)
elif arenaNr == 2:
sunLens.setFov(120, 40)
sunLens.setNearFar(2,10)
sun.setLens(sunLens)
self.sunNp = render.attachNewNode(sun)
self.sunNp.setPos(0, 0, 5)
self.sunNp.lookAt(0,0,0)
self.fog = Fog("Temple Fog")
self.fog.setColor(0,0,0)
self.fog.setExpDensity(0.065)
def start(self):
self.arena.show()
render.setLight(self.alnp)
render.setLight(self.sunNp)
if self.ambientSound != None:
self.ambientSound.play()
render.setFog(self.fog)
def stop(self):
self.arena.hide()
render.clearLight()
if self.ambientSound != None:
self.ambientSound.stop()
render.clearFog()
if self.levelParticles != None:
self.levelParticles.cleanup()
def getStartPos(self, charNr):
if charNr == 1:
return self.arena.find("**/StartPosA").getPos() * 2
elif charNr == 2:
return self.arena.find("**/StartPosB").getPos() * 2
else:
return (0,0,0)