本文整理匯總了Python中pandac.PandaModules.AmbientLight.upcastToPandaNode方法的典型用法代碼示例。如果您正苦於以下問題:Python AmbientLight.upcastToPandaNode方法的具體用法?Python AmbientLight.upcastToPandaNode怎麽用?Python AmbientLight.upcastToPandaNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pandac.PandaModules.AmbientLight
的用法示例。
在下文中一共展示了AmbientLight.upcastToPandaNode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create
# 需要導入模塊: from pandac.PandaModules import AmbientLight [as 別名]
# 或者: from pandac.PandaModules.AmbientLight import upcastToPandaNode [as 別名]
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 )
示例2: setupLights
# 需要導入模塊: from pandac.PandaModules import AmbientLight [as 別名]
# 或者: from pandac.PandaModules.AmbientLight import upcastToPandaNode [as 別名]
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 )
示例3: __init__
# 需要導入模塊: from pandac.PandaModules import AmbientLight [as 別名]
# 或者: from pandac.PandaModules.AmbientLight import upcastToPandaNode [as 別名]
class Environment:
def __init__(self):
self.cameraPos = base.camera.getPos()
# create a heightfield
self.heightfield = heightfield.Heightfield(base.camera)
if USELIGHT:
self.setupLight()
if USESKY:
self.setupSky()
if USEFOG:
self.setupFog()
if USESOUND:
self.setupSound()
if USERAIN:
from src.rain import rainClass
self.setupRain()
if USENIGHT:
self.setupNight()
def setupLight(self):
self.ambientLight = AmbientLight("ambientLight")
self.ambientLight.setColor(Vec4(0.1, 0.1, 0.1, 1))
self.ambientLightNP = render.attachNewNode(self.ambientLight.upcastToPandaNode())
render.setLight(self.ambientLightNP)
self.dlight = DirectionalLight("dlight")
self.dlight.setColor(VBase4(0.8, 0.8, 0.5, 1))
self.dlnp = render.attachNewNode(self.dlight.upcastToPandaNode())
self.dlnp.setHpr(0, -30, 0)
render.setLight(self.dlnp)
"""
# 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( VBase4( 0.1, 0.1, 0.1, 1 ) )
#Make the light affect render (ie everything)
render.setLight(render.attachNewNode(self.ambientLight.upcastToPandaNode()))
"""
def setupSky(self):
self.skyNP = loader.loadModel("data/models/sky.bam.pz")
self.skyNP.reparentTo(render)
self.skyNP.setScale(4000, 4000, 1000)
self.skyNP.setPos(0, 0, 0)
self.skyNP.setTexture(loader.loadTexture("data/textures/clouds.png"))
self.skyNP.setShader(loader.loadShader("data/sky.sha"))
"""self.skyFogNP = loader.loadModel( 'data/models/sphere.egg' )
self.skyFogNP.reparentTo( base.camera )
self.skyFogNP.setTwoSided( True )
self.skyFogNP.setScale( 10 )
self.skyFogNP.setPos( Vec3(0,0,4) )
self.skyFogNP.setTransparent( True )"""
sky = Vec4(0.25, 0.5, 1.0, 0.0) # r, g, b, skip
sky2 = Vec4(1.0, 1.0, 1.0, 0.0)
clouds = Vec4(0.004, 0.002, 0.008, 0.010) # vx, vy, vx, vy
self.skyNP.setShaderInput("sky", sky)
self.skyNP.setShaderInput("sky2", sky2)
self.skyNP.setShaderInput("clouds", clouds)
render.setShaderInput("time", 0)
def setupFog(self):
"""defaultExpFogColor = (0.33, 0.5, 1.0)
self.expFog = Fog("exponentialFog")
self.expFog.setColor(*defaultExpFogColor)
self.expFog.setExpDensity(DEFAULTFOG)
render.setFog(self.expFog)"""
defaultLinFogColor = (0.165, 0.25, 0.5)
self.linFog = Fog("linearFog")
self.linFog.setColor(*defaultLinFogColor)
self.linFog.setLinearRange(0, linFogMinRange + linFogVarianceRange)
self.linFog.setLinearFallback(30, 60, 240)
base.camera.attachNewNode(self.linFog)
render.setFog(self.linFog)
base.setBackgroundColor(defaultLinFogColor)
def setupSound(self):
self.mySound1 = loader.loadSfx("data/sounds/rainshower.wav")
self.mySound1.setLoop(True)
self.mySound1.play()
def setupRain(self):
base.enableParticles()
self.rain = rainClass()
self.rain.reparentTo(base.camera)
self.rain.setScale(200)
self.rain.start(render)
def setupNight(self):
taskMgr.doMethodLater(0.05, self.dayNightCycle, "UpdateDayNight")
taskMgr.doMethodLater(0.05, self.updateScene, "updateScene")
#.........這裏部分代碼省略.........
示例4: makeFractalTree
# 需要導入模塊: from pandac.PandaModules import AmbientLight [as 別名]
# 或者: from pandac.PandaModules.AmbientLight import upcastToPandaNode [as 別名]
makeFractalTree(bodydata, nodePath,length,newPos, numIterations-1,numCopies,smallRandomAxis(vecList))
else:
drawBody(nodePath,bodydata, pos, vecList, length.getX(),False)
drawLeaf(nodePath,bodydata, pos,vecList)
#spin = nodePath.hprInterval(20, Vec3(360,0,0))
#spin.loop()
alight = AmbientLight('alight')
alight.setColor(Vec4(0.5, 0.5, 0.5, 1))
alnp = render.attachNewNode(alight.upcastToPandaNode())
render.setLight(alnp)
slight = Spotlight('slight')
slight.setColor(Vec4(1, 1, 1, 1))
lens = PerspectiveLens()
slight.setLens(lens)
slnp = render.attachNewNode(slight.upcastToLensNode())
render.setLight(slnp)
slnp.setPos(0, 0,40)
#rotating light to show that normals are calculated correctly
def updateLight(task):
global slnp
currPos=slnp.getPos()