本文整理匯總了Python中pandac.PandaModules.AmbientLight類的典型用法代碼示例。如果您正苦於以下問題:Python AmbientLight類的具體用法?Python AmbientLight怎麽用?Python AmbientLight使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了AmbientLight類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
def __init__(self, *args, **kwargs):
ViewTowers.__init__(self, *args, **kwargs)
# ignore keys set by viewer
for key in self.getAllAccepting():
if key in ("s", "escape"):
continue
self.ignore(key)
self.permanent_events = self.getAllAccepting()
# global variables
self.text_bg = (1, 1, 1, 0.7)
self.font = self.loader.loadFont("cmr12.egg")
self.question = "Use the mouse to indicate the direction that " "the tower will fall."
self.feedback_time = 3.0
self.buffer_time = 0.75
# create text
self.create_all_text()
# create direction line
self.line = LineSegs()
self.line_node = None
self.angle = None
alight = AmbientLight("alight3")
alight.setColor((0.8, 0.8, 0.8, 1))
self.line_light = self.lights.attachNewNode(alight)
示例2: __init__
class Lighting:
def __init__(self, ancestor = None):
print "____________________________________________________"
print "Class Lights"
self.ancestor = ancestor
#Initialize bg colour
colour = (0.2, 0.2, 0.6)
base.setBackgroundColor(*colour)
base.camLens.setFar(1000.0)
self.alight = AmbientLight('ambient_light')
self.alight.setColor(Vec4(0.7, 0.7, 0.7, 1))
self.alnp = base.render.attachNewNode(self.alight)
base.render.setLight(self.alnp)
self.plight = PointLight('sunlight')
self.plight.setColor(Vec4(2.5, 2.5, 2.5, 1))
self.plnp = base.render.attachNewNode(self.plight)
self.plnp.setPos(50, 0, 300)
self.plnp.lookAt(self.ancestor.terrain.root)
base.render.setLight(self.plnp)
# Initialize linear fog
self.fog = Fog("Fog object")
self.fog.setMode(Fog.MLinear)
self.fog.setLinearRange(14.0,40.0)
self.fog.setColor(*colour)
示例3: __init__
def __init__(self):
ShowBase.__init__(self)
wp = WindowProperties()
wp.setSize(850, 480)
wp.setTitle("GAME")
base.win.requestProperties(wp)
bgg = BlockGeometryGenerator()
blocks = []
for x in xrange(1):
for y in xrange(512):
for z in xrange(64):
bid = random.randint(0, 255)
blocks.append(bid)
bgg.GenerateBlockGeometry(x, y, z, Block(bid), [0])
#blocks[x * 512 * 64 + y * 64 + z] = 1
print x
ambientLight = AmbientLight('ambientLight')
ambientLight.setColor(Vec4(0.2, 0.2, 0.2, 1))
ambientLightNP = render.attachNewNode(ambientLight)
render.setLight(ambientLightNP)
示例4: create
def create( self ):
lightAttrib = LightAttrib.makeAllOff()
#create ambient light
ambientLight = AmbientLight( "ambientLight" )
ambientLight.setColor( self.ambientColor )
lightAttrib = lightAttrib.addLight( ambientLight )
render.attachNewNode( ambientLight.upcastToPandaNode() )
self.ambientLight = ambientLight
#default light settings
"""colors = [ Vec4(1,0,0,0), Vec4(0,1,0,0), Vec4(0,0,1,0), Vec4(1,1,0,0) ]
directions = [ Vec3(1,0,0), Vec3(0,1,0), Vec3(-1,0,0), Vec3(0,-1,0) ]
intensities = [ 3.0, 0.1, 3.0, 0.1 ]"""
colors = [ Vec4(1,1,1,0), Vec4(0,1,0,0), Vec4(0,0,1,0), Vec4(1,1,0,0) ]
# basic 3+1 point lighting
directions = [ Vec3(0,1,-0.2), Vec3(0,1,0), Vec3(-1,0.3,0), Vec3(0,-1,0) ]
intensities = [ 1.0, 0.0, 0.5, 0.0 ]
#add directional lights
self.directionalLights = []
for i in range(4):
self.directionalLights.append( ShaderDirectionalLight( colors[i], directions[i], intensities[i], i ) )
lightAttrib = self.directionalLights[i].create( lightAttrib )
#set light attributes
render.node().setAttrib( lightAttrib )
示例5: __init__
def __init__(self):
# Display nodes creation
self.patches_node = render.attachNewNode("patches_node")
self.agents_node = render.attachNewNode("agents_node")
self.lines_node = render.attachNewNode("lines_node")
self.light_node = render.attachNewNode("light_node")
self.floor_node = render.attachNewNode("floor_node")
self.frame_node = render.attachNewNode("frame_node")
self.env_node = render.attachNewNode("env_node")
# Light settings
self.light = True
self.dlight = PointLight("dlight")
self.dlight.setColor(Vec4(.8,.8,.5,1))
self.dlnp = render.attachNewNode(self.dlight)
self.dlnp.setPos(0,100,100)
render.setLight(self.dlnp)
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor(Vec4(.4, .4, .4, 1))
render.setLight(render.attachNewNode(ambientLight))
#self.create_floor(121, 121, "grass_floor")
self.create_frame(121, 121, 0)
self.add_model(self.env_node, "env", (60,60,-0.5), 200)
self.fill_env()
taskMgr.add(self.game_loop, "game_loop")
taskMgr.add(self.close_window, "close_window")
示例6: setLight
def setLight(self):
pLight = PointLight('pLight')
plnp = base.render.attachNewNode(pLight)
plnp.setPos(37, 10, 15)
alight = AmbientLight('alight')
alight.setColor(VBase4(0.2, 0.25, 0.25, 1))
alnp = base.render.attachNewNode(alight)
base.render.setLight(plnp)
base.render.setLight(alnp)
示例7: loadStars
def loadStars(self):
ambientlight = AmbientLight('alight')
ambientlight.setColor( Vec4(1, 1, 1, 0) )
lightnode = render.attachNewNode(ambientlight)
self.stars = loader.loadModel("stars.bam")
self.stars.setLight(lightnode)
self.stars.setScale(1000)
self.stars.setPos(0,0,0)
self.stars.reparentTo(render)
self.starsRotation = self.stars.getQuat()
示例8: set_lighting
def set_lighting(self):
dlight = DirectionalLight('dlight')
dlnp = self.render.attachNewNode(dlight)
dlnp.setHpr(45,-45,0)
self.render.setLight(dlnp)
ambientLight = AmbientLight('ambientLight')
ambientLight.setColor(VBase4(0.5, 0.5, 0.5, 1))
ambientLightNP = render.attachNewNode(ambientLight)
self.render.setLight(ambientLightNP)
示例9: setupLight
def setupLight( self ):
#Default lightAttrib with no lights
#self.lightAttrib = LightAttrib.makeAllOff()
# First we create an ambient light. All objects are affected by ambient
# light equally
#Create and name the ambient light
self.ambientLight = AmbientLight( "ambientLight" )
#Set the color of the ambient light
self.ambientLight.setColor( Vec4( .1, .1, .1, 1 ) )
self.alnp = render.attachNewNode(self.ambientLight)
render.setLight(self.alnp)
self.heightfield.mHeightFieldNode.setLightOff()
self.ambientLight2 = AmbientLight( "ambientLight2" )
#Set the color of the ambient light
self.ambientLight2.setColor( Vec4( .1, .1, .1, 1 ) )
self.al2np = render.attachNewNode(self.ambientLight2)
self.heightfield.mHeightFieldNode.setLight(self.al2np)
self.dlight = DirectionalLight('dlight')
self.dlight.setColor(VBase4(1.0, 1.0, 0.6, 1))
self.dlnp = render.attachNewNode(self.dlight.upcastToPandaNode())
self.dlnp.setHpr(-90, -30, 0)
self.heightfield.mHeightFieldNode.setLight(self.dlnp)
# Now we create a spotlight. Spotlights light objects in a given cone
# They are good for simulating things like flashlights
self.spotlight = Spotlight( "spotlight" )
self.spotlight.setColor( Vec4( .9, .9, .9, 1 ) )
#The cone of a spotlight is controlled by it's lens. This creates the lens
self.spotlight.setLens( PerspectiveLens() )
#This sets the Field of View (fov) of the lens, in degrees for width and
#height. The lower the numbers, the tighter the spotlight.
self.spotlight.getLens().setFov( 30, 30 )
# Attenuation controls how the light fades with distance. The numbers are
# The three values represent the three constants (constant, linear, and
# quadratic) in the internal lighting equation. The higher the numbers the
# shorter the light goes.
self.spotlight.setAttenuation( Vec3( 0.0, 0.0075, 0.0 ) )
# This exponent value sets how soft the edge of the spotlight is. 0 means a
# hard edge. 128 means a very soft edge.
self.spotlight.setExponent( 60.0 )
# Unlike our previous lights, the spotlight needs a position in the world
# We are attaching it to the camera so that it will appear is if we are
# holding a flashlight, but it can be attached to any NodePath
#
# When attaching a spotlight to a NodePath, you must use the
# upcastToLensNode function or Panda will crash
#camera.attachNewNode( self.spotlight.upcastToLensNode() )
self.spnp = camera.attachNewNode( self.spotlight.upcastToLensNode() )
render.setLight(self.spnp)
self.heightfield.mHeightFieldNode.setLight(self.spnp)
示例10: setupLights
def setupLights(self):
lAttrib = LightAttrib.makeAllOff()
ambientLight = AmbientLight( "ambientLight" )
ambientLight.setColor( Vec4(.4, .4, .35, 1) )
lAttrib = lAttrib.addLight( ambientLight )
directionalLight = DirectionalLight( "directionalLight" )
directionalLight.setDirection( Vec3( 0, 8, -2.5 ) )
directionalLight.setColor( Vec4( 0.9, 0.8, 0.9, 1 ) )
lAttrib = lAttrib.addLight( directionalLight )
render.attachNewNode( directionalLight.upcastToPandaNode() )
render.attachNewNode( ambientLight.upcastToPandaNode() )
render.node().setAttrib( lAttrib )
示例11: loadLights
def loadLights(self):
plight = AmbientLight('my plight')
plight.setColor(VBase4(0.12, 0.12, 0.12, 1))
self.plnp = self.render.attachNewNode(plight)
self.render.setLight(self.plnp)
light4 = PointLight('pointlight3')
plnp4 = self.render.attachNewNode(light4)
plnp4.setPos(10, 0, 8)
light5 = PointLight('pointlight5')
self.plnp5 = self.render.attachNewNode(light5)
self.plnp5.setPos(10,0, 8)
self.render.setLight(self.plnp5)
示例12: setupLights
def setupLights(self):
lAttrib = LightAttrib.makeAllOff()
ambientLight = AmbientLight( "ambientLight" )
ambientLight.setColor( Vec4(.6, .6, .55, 1) )
lAttrib = lAttrib.addLight( ambientLight )
directionalLight = DirectionalLight( "directionalLight" )
directionalLight.setDirection( Vec3( 0, 8, -2.5 ) )
directionalLight.setColor( Vec4( 0.9, 0.8, 0.9, 1 ) )
lAttrib = lAttrib.addLight( directionalLight )
#set lighting on teapot so steam doesn't get affected
#self.t.attachNewNode( directionalLight.upcastToPandaNode() )
self.t.attachNewNode( directionalLight )
#self.t.attachNewNode( ambientLight.upcastToPandaNode() )
self.t.attachNewNode( ambientLight)
self.t.node().setAttrib( lAttrib )
示例13: initAnchor
def initAnchor(self):
self.anchor = loader.loadModel(self.main.modeld + "planet")
self.anchor.reparentTo(self.main.systemNP)
self.anchor.setScale(15)
self.anchor_tex = loader.loadTexture(self.main.modeld + "anchor.jpg")
self.anchor.setTexture(self.anchor_tex)
self.anchor_sp = self.main.getPlist()[0] # anchor가 선택한 행성 (혹은 항성)
self.anchor.setPos(self.anchor_sp.getPos())
self.anchor.setZ(self.anchor_sp.getZ() + 2 * self.anchor_sp.getScale().getX())
al = AmbientLight("d")
al.setColor(VBase4(1, 1, 1, 1))
alnp = self.anchor.attachNewNode(al)
self.anchor.setLight(alnp)
self.anchor_spin = self.anchor.hprInterval(3.0, VBase3(360, 0, 0))
self.anchor_spin.loop()
示例14: _set_light_sources
def _set_light_sources(self):
light_positions = [(1,-1,1),(-1,-5,1)]
intensity = 0.8
for l_pos in light_positions:
plight = PointLight('plight')
plight.setColor(VBase4(intensity, intensity, intensity, 1))
plnp = render.attachNewNode(plight)
plnp.setPos(l_pos[0], l_pos[1], l_pos[2])
render.setLight(plnp)
light = AmbientLight('')
light.setColor(VBase4(0.4,0.4,0.4,1))
light_np = render.attachNewNode(light)
light_np.setPos(0,0,0)
render.setLight(light_np)
pass
示例15: __init__
def __init__(self, game):
super(World, self).__init__()
self.game = game
self.things = []
#initialize the rendering
self.renderer = self.game.render
self.initFog()
#FIXME do better lighting
alight = AmbientLight('alight')
alight.setColor(VBase4(0.2, 0.2, 0.2, 1))
alnp = self.renderer.attachNewNode(alight)
self.renderer.setLight(alnp)
#initialize a hud
self.hud = HUD()
self.add(self.hud)
#physics
self.world = OdeWorld()
self.world.setGravity(0, -20, 0) #FIXME (0,-9.81) would be realistic physics
self.world.initSurfaceTable(1)
self.world.setSurfaceEntry(0, 0, 0.6, 0.0, 9.1, 0.9, 0.00001, 1.0, 0.02) #FIXME I have no idea what this means
self.space = OdeSimpleSpace()
self.space.setAutoCollideWorld(self.world)
self.contactGroup = OdeJointGroup()
self.space.setAutoCollideJointGroup(self.contactGroup)
#constrain to 2d
self.plane = OdePlane2dJoint(self.world)
self.timeAccumulator = 0
self.dt = 1.0 / 60.0
#give it a player
self.player = Player(self, Point3(0,10,0))
self.add(self.player)
self.game.taskMgr.add(self.player.move, "movePlayer")