当前位置: 首页>>代码示例>>Python>>正文


Python core.PointLight类代码示例

本文整理汇总了Python中panda3d.core.PointLight的典型用法代码示例。如果您正苦于以下问题:Python PointLight类的具体用法?Python PointLight怎么用?Python PointLight使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PointLight类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

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
开发者ID:gamingrobot,项目名称:second-sunrise,代码行数:27,代码来源:camera.py

示例2: __init__

    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)
开发者ID:grimfang,项目名称:rising_reloaded,代码行数:30,代码来源:MenuBG.py

示例3: __init__

 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)
开发者ID:TheCheapestPixels,项目名称:panda_examples,代码行数:26,代码来源:geometry.py

示例4: initLights

    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))
开发者ID:grimfang,项目名称:owp_ajaw,代码行数:29,代码来源:level01.py

示例5: setupWorld

    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)
开发者ID:kit-ipe,项目名称:sensorsEditor,代码行数:27,代码来源:m.py

示例6: Bullet

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()
开发者ID:cconger,项目名称:Asteroi3ds,代码行数:33,代码来源:main.py

示例7: setupLights

    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()
开发者ID:genusgant,项目名称:CS594-ThrottleThunder-GameClient,代码行数:34,代码来源:RRMain.py

示例8: __init__

    def __init__(self):
        base.disableMouse()
        base.cam.node().getLens().setNear(10.0)
        base.cam.node().getLens().setFar(9999999)
        camera.setPos(0, -50, 0)
        
        # Check video card capabilities.
        
        if (base.win.getGsg().getSupportsBasicShaders() == 0):
            addTitle("Toon Shader: Video driver reports that shaders are not supported.")
            return
        
        # Enable a 'light ramp' - this discretizes the lighting,
        # which is half of what makes a model look like a cartoon.
        # Light ramps only work if shader generation is enabled,
        # so we call 'setShaderAuto'.

        tempnode = NodePath(PandaNode("temp node"))
        tempnode.setAttrib(LightRampAttrib.makeSingleThreshold(0.5, 0.4))
        tempnode.setShaderAuto()
        base.cam.node().setInitialState(tempnode.getState())
        
        # Use class 'CommonFilters' to enable a cartoon inking filter.
        # This can fail if the video card is not powerful enough, if so,
        # display an error and exit.
        
        self.separation = 1 # Pixels
        self.filters = CommonFilters(base.win, base.cam)
        filterok = self.filters.setCartoonInk(separation=self.separation)
        if (filterok == False):
            addTitle("Toon Shader: Video card not powerful enough to do image postprocessing")
            return
        
        # Create a non-attenuating point light and an ambient light.
        
        plightnode = PointLight("point light")
        plightnode.setAttenuation(Vec3(1,0,0))
        plight = render.attachNewNode(plightnode)
        plight.setPos(30,-50,0)
        alightnode = AmbientLight("ambient light")
        alightnode.setColor(Vec4(0.8,0.8,0.8,1))
        alight = render.attachNewNode(alightnode)
        render.setLight(alight)
        render.setLight(plight)
        
        # Panda contains a built-in viewer that lets you view the 
        # results of all render-to-texture operations.  This lets you
        # see what class CommonFilters is doing behind the scenes.
        
        self.accept("v", base.bufferViewer.toggleEnable)
        self.accept("V", base.bufferViewer.toggleEnable)
        base.bufferViewer.setPosition("llcorner")
        self.accept("s", self.filters.manager.resizeBuffers)
        
        # These allow you to change cartooning parameters in realtime
        
        self.accept("escape", sys.exit, [0])
开发者ID:mitchellvitez,项目名称:Bubble-Bonanza,代码行数:57,代码来源:fishtank_single_copy.py

示例9: initLights

	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))

		"""
开发者ID:JauriaStudios,项目名称:pandasandbox,代码行数:57,代码来源:main.py

示例10: buildSubType

    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)
开发者ID:grimfang,项目名称:quickShadows,代码行数:53,代码来源:baseObject.py

示例11: Game

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()
开发者ID:arikel,项目名称:PPARPG,代码行数:52,代码来源:meshHandler.py

示例12: setup_light

    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()
开发者ID:bhampl-tgm,项目名称:PySolar,代码行数:13,代码来源:PySolarOrbit.py

示例13: __create_point_light

    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
开发者ID:ShengCN,项目名称:SeriousCode,代码行数:15,代码来源:light_controller.py

示例14: addLight

	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()
开发者ID:arikel,项目名称:PPARPG,代码行数:29,代码来源:meshHandler.py

示例15: __init__

    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()
开发者ID:adhoc92,项目名称:MundusSystem,代码行数:46,代码来源:the_mundus_current.py


注:本文中的panda3d.core.PointLight类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。