本文整理汇总了Python中panda3d.core.DirectionalLight.setShadowCaster方法的典型用法代码示例。如果您正苦于以下问题:Python DirectionalLight.setShadowCaster方法的具体用法?Python DirectionalLight.setShadowCaster怎么用?Python DirectionalLight.setShadowCaster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.DirectionalLight
的用法示例。
在下文中一共展示了DirectionalLight.setShadowCaster方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setShadowCaster [as 别名]
def __init__(self):
self.hotelModel = loader.loadModel("menuBG/menuback")
self.hotelModel.reparentTo(render)
self.hotelModel.stash()
# setup some lights
plight = PointLight("mapgen_plight")
plight.setColor(VBase4(0.45, 0.35, 0.35, 1))
self.plnp = self.hotelModel.attachNewNode(plight)
self.plnp.setPos(-3, 3, 5)
base.render.setLight(self.plnp)
# setup a default ambient light
alight = AmbientLight("mapgen_alight")
alight.setColor(VBase4(0.20, 0.20, 0.28, 1))
self.alnp = self.hotelModel.attachNewNode(alight)
base.render.setLight(self.alnp)
sun = DirectionalLight('sun')
sun.setColor(VBase4(0.8, 0.8, 0.8, 1))
lens = PerspectiveLens()
lens.setFar(50)
lens.setFov(80, 80)
sun.setLens(lens)
ms = 1024 #graphicMgr.shadowMapSize
sun.setShadowCaster(True, ms, ms)
self.sunnp = self.hotelModel.attachNewNode(sun)
self.sunnp.setHpr(85, -50, 0)
self.sunnp.setPos(12, 0, 10)
base.render.setLight(self.sunnp)
示例2: __setDirectionalLight
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setShadowCaster [as 别名]
def __setDirectionalLight(self,props):
light = DirectionalLight(props['name'])
light.setShadowCaster(props['castShadows'],1024,1024)
lens = PerspectiveLens()
light.setLens(lens)
lens.setFov(1200/props['pos'].z)
return self.__createLight(light,props)
示例3: buildSubType
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setShadowCaster [as 别名]
def buildSubType(self):
"""Build the light with the given subType"""
if self.subType == "pointType":
# make a point light
c = self.color
pointLight = PointLight(self.name)
pointLight.setColor(VBase4(c[0], c[1], c[2], c[3]))
pointLight.setShadowCaster(True, 512, 512)
plnp = self.renderObjectsLight.attachNewNode(pointLight)
plnp.setPos(self.position)
self.lightNP = plnp
self.setLightSwitch(True)
if self.subType == "directType":
# make a directional light
c = self.color
directLight = DirectionalLight(self.name)
directLight.setColor(VBase4(c[0], c[1], c[2], c[3]))
directLight.setShadowCaster(True, 512, 512)
dlnp = self.renderObjectsLight.attachNewNode(directLight)
#dlnp.setHpr(0, -60, 0) # no idea why its like that.. but it works
self.lightNP = dlnp
self.setLightSwitch(True)
if self.subType == "ambientType":
# make a ambient light
c = self.color
ambientLight = AmbientLight(self.name)
ambientLight.setColor(VBase4(c[0], c[1],c[2], c[3]))
alnp = self.renderObjectsLight.attachNewNode(ambientLight)
self.lightNP = alnp
self.setLightSwitch(True)
if self.subType == "spotType":
# make a spot light
# lookAtObj = _object.getTag("lookAt") get rid of this.
c = self.color
spotLight = Spotlight(self.name)
spotLight.setColor(VBase4(c[0], c[1], c[2], c[3]))
spotLight.setShadowCaster(True, 512, 512)
lens = PerspectiveLens()
spotLight.setLens(lens)
slnp = self.renderObjectsLight.attachNewNode(spotLight)
slnp.setPos(self.position)
slnp.setHpr(self.hpr)
# Find out if this is really the only option
# because setHpr doesnt seem to have any effect.
# lookAt would be okay but that means adding anothe type
#slnp.lookAt(self.main.GameObjects["player"].collisionBody)
self.lightNP = slnp
self.setLightSwitch(True)
示例4: Game
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setShadowCaster [as 别名]
class Game(ShowBase):
def __init__(self):
ShowBase.__init__(self)
self.setBackgroundColor(0.2,0.2,0.2)
self.accept("escape", self.taskMgr.stop)
#self.accept("mouse1", self.onClick)
#self.accept("mouse2", self.onClick2)
self.globalClock = ClockObject()
self.addLight()
self.liner = LineDrawer(self)
self.taskMgr.add(self.update, "update")
def update(self, task):
self.globalClock.tick()
t = self.globalClock.getFrameTime()
#print t
dt = self.globalClock.getDt()
return task.cont
def addLight(self):
self.render.clearLight()
self.lightCenter = self.render.attachNewNode(PandaNode("center"))
#self.lightCenter.setCompass()
# ambient light
self.ambientLight = AmbientLight('ambientLight')
self.ambientLight.setColor(Vec4(0.5,0.5,0.5, 1))
self.alight = self.lightCenter.attachNewNode(self.ambientLight)
self.render.setLight(self.alight)
# point light
self.pointlight = PointLight("pLight")
self.light = self.lightCenter.attachNewNode(self.pointlight)
self.pointlight.setColor(Vec4(0.8,0.8,0.8,1))
self.light.setPos(0,0,2)
self.render.setLight(self.light)
# directional light
self.dirlight = DirectionalLight("dLight")
self.dlight = self.lightCenter.attachNewNode(self.dirlight)
self.dirlight.setColor(Vec4(0.8,0.8,0.8,1))
self.dirlight.setShadowCaster(True)
self.dlight.setPos(0,0,5)
self.dlight.lookAt(5,10,0)
self.render.setLight(self.dlight)
self.render.setShaderAuto()
示例5: __init__
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setShadowCaster [as 别名]
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)
示例6: __create_directional_light
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setShadowCaster [as 别名]
def __create_directional_light(self,
lightId,
lightColor,
lightHpr,
shadow = True):
directionalLight = DirectionalLight(lightId)
directionalLight.setColor(lightColor)
directionalLight.setShadowCaster(shadow)
directionalLightNP = NodePath(directionalLight)
directionalLightNP.setHpr(lightHpr)
return directionalLightNP
示例7: createLighting
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setShadowCaster [as 别名]
def createLighting(self):
light = DirectionalLight("light")
light.setColor(VBase4(0.4, 0.4, 0.4, 1))
light.setShadowCaster(True)
light.getLens().setNearFar(100.0, 400.0)
light.getLens().setFilmSize(400, 400)
# light.showFrustum()
np = self.render.attachNewNode(light)
np.setPos(100, -100, 200)
np.lookAt(0, 0, -100)
self.render.setLight(np)
light = AmbientLight("ambient")
light.setColor(VBase4(0.2, 0.2, 0.2, 1))
np = self.render.attachNewNode(light)
self.render.setLight(np)
示例8: createLights
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setShadowCaster [as 别名]
def createLights(self):
"""Create an ambient light and a spotlight for shadows"""
self.render.clearLight()
alight = AmbientLight("ambientLight")
alight.setColor(Vec4(0.7, 0.7, 0.7, 1))
alightNP = self.worldRender.attachNewNode(alight)
self.worldRender.setLight(alightNP)
# Create a directional light for shadows
dlight = DirectionalLight("dLight")
dlight.setColor(Vec4(0.6, 0.6, 0.6, 1))
dlight.setShadowCaster(True, 1024, 1024)
dlight.getLens().setNearFar(1, 15)
dlight.getLens().setFilmSize(128, 128)
dlightNP = self.worldRender.attachNewNode(dlight)
dlightNP.setPos(0, 0, 10)
dlightNP.lookAt(0, 0, 0)
self.worldRender.setLight(dlightNP)
示例9: MyApp
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setShadowCaster [as 别名]
#.........这里部分代码省略.........
#Add walker for panda
self.collision_sphere = CollisionSphere(0,0,1,1)
self.collNode = CollisionNode('pandaWalker')
self.cnodePath = self.pandaActor.attachNewNode(self.collNode)
self.cnodePath.node().addSolid(self.collision_sphere)
#AddZombieDetector for panda
self.zombie_sphere = CollisionSphere(0,0,3,1)
self.zomb_detector_node = CollisionNode('zombieDetector')
self.zomb_detector_NP = self.pandaActor.attachNewNode(self.zomb_detector_node)
self.zomb_detector_NP.node().addSolid(self.zombie_sphere)
#self.zomb_detector_NP.show()
#Add pusher against gravity
self.pusher = PhysicsCollisionHandler()
self.pusher.addCollider(self.cnodePath, self.pandaActorPhysicsP)
self.pusher.addCollider(self.zomb_detector_NP,self.pandaActorPhysicsP)
self.cTrav.addCollider(self.cnodePath,self.pusher)
self.cTrav.addCollider(self.zomb_detector_NP,self.pusher)
self.pusher.addInPattern('%fn-into-%in')
self.pusher.addAgainPattern('%fn-again-%in')
#Add collision handler patterns
self.collisionHandler.addInPattern('%fn-into-%in')
self.collisionHandler.addAgainPattern('%fn-again-%in')
self.abientLight = AmbientLight("ambientLight")
self.abientLight.setColor(Vec4(0.1, 0.1, 0.1, 1))
self.directionalLight = DirectionalLight("directionalLight")
self.directionalLight.setDirection(Vec3(-5, -5, -5))
self.directionalLight.setColor(Vec4((229.0/255), (204.0/255), (255.0/255), 0.7))
self.directionalLight.setSpecularColor(Vec4(0.4, 0.4, 0.4, 0.1))
self.directionalLight.setShadowCaster(True,512,512)
self.render.setLight(self.render.attachNewNode(self.abientLight))
self.render.setLight(self.render.attachNewNode(self.directionalLight))
self.render.setShaderAuto()
#create zombie land
self.zombieland = zombie.Zombies(self)
self.taskMgr.doMethodLater(0.01,self.zombieland.moveZombie, "zombieTask_ZombieMover")
layer2d.incBar(self.health)
self.taskMgr.add(self.game_monitor,"zombieTask_gameMonitor")
self.taskMgr.doMethodLater(2.7,self.music_play, "zombieTask_music")
#Add random useless things:
self.randomthings_.add_random_things()
def music_play(self,task):
self.music.play()
return Task.done
#def get_color(self):
# return self.color[min(len(self.color)-1,self.level)]
#GameMonitor
def game_monitor(self,task):
if self.paused:
return Task.cont
#Update Score
self.layer2d.update_score(self.panda_kill_count)
#Check for health of actor
if self.health <= 0:
self.dead_sound.play()
self.pandaActor.detachNode()
print "LOL u ded"
self.info = """Game Over..
Score: """ + str(self.panda_kill_count) + """
示例10: Dockit
# 需要导入模块: from panda3d.core import DirectionalLight [as 别名]
# 或者: from panda3d.core.DirectionalLight import setShadowCaster [as 别名]
class Dockit(DirectObject):
''' Main class of the Dockit! game '''
# VdW radius scale constant
radius_scale = 1.5
# Step to move ligand
move_step = 50
# Step to rotate ligand
rotate_step = 90
#Instructions
instructions = ['Dock it!','',
'X: a/d','Y: w/s','Z: q/e',
'Heading: r/f','Pitch: t/g','Roll: h/y',
'Cartoon: c','Control: x','Center: z',
'Help: v','Exit: escape']
def __init__(self, width, height, pdb_file1, pdb_file2, full_atom=True, debug=False):
''' Build Dockit! '''
self.multisamples = base.win.getFbProperties().getMultisamples()
self.cartoon = False
self.structures = False
self.help = False
self.text_on_screen = []
self.width = width
self.height = height
# Keyboard events
self.accept('c', self.toggle_cartoon)
self.accept('x', self.toggle_control_structures)
self.accept('z', self.center_camera)
self.accept('v', self.help_on_screen)
self.accept('escape', sys.exit)
self.keyMap = {"a":0, "d":0, "w":0, "s":0, "q":0, "e":0,
"r":0, "f":0, "g":0, "t":0, "h":0, "y":0}
# Load PDB structures
receptor = PDBReader.read_pdb_from_file(pdb_file1)
ligand = PDBReader.read_pdb_from_file(pdb_file2)
receptor.move_to_origin()
ligand.move_to_origin()
# Background
base.setBackgroundColor(0.7, 0.7, 0.7, 1.0)
# Load Color maps
color_map_cpk = CPK()
color_map_bfactor = BFactor(min_value=-14.0, max_value=8.0, middle_value=0.0)
# Load 3D model
self.receptor_node = render.attachNewNode("Receptor")
if full_atom:
self.load_protein_full_atom(receptor, self.receptor_node, color_map_bfactor)
else:
self.load_protein_residue(receptor, self.receptor_node)
self.receptor_node.reparentTo(render)
self.ligand_node = render.attachNewNode("Ligand")
if full_atom:
self.load_protein_full_atom(ligand, self.ligand_node, color_map_cpk)
else:
self.load_protein_residue(ligand, self.ligand_node)
self.ligand_node.reparentTo(render)
# Ambient lights
self.alight = AmbientLight('alight')
self.alight.setColor(LVecBase4f(0.162679, 0.162679, 0.169059, 1.0))
self.alnp = render.attachNewNode(self.alight)
render.setLight(self.alnp)
# Center receptor and ligand
self.center_proteins()
# Center camera on complexes
self.center = loader.loadModel("models/atom_sphere")
self.center.setColor(0.0, 0.53, 0.0, 1.0)
self.center_camera()
# DirectionalLight
self.dlight = DirectionalLight('dlight')
self.dlight.setColor(LVecBase4f(0.797448, 0.660287, 0.743222, 1.0))
self.dlight.setShadowCaster(True, 512, 512)
render.setShaderAuto()
self.dlnp = render.attachNewNode(self.dlight)
self.dlnp.setPos(0,-50,0)
render.setLight(self.dlnp)
self.dlnp.lookAt(self.center)
l1 = loader.loadModel("models/Dirlight")
l1.setColor(1.0, 1.0, 0.0, 1.0)
l1.setPos(0, -50, 0)
l1.setScale(1)
self.lights = [l1]
# Post processing
render.setAntialias(AntialiasAttrib.MAuto)
# Show control structures if required
if self.structures:
for light in self.lights:
light.reparentTo(render)
self.center.reparentTo(render)
#.........这里部分代码省略.........