本文整理汇总了Python中panda3d.core.PointLight.setColor方法的典型用法代码示例。如果您正苦于以下问题:Python PointLight.setColor方法的具体用法?Python PointLight.setColor怎么用?Python PointLight.setColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.PointLight
的用法示例。
在下文中一共展示了PointLight.setColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setColor [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: __init__
# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setColor [as 别名]
class Camera:
"""Does camera set up - will probably end up with lots of options."""
def __init__(self, xml):
base.camNode.setCameraMask(BitMask32.bit(0))
#only temporary while testing
self.plight = PointLight('plight')
bright = 2
self.plight.setColor(VBase4(bright, bright, bright, 1))
#self.plight.setAttenuation(Point3(0, 0, 0.5))
plnp = base.camera.attachNewNode(self.plight)
#plnp.setPos(0, 0, 0)
render.setLight(plnp)
#base.disableMouse()
self.reload(xml)
def reload(self, xml):
pass
def start(self):
pass
def stop(self):
pass
def destroy(self):
pass
示例3: __init__
# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setColor [as 别名]
def __init__(self):
# Basics
ShowBase.__init__(self)
base.disableMouse()
base.setFrameRateMeter(True)
self.accept("escape", sys.exit)
self.camera.set_pos(-10, -10, 10)
self.camera.look_at(0, 0, 0)
# A light
plight = PointLight('plight')
plight.setColor(VBase4(0.5, 0.5, 0.5, 1))
plnp = render.attachNewNode(plight)
plnp.setPos(10, 10, 10)
render.setLight(plnp)
# Create the geometry
self.sidelength = 30
self.map_a = self.create_map(self.sidelength)
self.map_b = self.map_a
geom = self.create_geom(self.sidelength)
np = NodePath(geom)
np.reparent_to(self.render)
# Start the task to interpolate the geometry each frame
self.last_time = 0.0
self.need_to_swap_maps = True
self.taskMgr.add(self.swap_maps, 'swap_geometry', sort = 5)
self.taskMgr.add(self.interpolate_maps, 'interpolate_geometry', sort = 10)
示例4: initLights
# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setColor [as 别名]
def initLights(self):
torches = self.level.findAllMatches("**/TorchTop*")
self.lights = []
for torch in torches:
tLight = PointLight(torch.getName())
tLight.setColor((.4, .2, .0, 1))
tlnp = render.attachNewNode(tLight)
tlnp.setPos(torch.getPos(render))
render.setLight(tlnp)
self.lights.append(tlnp)
windows = self.level.findAllMatches("**/Window*")
plates = self.level.findAllMatches("**/Plate*")
spikes = self.level.findAllMatches("**/Spikes*")
for window in windows:
wLight = Spotlight(window.getName())
lens = PerspectiveLens()
wLight.setLens(lens)
wLight.setColor((0.5, 0.4, 0.5, 1))
wlnp = render.attachNewNode(wLight)
wlnp.setPos(window.getPos(render))
wlnp.lookAt((0, window.getY(), 0))
for plate in plates:
plate.setLight(wlnp)
self.lights.append(wlnp)
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor((.1, .1, .025, 1))
render.setLight(render.attachNewNode(ambientLight))
示例5: setupWorld
# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setColor [as 别名]
def setupWorld(self):
""" responsible for loading all models """
# load our ball
self.mBall = self.loader.loadModel("data/cube")
# add to scenegraph
self.mBall.reparentTo(self.render)
# set position
self.mBall.setScale(1.0, 1.0, 1.0)
# self.mBall.setPosHpr(0,0,0,0.,45.,0)
self.mBall.setColor(0.0, 0.2, 0.8)
# use object tag to find the object when picking
self.mBall.setTag("MyObjectTag", "1")
self.mBall.setRenderModeWireframe()
# Panda's coordintes are Z is up, -Y is forward, and X is to the right
# it also uses degrees as the orientation component
# self.camera.setPos(0, -6.0, 0)
angleDegrees = 0
angleRadians = angleDegrees * (math.pi / 180.0)
self.camera.setPos(2 * math.sin(angleRadians), -5.0 * math.cos(angleRadians), 0)
self.camera.setHpr(angleDegrees, 0, 0)
# lets create a light
plight = PointLight("plight")
plight.setColor(Vec4(0.7, 0.7, 0.7, 1))
plnp = self.render.attachNewNode(plight)
plnp.setPos(self.mBall, 0, 0, 40)
self.render.setLight(plnp)
示例6: Bullet
# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setColor [as 别名]
class Bullet(DirectObject):
def __init__(self, ship, bulletPos, bulletVelocityVec, collisionHandler):
self.model = game.loader.loadModel("Models/bullet.egg.pz")
self.model.setPos(bulletPos)
self.model.setScale(BULLET_SIZE)
self.model.reparentTo(render)
self.model.setPythonTag("owner", self)
self.ship = ship
finalPosition = bulletPos + (bulletVelocityVec * BULLET_TRAVEL_TIME)
self.trajectory = self.model.posInterval(BULLET_TRAVEL_TIME, finalPosition).start()
self.collisionNode = self.model.attachNewNode(CollisionNode("bullet"))
self.collisionNode.node().addSolid(CollisionSphere(0,0,0,1))
base.cTrav.addCollider(self.collisionNode, collisionHandler)
# Add Point Light to the bullet
self.plight = PointLight('plight'+str(random()))
self.plight.setColor(Vec4(1,1,1,1))
self.plight.setAttenuation(Vec3(0.7, 0.05, 0))
self.plnp = self.model.attachNewNode(self.plight)
render.setLight(self.plnp)
render.setShaderInput("light", self.plnp)
###
# Bullet.remove
#
# Removes this asteroid from rendering and registering collisions.
##
def remove(self):
self.ignoreAll()
self.model.remove()
self.collisionNode.remove()
示例7: setupLights
# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setColor [as 别名]
def setupLights(self):
base.setBackgroundColor(0.0, 0.0, 0.0, 1)
base.setFrameRateMeter(True)
# Add a light to the scene.
self.lightpivot = render.attachNewNode("lightpivot")
self.lightpivot.setPos(0, 0, 5)
self.lightpivot.hprInterval(10, Point3(360, 0, 0)).loop()
plight = PointLight('plight')
plight.setColor(Vec4(1, 0, 0, 1))
plight.setAttenuation(Vec3(0.37, 0.025, 0))
plnp = self.lightpivot.attachNewNode(plight)
plnp.setPos(45, 0, 0)
plnp.lookAt(*Vec3(0, 0, 0, ))
# Light
alight = AmbientLight('ambientLight')
alight.setColor(Vec4(0.2, 0.2, 0.2, 1))
alightNP = render.attachNewNode(alight)
# dlight = DirectionalLight('directionalLight')
# dlight.setDirection(Vec3(1, 1, -1))
# dlight.setColor(Vec4(0.7, 0.7, 0.7, 1))
# dlightNP = render.attachNewNode(dlight)
render.clearLight()
render.setLight(alightNP)
# render.setLight(dlightNP)
render.setLight(plnp)
# create a sphere to denote the light
sphere = loader.loadModel("models/sphere")
sphere.reparentTo(plnp)
render.setShaderAuto()
示例8: initLights
# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setColor [as 别名]
def initLights(self):
# Create some lighting
#self.environ.ls()
#print(self.environ.findAllMatches("**/Spot"))
ambientLight = AmbientLight("ambientLight")
ambientLight.setColor(Vec4(0.8, 0.8, 0.8, 0.65))
"""
directionalLight = DirectionalLight("directionalLight")
directionalLight.setDirection(Vec3(-10, -10, 5))
directionalLight.showFrustum()
directionalLight.setColor(Vec4(1, 1, 1, 1))
directionalLight.setSpecularColor(Vec4(1, 1, 1, 1))
dirnp = render.attachNewNode(directionalLight)
dirnp.setPos(10, 0, 6)
"""
plight1 = PointLight('plight1')
plight1.setColor(VBase4(1, 1, 1, 1))
plight1.showFrustum()
#plight1.setShadowCaster(True)
plnp1 = render.attachNewNode(plight1)
plnp1.setPos(26.71, -33.2, 26)
plight2 = PointLight('plight2')
plight2.setColor(VBase4(1, 1, 1, 1))
plight2.showFrustum()
plnp2 = render.attachNewNode(plight2)
plnp2.setPos(-25, 25, 25)
slight = Spotlight('slight')
slight.setColor(VBase4(1, 1, 1, 1))
lens = PerspectiveLens()
lens.setFilmSize(1, 1) # Or whatever is appropriate for your scene
slight.setLens(lens)
slight.setShadowCaster(True, 512, 512)
slight.showFrustum()
slnp = render.attachNewNode(slight)
slnp.setPos(0, 0, 100)
slnp.lookAt(Vec3(0,0,0))
render.setLight(slnp)
render.setLight(plnp1)
render.setLight(plnp2)
#render.setLight(render.attachNewNode(ambientLight))
#render.setLight(dirnp)
render.setShaderAuto()
#render.setLight(render.attachNewNode(directionalLight))
"""
示例9: buildSubType
# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setColor [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)
示例10: Game
# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setColor [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()
示例11: setup_light
# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setColor [as 别名]
def setup_light(self):
# light
plight = PointLight('plight')
plight.setColor(VBase4(1, 1, 1, 1))
self.plnp = self.base.render.attachNewNode(plight)
self.plnp.setPos(0, 0, 0)
alight = AmbientLight('alight')
alight.setColor(VBase4(.1, .1, .1, 1))
self.alnp = self.planets['sun'].get_model().attachNewNode(alight)
self.planets['sun'].get_model().setLightOff()
self.toggle_light()
示例12: __create_point_light
# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setColor [as 别名]
def __create_point_light(self,
lightId,
lightColor,
lightPos,
shadow = True):
pointLight = PointLight(lightId)
pointLight.setColor(lightColor)
pointLight.setShadowCaster(shadow)
pointLightNP = NodePath(pointLight)
pointLightNP.setPos(lightPos)
return pointLightNP
示例13: __init__
# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setColor [as 别名]
def __init__(self):
#initialization
self.title = OnscreenText( # display title
text="""Mundus
/u/adhoc92""",
parent=base.a2dBottomRight, align=TextNode.A_right,
style=1, fg=(1, 1, 1, 1), pos=(-0.1, 0.1), scale=.07)
base.setBackgroundColor(0, 0, 0) # Set the background to black
camera.setPos(0, 0, 45) # Set the camera position (X, Y, Z)
camera.setHpr(0, -90, 0) # Set the camera orientation
#(heading, pitch, roll) in degrees
#sets up PointLighting to simulate Light coming from Magnus
plight = PointLight('plight')
plight.setColor((1, 1, 1, 1))
plnp = render.attachNewNode(plight)
plnp.setPos(20, 0, 0) #position just in front of Magnus
render.setLight(plnp) #because if pos set behind Magnus than the side of Magnus within the star sphere will not be illuminated
#sets up AmbientLighting so that the dark side of plane(t)s/moons aren't /too/ dark.
alight = AmbientLight('alight')
alight.setColor((0.2, 0.2, 0.2, 1))
alnp = render.attachNewNode(alight)
render.setLight(alnp)
# Here again is where we put our global variables. Added this time are
# variables to control the relative speeds of spinning and orbits in the
# simulation
# Number of seconds a full rotation of Earth around the sun should take
self.yearscale = 60
# Number of seconds a day rotation of Earth should take.
# It is scaled from its correct value for easier visability
self.dayscale = self.yearscale / 364.0 * 15 # 364 days in Nirn year
self.orbitscale = 2 # Orbit scale
self.sizescale = 0.6 # Planet size scale
self.loadPlanets() # Load and position the models
# rotatePlanets function that puts the plane(t)s and moons into motion
self.rotatePlanets()
示例14: __init__
# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setColor [as 别名]
def __init__(self):
ShowBase.__init__(self)
self.gameTask = taskMgr.add(self.flyCircles, "circles")
base.disableMouse()
base.camera.setPos(50, 100, 800)
base.camera.lookAt(0, 0, 0)
dl = DirectionalLight('dLight')
dl.setColor(Vec4(0.1,0.1,0.1,1))
dlNP = render.attachNewNode(dl)
dlNP.setPos(1000,1000,0)
al = AmbientLight('alight')
al.setColor(Vec4(0.3, 0.3, 0.3, 1))
alNP = render.attachNewNode(al)
pl = PointLight('plight')
pl.setColor(VBase4(0.2,0.2,0.2,1))
plNP = render.attachNewNode(pl)
plNP.setPos(100,100,100)
render.setLight(plNP)
self.shipList = [
Bwing("xwing1"),
TieInterceptor("tie1")
]
for i, ship in enumerate(self.shipList):
ship.reparentTo(render)
ship.setScale(2)
ship.setPos(Point3(i*10,i*0,i*0))
# ship.setLight(dlNP)
ship.setLight(alNP)
self.count = 0
self.iter = 0
示例15: __init__
# 需要导入模块: from panda3d.core import PointLight [as 别名]
# 或者: from panda3d.core.PointLight import setColor [as 别名]
def __init__(self):
ShowBase.__init__(self)
self.disableMouse()
self.camera.setPos(10, -80, 70)
self.camera.lookAt(10, 20, 0)
self.camLens.setFov(90.0)
self.win.setClearColor(Vec4(0,0,0,0))
make_level(self.render)
self.accept("escape", exit)
self.accept("arrow_up", self.forward)
self.accept("arrow_down", self.reverse)
self.accept("arrow_left", self.turn_left)
self.accept("arrow_right", self.turn_right)
self.accept("1", self.set_camera)
self.accept("2", self.set_camera_out)
self.accept("3", self.spin_camera_left)
self.accept("4", self.spin_camera_right)
slight = PointLight('slight')
slight.setColor(Vec4(1, 1, 1, 1))
slnp = render.attachNewNode(slight)
render.setLight(slnp)
slnp.setPos(self.camera, 0, 0, 20)
alight = AmbientLight('alight')
alight.setColor((0.2, 0.2, 0.2, 1))
alnp = render.attachNewNode(alight)
render.setLight(alnp)
title = OnscreenText(text="Bard's Tale I",
style=1, fg=(1,1,1,1),
pos=(0.7,0.92), scale = .07)
self.dir = Direction()
self.pos = Vector([0, 0])
self.set_camera()
self.map = make_map()